Per-function measures

Summary

Thing Value
Version v2026.1.1 (121187)
Deployment Some Azure VM somewhere
Goal Retrieve metrics per function via the REST API (using the CLI tool)
Attempted sonar api get “/api/measures/component_tree?component=PGIMB&metricKeys=complexity&qualifiers=MET&ps=500”

More detail

For compliance, I am required to report on a number of metrics over our code, per function and averaged over functions per module and across the whole code. I must, for example, report those figures for the cyclomatic complexity and the proportion of code which is comments.

I understand that SonarQube will catch functions which exceed our cyclomatic complexity threshold, however, I am also required to report on the actual figures.

I was advised by the accursed Copilot that adding qualifiers=MET to my API query (MET standing for Method-level, apparently) would yield per-function information, however, this appears not to work.

How do I get the per-function information? This does seem like the most useful number - perhaps even the only really important one.

Thanks for the help,
Jack White

Hi,

Can you be explicit about what compliance you’re trying to achieve? Is this a particular industry standard? Something else?

:flushed_face: Ehm… AI has been known to hallucinate.

As discussed in another thread on exactly this same topic: we simply don’t store method/function-level metrics.

 
Ann