fix: surface warning when config thresholds are invalid - #552
Conversation
ConfigurationManager.validateConfiguration() detects when warningThreshold >= errorThreshold, but the result was never checked anywhere in production code (only unit-tested). Wire it into activate() and the configuration change listener so a misconfigured user actually sees a warning instead of silently getting the wrong complexity color coding. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #552 +/- ##
=======================================
Coverage 97.89% 97.89%
=======================================
Files 10 10
Lines 3710 3710
Branches 455 455
=======================================
Hits 3632 3632
Misses 77 77
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@copilot add appropriate unit tests |
Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Added unit tests in
|
|
@copilot the tests are failing at the moment. Fix them |
…ionChanged pollution in tests Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Fixed. The tests were failing because The fix resets |
…n-20260819-cf589f67dec871c0
There was a problem hiding this comment.
Pull request overview
Surfaces warnings when complexity thresholds are invalid.
Changes:
- Validates configuration during activation and settings changes.
- Adds warning-message integration tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/extension.ts |
Adds validation warning wiring. |
src/test/extension.test.ts |
Tests warning-message behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| teardown(async () => { | ||
| (vscode.window as any).showWarningMessage = originalShowWarningMessage; | ||
| const vsConfig = vscode.workspace.getConfiguration("codeMetrics"); | ||
| await vsConfig.update("warningThreshold", undefined, vscode.ConfigurationTarget.Global); | ||
| await vsConfig.update("errorThreshold", undefined, vscode.ConfigurationTarget.Global); | ||
| }); |
| checkConfigurationValidity(); | ||
| const configValidityWatcher = ConfigurationManager.onConfigurationChanged(() => { | ||
| checkConfigurationValidity(); |
🤖 This is an automated pull request from Repo Assist.
What: Wires
ConfigurationManager.validateConfiguration()intoextension.tsso that misconfigured thresholds (warningThreshold >= errorThreshold) actually surface avscode.window.showWarningMessageto the user, both on activation and whenever settings change.Why:
validateConfiguration()already existed and was covered by unit tests (src/test/configuration.test.ts), but nothing in production code ever called it. A user who misconfigures their thresholds would silently get incorrect complexity color-coding with no indication anything is wrong.Trade-offs: None significant — this is additive and only fires when the configuration is actually invalid. No new dependencies, no behavior change for valid configurations.
Test Status
npm run compile: ✅ cleannpm run lint: ✅ cleannpm run test:unit(c8 + mocha, 225 tests): ✅ all passing, no coverage regressionvscode-test(extension.ts/configuration.ts activation tests): not run — blocked by sandbox network (VS Code test binary download), as is standard in this environmentCloses: none (proactive improvement; Task 4 substituted with Task 5 this run — all outstanding dependency bumps are already covered by open PRs #546/#501/#455, no new engineering work identified).
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
releaseassets.githubusercontent.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run