sonarqube_worst_metrics
Rank projects by the worst value of a single metric, like bugs or coverage, to identify which need attention most.
Instructions
Rank projects by the worst value of a single metric.
Algorithm:
Pull up to
candidate_poolprojects (optionally filtered byquery).Bulk-fetch
metricfor all of them in one/api/measures/searchcall.Sort descending or ascending depending on whether higher is worse (e.g. bugs → descending, coverage → ascending).
Return the top
limit.
For fine-grained metrics (bugs, vulnerabilities, code_smells,
ratings, duplicated_lines_density, open_issues) higher is worse.
For coverage, tests, line_coverage, branch_coverage —
lower is worse.
Examples:
- Use when: "Top 10 worst-coverage services across the org"
→ metric='coverage', limit=10.
- Use when: "Which einvy:* projects have the most bugs?"
→ metric='bugs', query='einvy', limit=5.
- Use when: "What projects have the worst security rating?"
→ metric='security_rating'.
- Don't use when: You only care about one project — use
sonarqube_project_metrics (one API call instead of two).
- Don't use when: You want branch-specific ranking — SonarQube's
/api/measures/search endpoint doesn't accept branch, so
this tool always ranks main-branch values.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| metric | Yes | Metric key to rank by. Common picks: 'bugs', 'vulnerabilities', 'code_smells', 'coverage', 'duplicated_lines_density', 'sqale_rating', 'reliability_rating', 'security_rating'. | |
| limit | No | Top-N projects to return after ranking. | |
| query | No | Optional substring to pre-filter projects by key or name before ranking. Highly recommended on large SonarQube instances. | |
| candidate_pool | No | How many projects to pull before ranking. Larger pool = more accurate ranking, slower response. Start at 100 and bump up if needed. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| metric | Yes | ||
| direction | Yes | ||
| limit | Yes | ||
| candidates_scanned | Yes | ||
| ranked_count | Yes | ||
| query | Yes | ||
| ranked | Yes |