How harshan-ks/sonar-scanner-agent works
This repository automates SonarQube issue triage and optionally applies guarded fixes. The main workflow is a SonarQube gate-failure webhook (or a direct CLI run) into a LangGraph scan stage, confidence-based fix routing, read-only safety review, then edits or human-review suggestions. The scanner also supports optional LLM rescue for non-whitelisted code smells; dependency fan-in informs confidence scores. Source excerpts do not show every scanner helper or generated-file loading detail, so those internal links are limited to documented behavior.
Main entry points: fix_agent.py Fix agent · sonar_agent.py Issue scanner · main.py CLI front door · pipeline_graph.py Pipeline graph
Components 15
Entry points
- CLI front door
main.py - Webhook listener
webhook_listener.py - Pipeline graph
pipeline_graph.py
Issue scanning
- Issue scanner
sonar_agent.py - Rule whitelist
fix_rules.yaml - Scored issues
Fix workflow
- Fix agent
fix_agent.py - Fix backups
- Fix report
AI and risk support
- Fan-in analyzer
dependency_graph.py - Claude wrapper
claude_cli.py
Other components
- Operator
- SonarQube
- Claude CLI
- Scanned project
Connections 22
- Operator → CLI front door: runs commands
- Operator → Webhook listener: sends webhook
- CLI front door → Pipeline graph: runs pipeline
- CLI front door → Webhook listener: starts listener
- CLI front door → Issue scanner: runs scan
- CLI front door → Fix agent: runs fix
- Webhook listener → Pipeline graph: dispatches failures
- SonarQube → Webhook listener: posts gate status
- Pipeline graph → Issue scanner: runs scan stage
- Pipeline graph → Fix agent: routes eligible issues
- Issue scanner → SonarQube: fetches issues
- Issue scanner → Rule whitelist: reads whitelist
- Issue scanner → Fan-in analyzer: uses fan-in scoring
- Issue scanner → Scored issues: writes issues
- Fix agent → Scored issues: reads issues
- Fix agent → Scanned project: reviews and edits
- Fix agent → Fix backups: saves originals
- Fix agent → Fix report: writes results
- Issue scanner → Claude wrapper: requests rescue review
- Fix agent → Claude wrapper: requests review and edits
- Fix agent → Claude wrapper: requests suggestions
- Claude wrapper → Claude CLI: invokes CLI