Skip to content

Fix baseline matching for violations under /private paths - #8

Merged
olitreadwell merged 2 commits into
mainfrom
fix-baseline-private-paths
Nov 3, 2026
Merged

olitreadwell merged 2 commits into
mainfrom
fix-baseline-private-paths

Conversation

@olitreadwell

@olitreadwell olitreadwell commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

What changed

relativeDisplayPath now normalizes the /private prefix on the working directory path and on the file path before subtracting one from the other.

When a project lives under a firmlink (mktemp -d, /tmp, a CI workspace under /private/var/folders) and the config has a non-empty excluded: list, the directory enumerator reports /private-prefixed paths while paths read back from a written baseline are standardized without the prefix.

The two sides disagree, so the baseline key lookup misses and every baselined violation resurfaces.

This bridges the same /private gap the exclusion matcher already handles in Excluder.

Why

Fixes realm#6909.

Reproduced on main at d5156105b.

With an excluded: entry under /private, the one-file repro exits 2 before this change and 0 after.

The same config under /Users, and the no-excluded: case, already worked.

How to verify

git fetch https://github.com/olitreadwell/SwiftLint.git fix-baseline-private-paths
git checkout FETCH_HEAD
swift test

Manual repro (matches the issue):

D=$(mktemp -d); cd "$D"; mkdir Sources
printf 'let value = Optional(1)!\n' > Sources/Foo.swift
cat > .swiftlint.yml <<'YML'
included:
  - Sources
excluded:
  - Ignored
opt_in_rules:
  - force_unwrapping
YML
swiftlint lint --write-baseline .swiftlint.baseline --quiet
swiftlint lint --quiet --strict --baseline .swiftlint.baseline

Expected: no violations, exit 0.

SwiftLint's substantive CI runs on Azure Pipelines and Buildkite, which are not connected to this fork.

On the fork, the GitHub Actions Lint, Build, and Test workflows all pass. The Documentation job fails only at its sourcekitten doc --spm infrastructure step (SPM build manifest does not exist at .../.build/debug.yaml); this is unrelated to this change — the docs job invokes a plain swift build manifest that the Bazel-based runner doesn't populate, and the added code exposes no new public API.

Verified locally here: swift build succeeds, the repro and its controls exit 0, and the changed files pass swiftlint lint.

The added unit test (BaselineTests.filteredAcrossPrivatePrefix) is exercised by swift test.


PROMOTION NOTE (remove this section before/when opening against upstream):

gh pr create --repo realm/SwiftLint --base main --head olitreadwell:fix-baseline-private-paths --title "Fix baseline matching for violations under /private paths"

When a project lives under a firmlink (e.g. a mktemp -d directory or a CI
workspace under /private/var/folders) and the config has a non-empty
excluded: list, FileManager's enumerator yields /private-prefixed paths
while paths read back from a baseline are standardized without the prefix.
relativeDisplayPath now normalizes the prefix on both sides before the
replacement so the write-time and read-time keys agree.

Fixes realm#6909
@olitreadwell

Copy link
Copy Markdown
Owner Author

Re-triggering fork CI (Actions were enabled after this PR was created).

@olitreadwell olitreadwell reopened this Sep 25, 2026
olitreadwell added a commit that referenced this pull request Sep 25, 2026
- Refresh header: upstream still main @ d515610
- Gap ledger: 2026-09-25 issue realm#6909 baseline matching under /private paths, fork PR #8
- Move misplaced 2026-09-24 typo PR #7 entry from Mined gaps to Gap ledger
@olitreadwell
olitreadwell merged commit 4f0a7da into main Nov 3, 2026
@olitreadwell
olitreadwell deleted the fix-baseline-private-paths branch November 3, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Baseline matching fails for every violation under /private when excluded: is non-empty (regression sibling of #6782)

1 participant