- SonarQube Developer Edition 7.7
- SonarJava 5.13.1 (build 18282)
A branch has over 10% code duplication on new code, which has triggered a quality gate to fail. We have a rather low % on code duplication on new code, because usually our developers are actually getting better all the time at writing good code.
The only changes in this particular branch, were improvements on Javadocs. No “actual code” changes.
On closer inspection, it turns out to be that 2 files have 100% duplication on new code.
On even closer inspection, it turns out that in both files, the new lines are 2 Javadoc lines that have been added, and those two lines are identical to 2 Javadoc lines in another class.
My questions:
- Is it expected to have “code duplication” detection on comments, not code?
- How do other companies and development teams deal with a situation like this? What are best practices?
Some ideas I already have, without making any changes to the code:
- Combine this branch with another branch, so that “numerically” the code duplication % is below the quality gate.
- Raise the quality gate to let this code duplication pass