Strange case technical debt calculation

  • SonarCloud
  • Wolters Kluwer Spain instance purchased 2M lines of code
  • strange technical debt calculation

In some of our analysis we have detected a folder with Manteniability Rating of new code E but the files included in the folder have maintenability rating A.

I uploaded a screenshot of the case.

How is possible this case?

Hi @rortiz

Sorry for the delayed answer, and welcome to the community forum.
Was the issue reproduced on several analysis recently (less than 1 month)?

If the issue is reproduced, could you please provide us

  • the ID of a background task after which the ratings were incoherent? It is located on the Administration menu of your project > Background Tasks, column ID.
  • the logs produced by the scanner during that same analysis
1 Like

Hi @rortiz,

After digging a bit more into the rating calculation, I think it is normal, while disturbing.
Let me explain.
The new maintainability rating is computed from the technical debt ratio.
“E” is for a ratio greater than 5%.

That ratio is computed from the new technical debt, and the new development cost.
The ratio of a directory, is computed from the sum of the new debt of all the files and sub-directories, and the sum of the new dev cost of all the files and sub-directories.

It means than each file may have a ratio lower than 5% (it can be because the quality is fine or because there is not enough data to compute the ratio, for example if the cost is 0).
But when summing the values and going up on the directory tree, at some point, the ratio goes up, and the rating changes.

You can have more information on the Maintainability metrics on the SonarCloud documentation.


In case it helps, here are the actual measures with numbers that have lead to this result:

component      new_debt new_dev_cost
css                   2            0
js                  285            0
index.html         null           60
Roxy_Fileman        287           60

As you see, using the formula new_debt / new_dev_cost we don’t have meaningful values for the elements of Roxy_Fileman, and thus they get an A rating. With the sum of the numbers the formula becomes computable, and then 287 / 60 yields an E rating.