Add --strict-baseline flag to fail lint when baselined violations are fixed#6614
Open
swizzlr wants to merge 1 commit intorealm:mainfrom
Open
Add --strict-baseline flag to fail lint when baselined violations are fixed#6614swizzlr wants to merge 1 commit intorealm:mainfrom
swizzlr wants to merge 1 commit intorealm:mainfrom
Conversation
Generated by 🚫 Danger |
swizzlr
commented
Apr 20, 2026
Comment on lines
+297
to
+305
| return StyleViolation( | ||
| ruleDescription: description, | ||
| severity: .error, | ||
| location: violation.location, | ||
| reason: """ | ||
| Violation previously recorded in the baseline for '\(violation.ruleIdentifier)' is no longer \ | ||
| detected. Regenerate the baseline to acknowledge this fix | ||
| """ | ||
| ) |
Author
There was a problem hiding this comment.
@SimplyDanny is there a more idomatic way to say "baseline is no longer valid"?
… fixed Adds a new `--strict-baseline` command-line flag and matching `strict_baseline` configuration key. When enabled, SwiftLint compares the stored baseline against the current run and reports an error for each violation recorded in the baseline that is no longer detected, encouraging users to regenerate the baseline after fixes. Fixes realm#6511
ea41fb4 to
070968f
Compare
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
Closes #6511.
Adds a new
--strict-baselinecommand-line flag and matchingstrict_baselineconfiguration key. When enabled, SwiftLint comparesthe stored baseline against violations detected in the current run and
reports an error for each baselined violation that is no longer
detected, encouraging the baseline to be regenerated once violations
have been fixed. This brings SwiftLint's baseline behaviour in line
with other linters.
Behaviour is opt-in and off by default, preserving backwards
compatibility.
Details
--strict-baselineflag onswiftlint lint/swiftlint analyzevia
LintOrAnalyzeArguments.strict_baselineYAML key wired throughConfiguration,Configuration+Parsing, andConfiguration+Merging.LintOrAnalyzeCommandnow retains the loaded baseline and, aftercollection, diffs it against the current run via the existing
Baseline.compareprimitive. Each fixed baselined violation issurfaced as a
fixed_baseline_violationerror at the originallocation.
Test plan
swift test --filter BaselineTestsswift test --filter LintOrAnalyzeOptionstrailing-semicolon warnings, then removed the semicolons and
re-ran with
--baseline baseline.json --strict-baseline. Exitcode
2and per-violation errors as expected. Without--strict-baseline, exit code0.swift buildclean.