Вопрос

In Sonar, for a particular Java class, I see :

Complexity:     830

Complexity /method:     8,1

How could you explain the difference between those two metrics ?

Is "Complexity" the class complexity ?

What is the maximum complexity a class should be under ? I know methods should be less than 10 for method complexity, but what is the maximum class complexity number a class should conform to be considered not complex ?

Thanks.

EDIT

I also look at Cyclomatic-Complexity rule violations in the file.

For a number of methods, sonar says with different complexity numbers (in french) :

"La complexité cyclomatique de la classe est de 28 alors que le maximum autorisé est de 10."

in english :

"The class cyclomatic complexity is 28 but the maximum allowed is 10".

I don't understand why it says "class cyclomatic complexity" as it seems as a "method cyclomatic complexity".

Also, the class in question does not appears on top of the most complex class sorted by average complexity/method, as sonar says it has only 8,1 average method complexity.

Это было полезно?

Решение

You can have a look at our "Metric Definitions" Wiki page (and more specifically on the "Complexity" section) to know more about the meaning of metrics found in Sonar.

  • "Complexity" is the total complexity of a resource (for a file => sum of the complexities of every class defined in the file)
  • "Complexity / method" is the "Complexity" divided by the number of methods found in the file
  • ... and so on for the other metrics.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top