Repository navigation
feat(cli): order review and scan findings by severity - #2003
Merged
Merged
Conversation
Contributor
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
|
Comment on lines
+33
to
+39
| for index, comment := range comments { | ||
| rank := slices.Index(levels[:], comment.Severity) | ||
| if rank < 0 { | ||
| rank = len(levels) | ||
| } | ||
| buckets[rank] = append(buckets[rank], findings[index]) | ||
| } |
Contributor
There was a problem hiding this comment.
Potential panic if len(comments) != len(findings). The function iterates over comments and indexes into findings[index] without verifying both slices have the same length. While current call sites are safe (same slice passed twice, or 1:1 built results), this implicit contract is fragile — a future caller passing mismatched slices would get an index-out-of-range panic. Consider adding a guard or documenting the precondition.
Suggestion:
Suggested change
| for index, comment := range comments { | |
| rank := slices.Index(levels[:], comment.Severity) | |
| if rank < 0 { | |
| rank = len(levels) | |
| } | |
| buckets[rank] = append(buckets[rank], findings[index]) | |
| } | |
| if len(comments) != len(findings) { | |
| panic(fmt.Sprintf("inCommentSeverityOrder: comments length %d != findings length %d", len(comments), len(findings))) | |
| } | |
| for index, comment := range comments { | |
| rank := slices.Index(levels[:], comment.Severity) | |
| if rank < 0 { | |
| rank = len(levels) | |
| } | |
| buckets[rank] = append(buckets[rank], findings[index]) | |
| } |
lizhengfeng101
force-pushed
the
feat/sort-findings-by-severity
branch
from
November 19, 2026 12:28
d83bc55 to
8a64270
Compare
2 of 3 tasks
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.
Description
Final
ocr reviewandocr scanreports group findings by severity instead of listing them in the order parallel workers finish. In text, JSON, and SARIF, findings with missing or unrecognized severity come first, followed bylow,medium,high, andcritical. Within each group, findings keep their collection order for that run; ties can appear in a different order on another run. SARIF assigns duplicate fingerprint suffixes before sorting, so reordering the report does not change a finding's fingerprint.The GitHub Action uses a different order when deciding which inline comment to post. With
incremental: 'true', it still skips candidates that overlap an existing bot comment. Among the remaining candidates, it considers the most severe first and breaks ties by report order. For example, if a newlowandcriticalfinding cover the same line, both remain in the CLI report, but only thecriticalfinding is posted inline. Existing comments are not replaced.Upgrade note: If your workflow pins the Action to an older revision but leaves
ocr_versionat its default (latest), upgrade the Action before adopting the new CLI, or pin the CLI until you can. The old incremental publisher keeps the first overlapping candidate, which in the new report can be the less severe finding.Type of Change
How Has This Been Tested?
make checkandmake testpassed locally.ocr reviewreported no findings.Checklist
AI disclosure: OpenAI Codex (
gpt-6.2-astra) assisted with implementation, tests, and PR preparation. OpenCodeReview (gpt-6.2-astra) performed the automated pre-commit review.