What are the parameters used to calculate complexity in SourceMonitor?
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 ca开发者_开发知识库lculates the complexity of the code. As in, what all parameters does it considers to read to a complexity number?
Found it in Help -> Help Topics -> Explanation of language Metrics -> C# -> Max Method Complexity -> (There is a hyperling) Complexity Value.
Source Monitor Complexity Value http://tinypic.com/r/10yi0kp/6
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
精彩评论