feat(review): Apply per-rule severity overrides from config#114
Merged
Conversation
Add `[review.severity_overrides."<rule-id>"]` to `relune.toml` so noisy rules can be downgraded and rules the project cares about can be escalated without changing the rule code itself. The overrides are applied in `relune-app::review` between rule evaluation and summary aggregation, so the post-override severity flows through both the JSON `summary` and the `--deny` threshold check. Unknown rule IDs in TOML now fail-fast as a usage error during the config merge, and duplicate `rule_id` entries on a directly built `ReviewRequest` are rejected as `AppError::Input` to keep behavior consistent with the strict TOML schema. `ReviewSeverityOverride` is added to `relune-core` (alongside `ReviewRuleMetadata`) as the single serialization shape shared by the CLI, future WASM bindings, and the playground.
Drop the manual `CliError::general` wrapper in `run_review` so the existing `From<ConfigError> for CliError` mapping (which returns `CliError::usage`) applies. Unknown rule_ids in `[review.severity_overrides]` now exit with code 2, matching the rest of the config validation surface. Add CLI integration coverage for the override pipeline: a downgrade success path that asserts the JSON summary/finding severity, and a usage-error path that asserts exit code 2 plus the explanatory stderr message.
This comment has been minimized.
This comment has been minimized.
Schema reviewTip ✅ No risk findings — schema changes look safe to merge. |
`ReviewRuleId::parse` is case-insensitive, so two TOML keys like `risk/fk-without-index` and `RISK/FK-WITHOUT-INDEX` previously slipped past `resolve_severity_overrides` and only failed inside the app layer's duplicate guard, surfacing as a generic exit code 1. Detect the collision in the config resolver instead so it raises a `ConfigError::InvalidValue` and maps to the usage exit code 2 like the rest of the override validation surface. Add a config-level unit test plus a CLI integration test that pin the behaviour for case-insensitive duplicates.
Code Metrics Report
Details | | main (436955f) | #114 (e21fb92) | +/- |
|---------------------|----------------|----------------|-------|
+ | Coverage | 94.7% | 94.7% | +0.0% |
| Files | 81 | 81 | 0 |
| Lines | 36858 | 37109 | +251 |
+ | Covered | 34912 | 35161 | +249 |
+ | Test Execution Time | 1m34s | 1m32s | -2s |Code coverage of files in pull request scope (94.0% → 94.4%)
Reported by octocov |
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.
Summary
--denythresholds see the post-override severity.[review.severity_overrides."<rule-id>"]inrelune.tomlwith strict, fail-fast validation: unknown rule IDs and duplicate (including case-insensitive) config entries become usage errors at startup.Changes
ReviewSeverityOverridein relune-core (re-exported from relune-app) and a newReviewRequest::severity_overridesfield plus builder.relune-app::review: build aHashMap<ReviewRuleId, ReviewSeverity>(rejecting duplicates as input errors) and rewrite finding severities before suppression, summary, and deny-threshold evaluation.[review.severity_overrides]as a strictBTreeMap<rule_id, { severity }>table, resolve each key viaReviewRuleId::parseso unknown IDs surface asConfigError::InvalidValue, and forward the merged list throughmerge_review_args.CliError::generalwrapper inrun_reviewso the existingFrom<ConfigError> for CliErrormapping returnsCliError::usage(exit code 2), matching the rest of the config validation surface.resolve_severity_overridesso duplicates are rejected asConfigError::InvalidValue(exit code 2) instead of slipping through to the app-layer duplicate guard (exit code 1).