Cyclomatic Complexity: Resharper vs CodeMaid

3.1k views Asked by At

I've been using both CodeMaid and Resharper for some time now, and noticed they both calculate Cyclomatic Complexity. Although, their calculation always differ, so I'm thinking that their calculating logic also does. But, to your experience, which one is more accurate? It sseems that Resharper's is usually higher, but CodeMaid's is easier to spot.

Is one of them calculating it wrong, perhaps? Or just differently, but acceptable?

Thanks in advance!

1

There are 1 answers

1
citizenmatt On

I can't speak to CodeMaid's implementation, but ReSharper's is based on parsing the source code into an abstract syntax tree, and actually building a control flow graph based on this information (this control flow graph is also used for null value analysis, tracing when things are null, not null or unknown, allowing for inspections such as "possible NullReferenceException"). I would expect ReSharper's to be an accurate calculation, but don't know for sure.

That said, as long as the difference between the values is fairly consistent, then it doesn't matter what the exact value is - just so long as you know what threshold means the code you have is too complex.