Skip to content

Commit ade4e4c

Browse files
dmartinochoaclaude
andcommitted
feat: pipelineCheck.severityThreshold filters editor diagnostics
A new enum setting (low | medium | high | critical, default "low") that mirrors the CLI's --severity-threshold. Drives a client-side handleDiagnostics middleware that drops diagnostics below the configured threshold before they reach VS Code's Problems panel. Reads Diagnostic.data["severity"] which the v1.0.6 server emits, so CRITICAL and HIGH are distinguished even though the LSP severity enum collapses both to Error. Diagnostics without the data.severity metadata (older server, or a non-pipeline-check publish) pass through unconditionally so the filter never hides legitimate signal when the metadata is absent. The config is re-read on each publish, so a settings change takes effect on the next scan with no restart. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 39b52bc commit ade4e4c

4 files changed

Lines changed: 77 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ versions follow [SemVer](https://semver.org/).
99
PRs landing on `main` between releases append entries here. The release
1010
commit collapses this section into `## [X.Y.Z] — <date>`.
1111

12+
### Added
13+
14+
- **`pipelineCheck.severityThreshold` setting.** A new enum knob
15+
(`low` / `medium` / `high` / `critical`, default `low`) that mirrors
16+
the CLI's `--severity-threshold`. Drives a client-side
17+
`handleDiagnostics` middleware that filters out diagnostics whose
18+
upstream pipeline-check severity falls below the threshold before
19+
they reach the gutter or Problems panel, so the editor surface can
20+
be tuned independently of the CLI's report. The filter reads
21+
`Diagnostic.data["severity"]` (set by the v1.0.6 server) so it can
22+
distinguish `CRITICAL` from `HIGH` (both map to LSP `Error`).
23+
Diagnostics without the `data.severity` metadata pass through
24+
unconditionally, so an older server (or a non-pipeline-check
25+
publish) is never hidden.
26+
1227
### Changed
1328

1429
- **Marketplace polish pass.** The `package.json` `description` is

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pip install "pipeline-check[lsp]"
5858
|---|---|---|
5959
| `pipelineCheck.serverCommand` | `python` | Command used to launch the language server. Override if `pipeline_check` is installed under a different interpreter. |
6060
| `pipelineCheck.serverArgs` | `["-m", "pipeline_check.lsp"]` | Arguments passed to the server command. |
61+
| `pipelineCheck.severityThreshold` | `low` | Lowest severity that produces a diagnostic. One of `low`, `medium`, `high`, `critical`. Mirrors the CLI's `--severity-threshold`. |
6162
| `pipelineCheck.trace.server` | `off` | Traces LSP traffic. Set to `verbose` when debugging. |
6263

6364
## Development

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@
7878
],
7979
"markdownDescription": "Arguments passed to the server command. Default invokes the module via `python -m pipeline_check.lsp`."
8080
},
81+
"pipelineCheck.severityThreshold": {
82+
"type": "string",
83+
"enum": [
84+
"low",
85+
"medium",
86+
"high",
87+
"critical"
88+
],
89+
"default": "low",
90+
"markdownDescription": "Lowest severity that produces a diagnostic. Findings below this level are dropped on the client side so the gutter / Problems panel only carries the cuts you care about. Mirrors the CLI's `--severity-threshold`. Default `low` matches CLI behavior; set to `high` or `critical` for a quieter editor."
91+
},
8192
"pipelineCheck.trace.server": {
8293
"type": "string",
8394
"enum": [

src/extension.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@ const LANGUAGE_ID = "pipelineCheck";
2323
const LANGUAGE_NAME = "Pipeline-Check";
2424
const OUTPUT_CHANNEL = "Pipeline-Check";
2525

26+
// Upstream severity ranks. Higher = more severe. The server stuffs the
27+
// pipeline-check severity name into Diagnostic.data["severity"] (e.g.
28+
// "CRITICAL"). The LSP DiagnosticSeverity enum collapses CRITICAL + HIGH
29+
// into a single Error value, so we can't filter precisely on
30+
// vscode.Diagnostic.severity alone.
31+
const SEVERITY_RANK: Record<string, number> = {
32+
INFO: 0,
33+
LOW: 1,
34+
MEDIUM: 2,
35+
HIGH: 3,
36+
CRITICAL: 4,
37+
};
38+
39+
// Threshold knob values. Map each to the rank a diagnostic must
40+
// reach to survive the filter.
41+
const THRESHOLD_RANK: Record<string, number> = {
42+
low: SEVERITY_RANK.LOW,
43+
medium: SEVERITY_RANK.MEDIUM,
44+
high: SEVERITY_RANK.HIGH,
45+
critical: SEVERITY_RANK.CRITICAL,
46+
};
47+
2648
let client: LanguageClient | undefined;
2749

2850
function buildClient(): LanguageClient {
@@ -51,6 +73,34 @@ function buildClient(): LanguageClient {
5173
configurationSection: "pipelineCheck",
5274
},
5375
outputChannelName: OUTPUT_CHANNEL,
76+
middleware: {
77+
// Drop diagnostics below the user-configured severity threshold
78+
// before they reach VS Code's Problems panel. The config is
79+
// re-read on each publish so a settings change takes effect on
80+
// the next scan without needing a server restart. Diagnostics
81+
// whose `data.severity` is missing (older server, or a
82+
// not-from-pipeline-check publish that somehow flowed through)
83+
// pass through unconditionally so the filter never hides
84+
// legitimate signal when the metadata is absent.
85+
handleDiagnostics: (uri, diagnostics, next) => {
86+
const threshold = vscode.workspace
87+
.getConfiguration("pipelineCheck")
88+
.get<string>("severityThreshold", "low");
89+
const minRank = THRESHOLD_RANK[threshold] ?? SEVERITY_RANK.LOW;
90+
const filtered = diagnostics.filter((diag) => {
91+
const data = (diag as vscode.Diagnostic & {
92+
data?: { severity?: string };
93+
}).data;
94+
const name = data?.severity;
95+
if (!name) {
96+
return true;
97+
}
98+
const rank = SEVERITY_RANK[name];
99+
return rank === undefined || rank >= minRank;
100+
});
101+
next(uri, filtered);
102+
},
103+
},
54104
};
55105

56106
return new LanguageClient(

0 commit comments

Comments
 (0)