Repository navigation
Honor excluded paths for projects under /private-symlinked directories - #6783
Conversation
|
@SimplyDanny please take a look at your earliest convenience. This is a bit of a blocker for us, because we use homebrew to install |
Generated by 🚫 Danger |
|
This apparently causes a slowdown in one of the OSS repositories intended to focus exactly on exclude performance:
If we found a way that would roughly align with the numbers from |
|
@SimplyDanny I've pushed a different approach for this. Instead of standardizing every path (which stats the filesystem and regressed performance), it just matches the candidate with and without the Let's wait and see if Danger is happier. |
Exclusion matchers and prefixes are derived from standardized URLs (via `String.url()`), which on macOS strips a leading `/private` from paths under firmlinks such as `/tmp` and `/var`. The directory enumerator, however, yields file paths that keep the `/private` prefix, so the `FilenameMatcher`/prefix comparison never matched and excluded files (e.g. generated code) were linted in CI workspaces and `mktemp` directories. Compare each candidate against the path both with and without the `/private` prefix using string operations only, so both sides agree without the per-file `stat` that standardizing every candidate would incur.
|
Thank you for merging the changes @SimplyDanny. Would you have a target date for patch release? |
There you go. Homebrew will be ready in a bit as well. |
|
Brew finally updated, and I was able to successfully test end to end. |
Summary
Fixes #6782.
excludedpaths are silently ignored and the files get linted anyway when the linted project's real path is located under a/private-symlinked directory. On macOS that includes anything under/tmp,/var, and/var/folders(firmlinks to/private/tmp,/private/var, …), so it commonly affects CI workspaces andmktempdirectories. This is a regression introduced in 0.64.0.Root cause
Exclusion matchers/prefixes are built from
excludedPaths, whose URLs are produced byString.url(), which applies.standardizedFileURL. On macOS, standardization strips a leading/private(so/private/var/x→/var/x).The file paths to be linted, however, come from
FileManager's directory enumerator, which yields paths that keep the/privateprefix (/private/var/x/...).So
Excluder.excludes(path:)compares/private/...file paths against/...patterns, and theFilenameMatcher/ prefix check never matches. Under/Usersthere is no/privateto strip, which is why the bug looks machine-dependent.Fix
In
Excluder.excludes(path:), compare each candidate against the path both with and without a leading/privateprefix, using string operations only. This bridges the discrepancy without touching the filesystem, and unlike standardizing every candidate it leaves matching behavior for non-/privatepaths exactly as it was.Performance
An earlier iteration of this fix standardized every candidate via
standardizedFileURL, whichstats each path and regressed linting performance noticeably. The current string-only approach avoids that. Measured withtools/oss-check's command (lint --no-cache --enable-all-rules, 5-run average) on the performance corpus:mainmainstandardizedFileURLapproachSame violation count in all cases.
Test
Added
ConfigurationTests.testExcludedPathsUnderSymlinkedDirectory, which creates a small project under the system temporary directory (resolves under/private/var/folders/…on macOS) and asserts the excluded file is not linted. Verified it fails without the fix (the excluded file leaks into the lintable set) and passes with it. The fullFileSystemAccessTestssuite passes.