Repository navigation
Exclude the files under a directory that an exclude pattern matches - #7175
Conversation
69bcc77 to
4394c03
Compare
|
I think this looks good. remarks:
|
|
Thanks. Both points are in 9743e72. The second call now runs only when the path contains the literal text that the pattern ends with, followed by a separator. A file under a directory that the pattern matches always contains that text. On Windows the check is off, because there the match ignores case. On 20,000 paths, best of 15, with four patterns from the WordPress config in phpstan/phpstan#9554 and
A pattern that ends with I added |
9743e72 to
f796e6d
Compare
staabm
left a comment
There was a problem hiding this comment.
lgtm. I think we should wait until CI stablizes a bit before merging.
A literal exclude path that names a directory excludes the files under it. A pattern had to match the whole file path, so themes/*/node_modules/ and themes/*/node_modules excluded nothing under those directories. Each pattern that does not end with * now also gets the form <pattern>/*. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A file under a directory that the pattern matches contains the literal text the pattern ends with, followed by a separator. str_contains() on that text rules out most paths before the second fnmatch() call. The check is off on Windows, which matches case-insensitively. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f796e6d to
8359339
Compare
An exclude path that names a directory excludes the files under it. Since 2.0 that is true only for a literal path. A pattern has to match the whole file path, so
themes/*/node_modules/andthemes/*/node_modulesexclude nothing under those directories. Onlythemes/*/node_modules/*works.This change makes a pattern behave like a literal path. When a pattern matches a directory, it now also excludes the files under that directory.
FileExcluderadds<pattern>/*for each pattern that does not end with*. A pattern that ends with a separator can only name a directory, so it gets only that form.themes/*/node_modulesstill does not excludethemes/foo/node_modules-old/, so this does not bring back the implicit wildcard that phpstan/phpstan#10299 removed.A config from phpstan/phpstan#9554 uses this form:
I rebuilt that layout with a file in
themes/a/node_modules/pkg/. 2.3.x analyses that file, and this PR does not.ignoreErrorsusesFileExcluderforpathandpathstoo, so a pattern there now also matches the files under a directory it names. That is again how a literal directory path already works. Before, such an entry matched only a file with exactly that name.The new
FileExcluderTestcases with an/*-less directory pattern fail without the change. I could not run the Windows cases, because I have no Windows machine.🤖 Generated with Claude Code