Add --fail-on-unfixable flag for single-pass fix + validation
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
Problem
When using swiftlint --fix, the command always returns exit code 0, even when unfixable violations remain. This forces users to run SwiftLint twice in CI/pre-commit hooks:
swiftlint --fix && swiftlint --strict
This doubles the execution time for files with violations.
Proposed Solution
Add a new flag --fail-on-unfixable (or --strict-fix) that:
- Performs auto-correction as usual
- Returns non-zero exit code if any violations couldn't be auto-fixed
- Optionally outputs the unfixable violations to stderr
Use Case
Pre-commit hooks and CI pipelines that want to:
- Auto-fix what can be fixed
- Block commits/builds when manual intervention is required
- Do this in a single SwiftLint invocation
Current Workaround
Using swiftlint --fix && swiftlint --strict, but this is suboptimal for large codebases and adds unnecessary latency to developer workflows.
Example Usage
# Current (two passes)
swiftlint --fix --config .swiftlint.yml file.swift
swiftlint --strict --config .swiftlint.yml file.swift
# Proposed (single pass)
swiftlint --fix --fail-on-unfixable --config .swiftlint.yml file.swift
Related Issues
- #5387 - Discussion about
--strict --fixbehavior
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SwiftLint command-line handling for --fix and compare it with the behavior discussed in related issue #5387. Verify the proposed single-pass invocation against the current two-pass workaround, including the exit status and any output for remaining violations. Done means auto-fixable violations are corrected and unfixable violations produce a non-zero result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100