Skip to main content
Like AOF? Give us a star!
If you find AOF useful, please star us on GitHub. It helps us reach more developers and grow the community.

SonarQube Tools

AOF integrates with SonarQube for code quality analysis, security vulnerability detection, and technical debt management.

Available Tools

ToolDescription
sonar_project_statusGet quality gate status
sonar_issues_searchSearch for bugs, vulnerabilities, and code smells
sonar_hotspots_searchFind security hotspots
sonar_measures_componentGet metrics (coverage, bugs, complexity)
sonar_issue_transitionChange issue status
sonar_project_analysesGet analysis history

Configuration

Set the SonarQube server and token:

export SONAR_URL="https://sonarqube.example.com"
export SONAR_TOKEN="your-sonar-token"

Tool Reference

sonar_project_status

Get project quality gate status.

Parameters:

ParameterTypeRequiredDescription
endpointstringYesSonarQube server URL
project_keystringYesProject key in SonarQube
branchstringNoBranch name (default: main)
tokenstringYesSonarQube token

Response:

{
"success": true,
"project_key": "my-project",
"status": "ERROR",
"conditions": [
{
"metric": "new_coverage",
"operator": "LT",
"value": "65.2",
"threshold": "80",
"status": "ERROR"
},
{
"metric": "new_security_rating",
"operator": "GT",
"value": "1",
"threshold": "1",
"status": "OK"
}
]
}

Search for issues in a project.

Parameters:

ParameterTypeRequiredDescription
endpointstringYesSonarQube server URL
project_keystringYesProject key
typesstringNoIssue types: BUG, VULNERABILITY, CODE_SMELL
severitiesstringNoSeverities: BLOCKER, CRITICAL, MAJOR, MINOR, INFO
statusesstringNoStatuses: OPEN, CONFIRMED, RESOLVED, CLOSED
branchstringNoBranch name
pageintegerNoPage number (default: 1)
page_sizeintegerNoResults per page (default: 100)
tokenstringYesSonarQube token

Response:

{
"success": true,
"total": 42,
"issues": [
{
"key": "AYxyz123",
"type": "VULNERABILITY",
"severity": "CRITICAL",
"message": "Remove this hard-coded password",
"component": "src/main/java/Auth.java",
"line": 45,
"rule": "java:S2068",
"status": "OPEN",
"effort": "30min",
"tags": ["cwe", "owasp-a3"]
}
]
}

Search for security hotspots.

Parameters:

ParameterTypeRequiredDescription
endpointstringYesSonarQube server URL
project_keystringYesProject key
statusstringNoHotspot status: TO_REVIEW, REVIEWED
resolutionstringNoResolution: FIXED, SAFE, ACKNOWLEDGED
branchstringNoBranch name
tokenstringYesSonarQube token

Response:

{
"success": true,
"hotspots": [
{
"key": "AYabc456",
"message": "Make sure that using this pseudorandom number generator is safe here",
"component": "src/main/java/Security.java",
"line": 23,
"status": "TO_REVIEW",
"vulnerability_probability": "MEDIUM",
"security_category": "weak-cryptography"
}
]
}

sonar_measures_component

Get metrics for a component.

Parameters:

ParameterTypeRequiredDescription
endpointstringYesSonarQube server URL
componentstringYesComponent key (project or file)
metricsstringYesComma-separated metrics
branchstringNoBranch name
tokenstringYesSonarQube token

Common Metrics:

  • coverage - Line coverage %
  • bugs - Number of bugs
  • vulnerabilities - Security vulnerabilities
  • code_smells - Maintainability issues
  • duplicated_lines_density - Duplication %
  • ncloc - Lines of code

Response:

{
"success": true,
"component": "my-project",
"measures": {
"coverage": "78.5",
"bugs": "12",
"vulnerabilities": "3",
"code_smells": "145",
"duplicated_lines_density": "4.2",
"ncloc": "25000"
}
}

sonar_issue_transition

Change issue status.

Parameters:

ParameterTypeRequiredDescription
endpointstringYesSonarQube server URL
issue_keystringYesIssue key
transitionstringYesTransition: confirm, resolve, reopen, wontfix, falsepositive
commentstringNoComment for the transition
tokenstringYesSonarQube token

sonar_project_analyses

Get project analysis history.

Parameters:

ParameterTypeRequiredDescription
endpointstringYesSonarQube server URL
project_keystringYesProject key
branchstringNoBranch name
fromstringNoStart date (YYYY-MM-DD)
tostringNoEnd date (YYYY-MM-DD)
tokenstringYesSonarQube token

Quality Gate Metrics

MetricDescriptionTypical Threshold
coverageLine coverage %>= 80%
new_coverageCoverage on new code>= 80%
bugsTotal bugs0
vulnerabilitiesSecurity vulnerabilities0
security_ratingSecurity rating (A-E)A
reliability_ratingReliability ratingA
duplicated_lines_densityCode duplication %under 3%

Example Agent

apiVersion: aof.sh/v1alpha1
kind: Agent
metadata:
name: code-quality-auditor
spec:
model: google:gemini-2.5-flash
tools:
- sonar_project_status
- sonar_issues_search
- sonar_hotspots_search
- sonar_measures_component

environment:
SONAR_URL: "${SONAR_URL}"
SONAR_TOKEN: "${SONAR_TOKEN}"

system_prompt: |
You are a code quality auditor.

## Responsibilities
- Check quality gate status for projects
- Identify critical bugs and vulnerabilities
- Review security hotspots
- Track code metrics and trends

## Prioritization
1. Security vulnerabilities (CRITICAL, BLOCKER)
2. Bugs affecting reliability
3. Security hotspots needing review
4. Code smells for maintainability