首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >方法/函数级别的静态分析工具?

方法/函数级别的静态分析工具?
EN

Stack Overflow用户
提问于 2020-06-06 02:24:46
回答 1查看 66关注 0票数 1

最近,我开始使用静态分析工具,如sonarqube和Teamscale。

但是,它们仅显示项目/包/类级别的指标。我对评估Java方法的质量特别感兴趣,但我发现在方法级别返回结果的唯一工具是Sourcemeter和相应的Sonarqube插件。

有没有其他静态分析工具可以提供方法级的指标?

EN

回答 1

Stack Overflow用户

发布于 2020-06-08 18:15:12

您可以尝试JArchitect,它在方法级别为您提供了许多指标,包括架构/设计/实现指标。通过使用它的代码查询语言,您可以很容易地准确查询您想要的指标,还可以根据现有的指标计算您自己的指标。

代码语言:javascript
复制
// <Name>Avoid methods too big, too complex</Name>
warnif count > 0 from m in JustMyCode.Methods where 
    (m.NbLinesOfCode > 35 ||
   m.CyclomaticComplexity > 20)

  let complexityScore = m.NbLinesOfCode/2 + m.CyclomaticComplexity 

  orderby complexityScore descending,
          m.CyclomaticComplexity descending
select new { 
   m, 
   m.NbLinesOfCode,
   m.CyclomaticComplexity, 
   complexityScore,

   Debt = complexityScore.Linear(30, 40,    400, 8*60).ToMinutes().ToDebt(),

   // The annual interest varies linearly from interest for severity minor 
   // to interest for severity major
   AnnualInterest = complexityScore .Linear(30,     Severity.Medium.AnnualInterestThreshold().Value.TotalMinutes, 
                                            200, 2*(Severity.High.AnnualInterestThreshold().Value.TotalMinutes)).ToMinutes().ToAnnualInterest()

}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62221923

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档