sonar-autofix
v0.3.3
Published
This is a monorepo for the GitHub Sonar Autofix project, which automatically fixes code issues found by SonarQube/SonarCloud using LLMs.
Readme
sonar-autofix (BETA)
This is a monorepo for the GitHub Sonar Autofix project, which automatically fixes code issues found by SonarQube/SonarCloud using LLMs.
Project Structure
sonar-autofix/
├── packages/
│ ├── core/
│ ├── github-action/
│ ├── cli/
│ ├── sonar-client/
│ ├── llm-client/
│ ├── git-client/
│ └── validator/
├── prompts/
├── examples/
├── docs/
├── tests/
└── README.mdGoal
Build a reusable GitHub Action and CLI that automatically:
- Runs SonarQube/SonarCloud analysis
- Fetches open issues
- Uses an OpenAI-compatible LLM (LM Studio by default) to fix issues
- Validates changes (build, lint, tests)
- Re-runs Sonar
- Repeats until no more fixable issues remain (or retry limit reached)
- Commits changes
- Pushes a branch
- Creates a Pull Request
Packages
core
Responsible only for orchestration.
sonar-client
- Run sonar-scanner
- Wait for Quality Gate
- Fetch issues
- Fetch hotspots
- Download source metadata
- Read metrics
llm-client
Provider abstraction for various LLM providers:
- LM Studio
- OpenAI
- Azure OpenAI
- Anthropic
- Ollama
- OpenRouter
git-client
- Create branch
- Checkout
- Commit
- Push
- Restore file
- Reset
- Create Pull Request (GitHub CLI)
validator (currently not used)
Runs configurable commands:
- npm run build
- npm run lint
- npm test
github-action
Thin wrapper that reads action inputs and invokes core.run()
cli
Exposes npx sonar-autofix using the same core package
Usage on Existing Projects
See USAGE.md for detailed instructions on how to use this tool with your existing projects.
Documentation
For more details, see PROJECT.md
