Hello,
Duplicated code detection (Rule common-kotlin:DuplicatedBlocks, Source files should not have any duplicated blocks) report issues on duplicated code in annotations. I believe that both Java and Kotlin duplication in annotations could be pretty common for multiple frameworks and use cases.
Here is an example where we hit that false positive, using Swagger and some annotations:
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import io.swagger.v3.oas.annotations.tags.Tags
open class SomeClass {
@Post("/foo")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(
ApiResponse(
description = "description 1", responseCode = "200",
content = [Content(mediaType = MediaType.APPLICATION_JSON)]
),
ApiResponse(
description = "Invalid payload", responseCode = "400",
content = [Content(mediaType = MediaType.APPLICATION_JSON)]
),
ApiResponse(
description = "Not authorized", responseCode = "401",
content = [Content(mediaType = MediaType.APPLICATION_JSON)]
),
ApiResponse(
description = "not found", responseCode = "404",
content = [Content(mediaType = MediaType.APPLICATION_JSON)]
),
ApiResponse(
description = "Internal Server error", responseCode = "500",
content = [Content(mediaType = MediaType.APPLICATION_JSON)]
)
)
open fun fooBar(): Single<HttpResponse<String>> {
}
[...]
Reproducible environment: Sonarqube 8.9.x