how to list methods with most cyclomatic complexity

允我心安 提交于 2019-12-24 00:16:45

问题


I have installed sonar 2.12. Going to Violations > Major > Cyclomatic Complexity I can see the number of methods with CC over 10, but I need to go method by mehod to see its actual CC. I wonder if there a way to see a list of the methods with most CC?


回答1:


Our tool, SourceMeter has a plug-in for SonarQube that can list the most complex methods. It provides widgets for method level metrics. You can check it out here.




回答2:


There should be a rule to check for methods with high complexity; configure the threshold and run your analisys.

Then use Sonar REST api to query for hits of that rule. The result will include filename, line number and the message will tell you complexity value.

This is the operation you will have to invoke: http://docs.codehaus.org/pages/viewpage.action?pageId=229743298




回答3:


With Sonar 2.12, you can customize the dashboard of your project (with admin rights) in order to display the "metric hotspot widget" which you can configure to display the cyclomatic complexity metric. This way, you will see the highest CC of your project.

Read more on how to customize your dashboard.



来源:https://stackoverflow.com/questions/8383779/how-to-list-methods-with-most-cyclomatic-complexity

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!