-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Determine includes and excludes based on scores #104
Determine includes and excludes based on scores #104
Conversation
$pattern = preg_quote( str_replace( '*', '__wildcard__', $path_or_file ) ); | ||
$pattern = '/' . str_replace( '__wildcard__', '(.+)', $pattern ) . '$'; | ||
foreach ( $matchers as $path_or_file ) { | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have a short comment here describing what is being checked. Maybe something like this:
if ( | |
// Without a wildcard, we can directly check the folder hierarchy. | |
if ( |
|
||
$root_relative_path = str_replace( static::$dir, '', $file->getPathname() ); | ||
if ( false !== mb_ereg( $pattern, $root_relative_path ) ) { | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a comment as well. I'm not 100% sure what the reason is for checking both ways, I assume this is done for being overly conservative. This certainly needs an explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed for partial wildcards like this:
Given an include wildcard of: dir/wp-*
any directory starting with dir/wp-
should always be checked. We're checking if the directory starts with the matcher.
Whereas for normal wildcards the check is the other way around: one/two/three/*.js
means that a directory called one
should be checked to see if the matcher starts with the directory.
Determine includes and excludes based on scores
Include and exclude matches are based on the strength of the match with:
Can probably use improvement but this should cover the base scenarios.