Recently I got into using static analysis tools like sonarqube and Teamscale.

However, they only show metrics at Project/Package/Class level. I am particularly interested in assessing the quality of Java methods, but the only tool I found that returns results at a method level was Sourcemeter and the respective plugin for Sonarqube.

Are there any other static analysis tools out there that provide metrics at a method level?

  • Any indications of budget, OS, etc? – Steve Barnes Jun 8 '20 at 5:03
  • @SteveBarnes This is for a research project, therefore I don't have to stick to a certain OS or am limited to a budget etc. – heckDev Jun 8 '20 at 21:26
  • It might be worth editing your question to specify "Free or Low Cost" as some of the tools that I am aware of cost many thousands. – Steve Barnes Jun 9 '20 at 4:47

Many linters are available, and usually report at the method/function level.

A couple that are worth looking at for Java are:

It might even be worth taking a look at squale!

There is even a linter built into the Oracle Javac compiler (enabled with the -Xlint flags)


JArchitect tool gives you many metrics at a method level including Architecture/Design/Implementation metrics. And by using its code query language you can easily query exactly what you want as metrics, and also calculate your own ones based on the existing metrics.

// <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 { 

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.