Is it possible to count files that exceed a Code Smells threshold in SonarQube?

Hi,
I’m looking for a way to count how many files exceed a specific threshold of Code Smells in SonarQube. For example, if I set a rule that a file should have no more than 2 Code Smells, I’d like to know how many files in my project exceed that limit.

Is there any metric or query in SonarQube that can provide this information? Or would it be necessary to use an external integration with the SonarQube API to process these data?

Thanks in advance for your help!

In the Measures tab of a project you can drill into an issue type (like maintainability issues). While it’s not exactly a count (show me all the files with more than 2), it might help you better understand your project.

For any more intense processing, you’d need to use the API. Luckily, getting a metric for all files in a project is not that hard (GET api/measures/component_tree with metric_keys set to code_smells and strategy set to leaves)