views:

43

answers:

2

I recently started using SourceMonitor to review my (and others) code. Though i understand other parameters judged by the tool, i don't know how does it calculates the complexity of the code. As in, what all parameters does it considers to read to a complexity number?

Any feedback/suggestion would be of help. Thanks.

+2  A: 

It is hard to know without them stating it, but one of the most common measures is cyclomatic complexity - a measure of the number of routes through code. A simple top-to-bottom procedural method has complexity 1, with all loops / branches / catches etc adding to this. The idea is that if this grows too high, your method is doing too much and should be refactored into a few smaller, more targetted methods.


Edit; from here:

A parser for C# has been added. Most of the metrics are similar to C++ and Java. The primary difference is how the "biggest" method is determined. Instead of identifying the method with the most statements, for C# the most complex method is found for each file. The complexity measurement is similar to Cyclomatic Complexity - a count of the possible pathways through the code.

(emphasis mine) so it sounds like they have a slightly modified variant of regular CC. Only they can tell you what they did different ;p

Marc Gravell
A: 

Found it in Help -> Help Topics -> Explanation of language Metrics -> C# -> Max Method Complexity -> (There is a hyperling) Complexity Value.

Source  Monitor Complexity Value

Amby