最近,我开始使用静态分析工具,如sonarqube和Teamscale。
但是,它们仅显示项目/包/类级别的指标。我对评估Java方法的质量特别感兴趣,但我发现在方法级别返回结果的唯一工具是Sourcemeter和相应的Sonarqube插件。
有没有其他静态分析工具可以提供方法级的指标?
发布于 2020-06-08 18:15:12
您可以尝试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()
}https://stackoverflow.com/questions/62221923
复制相似问题