feat: add --fail-on-unfixable flag for single-pass fix and validation#6540
Open
omar-y-abdi wants to merge 3 commits intorealm:mainfrom
Open
feat: add --fail-on-unfixable flag for single-pass fix and validation#6540omar-y-abdi wants to merge 3 commits intorealm:mainfrom
omar-y-abdi wants to merge 3 commits intorealm:mainfrom
Conversation
alexey1312
approved these changes
Mar 14, 2026
Generated by 🚫 Danger |
Fixes prefer_self_in_static_references violations caught by SwiftLint's integration tests.
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.
Fixes #6450
Problem:
swiftlint --fixalways returns exit code 0, even when unfixable violationsremain. Users in CI/pre-commit hooks must run SwiftLint twice:
swiftlint --fix && swiftlint --strict,doubling execution time.
Solution: Add
--fail-on-unfixableflag that performs autocorrection as usual, thenre-lints to detect remaining violations. If serious violations remain, exits with code 2.
Reuses existing
lintOrAnalyze()path, so--strict/--lenientwork naturally with there-lint pass.
Why: The two-pass approach (fix then lint) reuses existing infrastructure with minimal code
changes. Configuration parsing is cached (O(1) on second pass), and
ignoreCache: trueensures stale cache entries from modified files are not used. This is architecturally the
simplest solution that correctly handles all edge cases.
Test:
swift buildpassesLintOrAnalyzeOptionsTestspasses (0 failures)--fail-on-unfixable→ exit 2 → works--fail-on-unfixable→ exit 0 → works--fail-on-unfixablewithout--fix→ prints warning → worksCloses #6450