Skip to content

feat: support severity-based diagnostic filtering (#776) - #1930

Open
CG-5228 wants to merge 4 commits into
rokucommunity:v1from
CG-5228:oss-agent/issue-776
Open

CG-5228 wants to merge 4 commits into
rokucommunity:v1from
CG-5228:oss-agent/issue-776

Conversation

@CG-5228

@CG-5228 CG-5228 commented Oct 16, 2026 •

Copy link
Copy Markdown

Fixes #776

Summary

Adds support for filtering diagnostics by a minimum severity threshold (minSeverity) in diagnosticFilters:

  • Types & Schema (src/BsConfig.ts, bsconfig.schema.json): Adds minSeverity?: BsDiagnosticSeverity ('error' | 'warn' | 'info' | 'hint' | DiagnosticSeverity) to diagnosticFilters filter objects.
  • Filtering Logic (src/DiagnosticFilterer.ts):
    • Supports minSeverity in global ({ minSeverity: 'warn' }), files-scoped ({ files: 'components/**/*', minSeverity: 'warn' }), dest-scoped, and v0-compatibility filter objects.
    • Filters out diagnostics with a severity lower than minSeverity (e.g. minSeverity: 'warn' filters out 'info' and 'hint' diagnostics while keeping 'warn' and 'error').
    • Supports combining codes and minSeverity on the same filter object (logical AND), as well as negative globs (!pattern) to un-ignore diagnostics meeting minSeverity.
    • Ensures isFileCompletelyFiltered() returns false when minSeverity is specified so file validation is not skipped.
  • Severity Adjustment Ordering (src/DiagnosticManager.ts): Runs diagnosticAdjuster.adjust() before filterDiagnostics() so diagnosticSeverityOverrides are respected when filtering by minSeverity.
  • Docs & Tests (docs/bsconfig.md, src/DiagnosticFilterer.spec.ts): Documents minSeverity in diagnosticFilters and adds unit tests covering threshold filtering.

@markwpearce

Copy link
Copy Markdown
Collaborator

Change this to work on the v1 branch

@CG-5228
CG-5228 force-pushed the oss-agent/issue-776 branch 2 times, most recently from 434bd63 to 78246b6 Compare October 18, 2026 03:06
@CG-5228
CG-5228 changed the base branch from master to v1 October 18, 2026 03:06
@CG-5228
CG-5228 force-pushed the oss-agent/issue-776 branch from 78246b6 to de8e9e3 Compare October 20, 2026 00:24
@CG-5228

CG-5228 commented Oct 23, 2026

Copy link
Copy Markdown
Author

@markwpearce Done — this branch has been rebased onto v1 (de8e9e3) and the PR target branch is set to v1.

@markwpearce markwpearce left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're truly working with a Threshold, then I would assume we can just specify one limit (eg. just severity)?

I think that logically, if I were to add a severity limit, I'd want to say the limit, not the ones not included in the limit.

So, for example:

{
   "files": "components/**/*",
   "severity": "warn"
}

would filter OUT any "hint" or "Info" diagnostics from components

I think the way the code is written now, that filter would allow hints, info and errors, BUT not warnings?

To be more clear about what the change means, perhaps you could change it to "minSeverity" or something?

eg.

{
   "files": "components/**/*",
   "minSeverity": "warn"
}

Comment thread bsconfig.schema.json Outdated
@CG-5228

CG-5228 commented Oct 24, 2026

Copy link
Copy Markdown
Author

Thanks for the feedback @markwpearce! That makes much more sense as a threshold.

I have updated the PR in 97456ef:

  1. Removed severities and severity and replaced them with a single minSeverity threshold property ("error" | "warn" | "info" | "hint") across bsconfig.schema.json, src/BsConfig.ts, src/DiagnosticFilterer.ts, and docs/bsconfig.md.
  2. Updated DiagnosticFilterer so minSeverity filters out diagnostics below the specified threshold (for example, { "files": "components/**/*", "minSeverity": "warn" } filters out "info" and "hint" diagnostics from components/**/* while keeping "warn" and "error").
  3. Updated the unit tests in src/DiagnosticFilterer.spec.ts to cover the minSeverity threshold behavior.

@CG-5228
CG-5228 requested a review from markwpearce October 24, 2026 12:03

@markwpearce markwpearce left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few changes and a suggested test

Comment thread src/DiagnosticFilterer.ts
Comment thread src/DiagnosticFilterer.ts Outdated
Comment thread src/DiagnosticManager.ts
@CG-5228

CG-5228 commented Oct 25, 2026

Copy link
Copy Markdown
Author

Thanks for the review! I have updated the PR in 3fca683 to address all three comments:

  1. Default missing diagnostic severity to Error (src/DiagnosticFilterer.ts): matchesSeverity now defaults diagnostic.severity to DiagnosticSeverity.Error (this.toDiagnosticSeverity(diagnostic.severity) ?? DiagnosticSeverity.Error), with a test in src/DiagnosticFilterer.spec.ts covering diagnostics without severity.
  2. Validate minSeverity during normalization (src/DiagnosticFilterer.ts): getDiagnosticFilters, getDiagnosticFiltersV0, and getNormalizedFilter now check this.toDiagnosticSeverity(filter.minSeverity) !== undefined before setting minSeverity on the normalized filter, so invalid values like "minSeverity": "foo" are ignored rather than preventing a filter from matching.
  3. Test diagnosticSeverityOverrides ordering with minSeverity (src/DiagnosticManager.spec.ts): Added a test verifying that a warning code overridden to 'hint' is hidden by { minSeverity: 'warn' } while an info code overridden to 'warn' is kept.

@CG-5228
CG-5228 requested a review from markwpearce October 25, 2026 21:08
@CG-5228
CG-5228 requested a review from markwpearce October 25, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for diagnosticFilters to ignore by severity instead of specific code

2 participants