-
Notifications
You must be signed in to change notification settings - Fork 2
Deduplicate issues when different rules flag the same issue #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oshorefueled
wants to merge
2
commits into
main
Choose a base branch
from
feat/dedup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import { RawIssue } from './types'; | ||
| import { Severity } from '../evaluators/types'; | ||
|
|
||
| // Map severities to their relative rank for tie-breaking. | ||
| const SEVERITY_RANK: Record<Severity, number> = { | ||
| [Severity.ERROR]: 3, | ||
| [Severity.WARNING]: 2, | ||
| }; | ||
|
|
||
| /** | ||
| * Filter and deduplicate overlapping issues to reduce noise. | ||
| * Groups by exact (file, line, match) and picks the best issue heuristically. | ||
| * | ||
| * Deduplication Heuristic: | ||
| * 1. Prefer rules with a `suggestion` (to make the error actionable). | ||
| * 2. Tie breaker 1: Pick the one with the longest `summary` (to provide maximum context). | ||
| * 3. Tie breaker 2: Prefer higher severity (`ERROR` > `WARNING`). | ||
| * 4. Tie breaker 3: Default to the first one evaluated. | ||
| * | ||
| * Note: Issues with an empty `match` text are explicitly preserved and not deduplicated | ||
| * against each other, as their exact overlap cannot be verified. | ||
| */ | ||
| export function filterDuplicateIssues(issues: RawIssue[]): RawIssue[] { | ||
| const grouped = new Map<string, RawIssue[]>(); | ||
|
|
||
| for (const issue of issues) { | ||
| const matchText = issue.match || ''; | ||
| const key = `${issue.file}:${issue.line}:${matchText}`; | ||
|
|
||
| const group = grouped.get(key) || []; | ||
| group.push(issue); | ||
| grouped.set(key, group); | ||
| } | ||
|
|
||
| const filtered: RawIssue[] = []; | ||
|
|
||
| for (const group of grouped.values()) { | ||
| const first = group[0]; | ||
| if (!first) continue; | ||
|
|
||
| const matchText = first.match || ''; | ||
| if (matchText === '' && group.length > 1) { | ||
| filtered.push(...group); | ||
| continue; | ||
| } | ||
|
|
||
| if (group.length === 1) { | ||
| filtered.push(first); | ||
| continue; | ||
| } | ||
|
|
||
| const best = group.reduce((prev, curr) => { | ||
| // 1. Prefer suggestion | ||
| const prevHas = !!prev.suggestion; | ||
| const currHas = !!curr.suggestion; | ||
| if (currHas !== prevHas) return currHas ? curr : prev; | ||
|
|
||
| // 2. Tie breaker 1: longest summary | ||
| const prevLen = prev.summary?.length || 0; | ||
| const currLen = curr.summary?.length || 0; | ||
| if (currLen !== prevLen) return currLen > prevLen ? curr : prev; | ||
|
|
||
| // 3. Tie breaker 2: higher severity | ||
| const prevRank = SEVERITY_RANK[prev.severity] || 0; | ||
| const currRank = SEVERITY_RANK[curr.severity] || 0; | ||
| if (currRank !== prevRank) return currRank > prevRank ? curr : prev; | ||
|
|
||
| // 4. Tie breaker 3: First evaluated (prev is always earlier in array) | ||
| return prev; | ||
| }); | ||
|
|
||
| filtered.push(best); | ||
| } | ||
|
|
||
| return filtered; | ||
| } |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: TRocket-Labs/vectorlint
Length of output: 1484
🏁 Script executed:
Repository: TRocket-Labs/vectorlint
Length of output: 4702
🏁 Script executed:
Repository: TRocket-Labs/vectorlint
Length of output: 3079
🏁 Script executed:
Repository: TRocket-Labs/vectorlint
Length of output: 1240
🏁 Script executed:
Repository: TRocket-Labs/vectorlint
Length of output: 749
🏁 Script executed:
Repository: TRocket-Labs/vectorlint
Length of output: 1609
🏁 Script executed:
Repository: TRocket-Labs/vectorlint
Length of output: 597
Make
issuesfield required onProcessCriterionResultandErrorTrackingResulttypes.issuesis currently declared optional (issues?: RawIssue[]) onErrorTrackingResult(and inherited byProcessCriterionResult), but bothextractAndReportCriterionandroutePromptResultalways initialize and return the field in every code path—even early returns include it. Makingissuesrequired in the type definitions would eliminate the need for the guards at lines 705-707 and accurately reflect the implementation invariant.🤖 Prompt for AI Agents