You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--fix doesn't use the lint cache, so it re-parses every file on every run #6964
I've upgraded to the latest released version of SwiftLint and checked the issue still exists
I've searched for existing GitHub issues
Feature Request
swiftlint lint skips unchanged files using the cache, but swiftlint --fix re-parses every file on every run, even when nothing has changed. LintOrAnalyzeCommand.autocorrect passes cache: nil to visitLintableFiles, while the lint path passes the real cache.
This matters most for the common setup of running --fix and then lint in an Xcode build phase. Fixing becomes the slowest part of every build, including builds where nothing changed.
On our project (about 3,600 Swift files, M5 Max), with nothing to fix:
Command
0.63.2
0.65.1
swiftlint lint (warm cache)
0.43s (1.2s CPU)
0.40s (1.3s CPU)
swiftlint --fix
6.3s (54s CPU)
4.4s (58s CPU)
0.65.1 spreads the work across cores better, but --fix still does about a minute of CPU work every time, on files that are already clean.
Inside an Xcode build, --fix competes with the compiler for cores, and it took 10–15 seconds per build for us.
As a workaround, we lint first with --reporter json and run --fix only on the files that lint flags. That brings the whole phase under a second, but every project with a build phase has to rediscover it.
Possible approach
A file whose content and configuration match a cache entry with no violations has nothing to correct, so fix mode could skip it, the same way lint mode does. A file with cached violations, or with no cache entry, would be corrected as today, and its cache entry updated afterwards.
If there's a reason fix mode can't trust the cache, it would help to note it in the docs, so build-phase setups can plan around it.
Activity