Skip to content
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

[Fix #12695] Handle Include from inherited file in parent directory #12708

Merged
merged 1 commit into from
Feb 25, 2024

Conversation

jonas054
Copy link
Collaborator

When we inherit configuration from a file in a parent or ancestor directory, and that file is called .rubocop.yml, the paths in its Include parameters are interpreted as being relative to the file, or rather its directory. This is specific for file names starting with .rubocop. The problem is that file name matching that we do when searching for target files to inspect doesn't work for patterns that start with ... Solve the problem by matching absolute paths in these corner cases.

…rectory

When we inherit configuration from a file in a parent or ancestor
directory, and that file is called `.rubocop.yml`, the paths in
its Include parameters are interpreted as being relative to the
file, or rather its directory. This is specific for file names
starting with `.rubocop`. The problem is that file name matching
that we do when searching for target files to inspect doesn't work
for patterns that start with `..`. Solve the problem by matching
absolute paths in these corner cases.
@koic koic merged commit 32467d4 into rubocop:master Feb 25, 2024
32 checks passed
@koic
Copy link
Member

koic commented Feb 25, 2024

Thanks!

@jonas054 jonas054 deleted the 12695_fix_include_bug branch February 25, 2024 16:15
def match_path?(pattern, path)
case pattern
when String
matches =
if pattern == path
true
elsif glob?(pattern)
# File name matching doesn't really work with relative patterns the start with "..". We
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "…that start with"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll fix that.

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.

None yet

3 participants