Search code examples
sonarqubesonar-runnercode-duplicationsonarqube-scan

Does SonarQube calculates "Effort to reach Maintainability Rating A" considering code duplication?


it looks like that out-of-the-box SonarQube 6 (6.3.1) does not consider the time to fix "Duplicated Code" and "Comments" when presenting the effort in the "Effort to reach Maintainability Rating A" metric. Is that correct?

If so, is there a way to add in the effort the time needed to fix duplicated code and/or lack of comments (%) ? I see there is a rule "Source files should not have any duplicated blocks" that can be activated. Is that all is needed to calculate time to fix duplicated code?

Does technical debt also accounts for comments ?

Sonar documentation does not state how "Effort to reach Maintainability Rating A" metric is calculated in https://docs.sonarqube.org/display/SONAR/Metric+Definitions


Solution

    • The Maintainability Rating is based on the Technical Debt
    • Technical Debt is the sum of the estimated remediation time of all Code Smells
    • Code Smell issues are raised by the Code Smell rules included in the profile

    To include coverage and duplications in your Maintainability Rating, include the relevant rules. The rest will happen automatically.