声纳-LOC&圈复杂度 [英] Sonar -LOC & Cyclomatic complexity
问题描述
Sonar如何计算软件指标,尤其是LOC和圈复杂度?它使用任何特定的工具吗?如果是的话,也请给出名字.
How does Sonar calculates software metrics particularly LOC and cyclomatic complexity? Does it uses any particular tools? IF yes, please also give the names.
推荐答案
对于每种受支持的语言,"squid"插件用于解析源代码并确定一些基本指标,例如LOC和复杂性.复杂度的计算方式因插件而异.
For each supported language, a "squid" plugin is used to parse the source code and determine some base metrics such as LOC and complexity. How the complexity is calculated varies based on the plugin.
For example, here's the source code files for the JavaScript plugin: https://github.com/SonarCommunity/sonar-javascript/tree/master/javascript-squid/src/main/java/org/sonar/javascript/metrics In this case, the complexity is calculated in the plugin itself using a very simple formula.
And here is the same set of classes for the C# support: https://github.com/SonarCommunity/sonar-dotnet/tree/master/sonar/csharp/sonar-csharp-squid/csharp-squid/src/main/java/com/sonar/csharp/squid/metric
但是,指标的创建可以由任何插件完成,因此,如果您想补充数据或以其他方式显示数据,则可以编写自己的插件.
The creation of metrics, though, can be done by any plugin, so you could write your own plugin if you wanted to supplement the data, or display the data in a different way.
也请看一下.net插件维护者之一Fabrice对这个问题(关于创建新插件)的答案:
Also take a look at the answer to this question (about creating a new plugin) by Fabrice, one of the .Net plugin maintainers: SonarQube - help in creating a new language plugin
这篇关于声纳-LOC&圈复杂度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!