Repository navigation
Description
New Issue Checklist
- Updated SwiftLint to the latest version (0.64.0)
- I searched for existing GitHub issues
Describe the bug
excluded paths are silently ignored, and the files get linted anyway, when the project's real path is located under /private (which on macOS includes anything under /tmp, /var, and /var/folders, since those are symlinks to /private/tmp, /private/var, …).
The same project, same config, and same SwiftLint binary work correctly when the project lives under a non-/private path such as /Users/....
This is a regression in 0.64.0. 0.63.3 excludes the files correctly in the exact same location.
This bites in practice because:
- Many CI systems run jobs out of a workspace under
/private/var/.... - Anything created with
mktemp -d(tests, scripts, scratch repos) lands under/private/var/folders/....
In both cases, files that should be excluded (e.g. generated code) start failing the lint, with no config change.
Complete output when running SwiftLint
Self-contained reproduction (paste into a terminal on macOS):
# mktemp -d returns a path under /var/folders -> /private/var/folders
D=$(mktemp -d)
mkdir -p "$D/Sources/Feature/Sources"
printf 'let value = Optional(1)!\n' > "$D/Sources/Feature/Sources/Generated.swift"
cat > "$D/.swiftlint.yml" <<'EOF'
included:
- Sources
excluded:
- Sources/**/Generated.swift
opt_in_rules:
- force_unwrapping
EOF
cd "$D" && swiftlint lint --quietActual (0.64.0): the excluded file is linted
.../Sources/Feature/Sources/Generated.swift:1:24: warning: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
Expected (and actual on 0.63.3): no output.Generated.swift is excluded.
Isolating the trigger
Same project (Sources/Feature/Sources/Generated.swift, same .swiftlint.yml), SwiftLint 0.64.0, only the location differs:
| Project real path | excluded honored? |
|---|---|
/Users/<me>/sl-repro |
✅ yes (no violations) |
/private/tmp/sl-repro (also via the /tmp symlink) |
❌ no (file linted) |
/private/var/folders/.../sl-repro (mktemp -d) |
❌ no (file linted) |
0.63.3 honors excluded in all of these locations. It is not about how you cd into the directory (canonical path vs. via the /tmp symlink behaves the same), it depends on whether the project's real path is under /private.
I tried several config variants under 0.64.0, none restored the exclusion in a /private location:
Sources/**/Generated.swift(glob)**/Generated.swift(leading globstar)Sources/Feature/Sources/Generated.swift(explicit, no glob)
Environment
- SwiftLint version: 0.64.0 (regression from 0.63.3, which works)
- Installation: Homebrew (also reproduced with the
portable_swiftlint.ziprelease binaries for both versions) - Xcode / OS: macOS
- Paths involved are all under
/privatevia the standard macOS/tmp→/private/tmpand/var→/private/varsymlinks
Likely cause
Looks like a path-normalization mismatch introduced in 0.64.0: the lint-target file paths and the resolved excluded patterns end up standardized differently with respect to the leading /private. macOS NSString.standardizingPath strips a leading /private (so /private/var/x → /var/x), while symlink resolution goes the other way (/var/x → /private/var/x). If one side is standardized and the other is symlink-resolved, the exclusion comparison never matches for any path under /private, which is exactly the observed behavior. Under /Users neither transform changes the path, so exclusion still matches.
Activity