I’m charge to evaluate some codemetrics tools for making the suitable election of them for some projects of our company.
Reading the SonarQube’s documentation, I didn’t clearly find a place where the following metrics at function level are included and the explanation of how to calculate and report them:
Cyclomatic Complexity (McCabe complexity) at function level.
Number of sentences / LoC by each function.
% of comments per function.
Please, can anyone explain us if SonarQube calculates these metrics and how to find a report of them?
If you reeeally have to have this, then there’s a very painful way to get it. What you can do is turn on the relevant rules (Methods should not be too complex, Methods should not have too many lines of code, …) and set all their thresholds to 0. I would suggest you activate these rules with an Info severity, because this is going to be suuuper noisy. Then you’ll have the count of each thing for each method in the issue message. Unfortunately, you’ll have to parse the issue messages to get your counts.
If you’re looking for methods that cross thresholds, then the rules are exactly what you need. Just activate them with your desired thresholds. An issue will be raised when (and only when) a method crosses the threshold. You can then use web services to extract issue data. Each issue will identify the component (file), line, and the segment of the line involved. You won’t get method names directly from that, but you’ll be able to figure it out easily. From there, you can build the tables you want.
Really we need to know the exact method (or function) that violates the thresholds. The approach mentioned is useful for developers, but for management level and for delivering to Customers, we need to know the method with out-of-limits values.
Is possible to find in any easy way to obtain this information in a table form?