Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interpret code metrics (calculated by SourceMonitor)

After reading the answers to the question "Calculate Code Metrics" I installed the tool SourceMonitor and calculated some metrics.

But I have no idea how to interpret them.

What's a "good" value for the metric

  • "Percent Branch Statements"
  • "Methods per Class"
  • "Average Statements per Method"
  • "Maximum Method or Function Complexity"

I found no hints in the documentation, can anybody help me?

like image 933
Thomas Koschel Avatar asked Sep 25 '08 16:09

Thomas Koschel


Video Answer


1 Answers

SourceMonitor is an awesome tool.

"Methods Per Class" is useful to those who wish to ensure their classes follow good OO principles (too many methods indicates that a class could be taking on more than it should).

"Average Statements per Method" is useful for a general feel of how big each method is. More useful to me is the info on the methods with too many statements (double click on the module for finer grain detail).

Function Complexity is useful for ascertaining how nasty the code is. Truly I use this info more than anything else. This is info on how complicated the nastiest function in a module is (at least according to cyclomatic complexity). If you double click on the module / file you can find out which particular method is so bad.

like image 107
torial Avatar answered Nov 14 '22 11:11

torial