【问题标题】:Static Analysis Tools at Method/Function Level?方法/功能级别的静态分析工具?
【发布时间】:2020-06-05 18:24:46
【问题描述】:

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

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

是否有任何其他静态分析工具可以提供方法级别的指标?

【问题讨论】:

标签: java function methods static-analysis


【解决方案1】:

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

// <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()

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-19
    • 2019-06-14
    相关资源
    最近更新 更多