feat(ai-review): have reviewers fix SonarQube findings - #14
Merged
Merged
Conversation
SonarQube reports through its GitHub App as a check run, so the gate, which only read Actions runs, never passed its findings to the reviewers. The gate now waits for the analysis, collects the PR's failed quality gate conditions, open issues and hotspots, and the prompt has reviewers fix them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The AI review of OpenC3/cosmos#3942 converged with "CI passed" while SonarQube's quality gate was failing on two Major issues. The gate only collected GitHub Actions runs (
actions/runs). SonarQube reports through its own GitHub App as a check run, so its findings never reached the reviewers, who have no network access to look them up. And the prompt's "no stylistic changes" rule meant reviewers would likely have left code-smell findings alone even if they had seen them.What changes
sonar_wait_minutes, default 10) and fetches the PR's failed quality gate conditions, open issues and hotspots waiting for review intosonar_findings.md. The project key comes from the check run's link, or from the newsonar_project_keyinput. Any Sonar trouble (no check run, outage, error page, nochecks: read) only leaves the findings out, with a warning. Hotspots are listed but not counted, because marking one safe takes a person in SonarQube.MAX_CI_ROUNDS.NOSONARand no weakened tests; false positives and out-of-scope fixes go tounresolved_concerns; coverage and duplication conditions need their own fix; hotspots are fixed if they are real problems. The "no stylistic changes" rule now allows what SonarQube rejects.SONAR_TOKENsecret. curl gets it through stdin, never the command line.checks: readis added to the gate job and documented for callers.Caller change needed
A called workflow can't get more permission than its caller gives it, so each caller must add
checks: read. For cosmos, that's OpenC3/cosmos#3958. Without it the review still runs but leaves the Sonar findings out, with a warning.Testing
python3 -m unittest discover -s tests: 82 tests pass, 9 of them new. They cover findings reaching the review, the project key override, the token going only through stdin, waiting for and giving up on the analysis, Sonar outages, AI fix rounds, and the loop prompt and summary.new_code_smells_severitycondition and both open issues (storage_controller.rb:495,test_storage.py:325).🤖 Generated with Claude Code