0

I ran radon cc -s myFile.py to calculate Cyclo metrics for it, I have pasted part of the result below

...
(more stuff)
C 37:0 MyClass - A (3)
M 40:4 MyClass.letter - A (2)
M 47:4 MyClass.fullname - A (2)
M 58:4 MyClass.__str__ - A (1)
...
(more stuff)

The Documentation for Radon doesn't specify how the metric will be calculated for class particularly. For me, it doesn't make sense for a class to have cyclomatic complexity as it doesn't represent a code flow by itself like a method or a function would do , and even if there was I would expect the Cyclomatic complexity for the class to be the sum of CCs for its methods, which is clearly not the case here.

95_96
  • 341
  • 2
  • 12

1 Answers1

1

Here is the implementation: https://github.com/rubik/radon/blob/f11f905d3c1b9a300dcb811ddf714902e087beee/radon/visitors.py#L122-L283

It appears there is a setting which makes radon start counting at 0 instead of counting at 1, though it's unclear from their documentation how to trigger this

It doesn't appear that this is a standard form of complexity counting such as McCabe's but one that's slightly more practical for python (choosing for instance to treat try blocks specially)

anthony sottile
  • 61,815
  • 15
  • 148
  • 207