Sonar marks classes implementing abstract class as duplicate code


I have two classes, XClientSettings and YClientSettings, both implementing an abstract class ClientSettings. They only define constructors, however the code in both classes is marked as duplicate. It’s worth noting that the Strings in the @Value annotations differ inside the reported duplicate block (e.g. "\${XXX.circuitBreaker.maximumAttempts:10}" in XClientSettings class vs "\${YYY.circuitBreaker.maximumAttempts:10}" in YClientSettings class - which in my opinion should disallow them from being considered duplicate.

open class XClientSettings(
        override val maxAttempts: Int = 10,
        override val timeout: Int = 30,
        override val expirationTime: Int = 300,
        override var retry: Boolean = true
) : ClientSettings() {
        override val serviceName = "X"

Is it expected behavior? I’ve disposed of this issue by setting sonar.cpd.exclusions in build.gradle of my project, however I’m not sure whether such examples should be really considered as duplicates. Any suggestions on this issue?


Hello @magnes,

Thanks for your feedback.

To my mind, this example should not be considered as a duplicate.

Could you please clarify what version of SQ you’re using? There were some changes in the Kotlin rules in recent versions. So we need to understand, whether it was introduced recently or was there before.

In the meantime you can mark this exact issue in SQ ui as FP or Won' fix.


Hi @Margarita_Nedzelska,
Thank you for quick response :slight_smile: We’re using SQ 8.8.

Thanks for your response @magnes

Could you, please update your SQ to 9.0 and check whether the issue still reproduces.