So,
This feels like bug, but maybe it’s a configuration issue, but when dealing with descendant classes from an abstract there is a pattern that I’ve noticed:
(forgive the pseudo-code, but the replicating is very easy)
abstract CodeGenBase
{
protected abstract GenericTypeStart {get;}
protected abstract GenericTypeEnd {get;}
}
CodeGenVb : CodeGenBase
{
types = {typeof(int), typeof(uint), typeof(string)}
names = {"Integer", "UInteger", "String"}
protected override GenericTypeStart => "(Of ";
protected override GenericTypeEnd => ")";
}
CodeGenCs : CodeGenBase
{
types = {typeof(int), typeof(uint), typeof(string)}
names = {"int, "uint", "string"}
protected override GenericTypeStart => "<";
protected override GenericTypeEnd => ">";
}
}
It’s a paltry example, but this in an abstract class being implemented for two different scenarios, albeit similar, but still unique in their own right.
The fact that GenericTypeStart/End exist in both is because they’re abstract, and the lines are not duplicated just the property def, but the value is different for both, so part of the line is duplicated by necessity of abstract implementations, but the entire line is not duplicate.
Similarly the “names” constant exists in both, but has different values in each of the descendants.
Because the values are different, even unto the simple case sensitivity differentiation between VB and C# these are considered to be duplicate lines. One Class create VB code, the other Creates C#, so Void and void may mean the same thing, but they are distinctly different and not subject to being identified as code duplication.
I don’t know if there is a case sensitive configuration to the SonarQube scanner, but especially when dealing with string values ("") and the c# language, case sensitivity should be enabled in duplicate code analysis. As well, abstract base classes should be a factor in the determination. Abstract methods and properties should never be considered in terms of duplication, especially when they return different values.
Thanks
Jaeden “Sifo Dyas” al’Raec Ruiner
- Version 6.7.5 (build 38563)