feat: add --fail-on-unfixable flag for single-pass fix and validation - #6540
feat: add --fail-on-unfixable flag for single-pass fix and validation#6540omar-y-abdi wants to merge 4 commits into
Conversation
Generated by 🚫 Danger |
|
@SimplyDanny hope it's alright to ping you or any other maintainers - this looks good and very useful! |
|
Sorry for the late response. I'm not quite happy with an additional option and would rather prefer a new The proposed What do others think? |
|
Danger doesn't like merge commits. Please rebase your branch onto |
Fixes prefer_self_in_static_references violations caught by SwiftLint's integration tests.
9631e4b to
a731c87
Compare
|
Feel free to submit review changes if they are needed in this PR, i'll submit commits with all the changes. |
Did you read my first comment? |
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