Use absolute path to support Cop Exclude param#33
Open
blelump wants to merge 1 commit intom4i:masterfrom
Open
Conversation
When Exclude param is used for a cop, ie:
```
Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
```
Rubocop internally checks these strings using the [`match_pattern?`][1] method
and since the pattern arg is given as `project root + pattern`, it never
works for relative paths. It would, however, work for a path defined as
regexp, ie:
```
Metrics/BlockLength:
Exclude:
- !ruby/regexp /spec\/.*\/.*_spec.rb$/
```
however I think it's convenient to support string paths in order
to allow '**' pattern as well.
[1]: https://github.com/bbatsov/rubocop/blob/v0.47.1/lib/rubocop/path_util.rb#L17
|
@blelump what is the status of this? |
Author
|
@madslundholmdk , what do you mean? |
|
@blelump why isn't this merged yet? |
Author
|
@madslundholmdk , this is just my PR for a particular problem :-) . Whether the PR will be merged or not eventually , depends on the repo owner (which I am not). |
|
@m4i this change worked for me too. Do you need any help to merge this? For now I'm using specific_install to use this fix: |
|
I just switched my config to use the regex from the OP...not sure what downsides might be though 🤷♂ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Exclude param is used for a cop, ie:
Rubocop internally checks these strings using the
match_pattern?methodand since the pattern arg is given as
project root + pattern, it neverworks for relative paths. It would, however, work for a path defined as
regexp, ie:
however I think it's convenient to support string paths in order
to allow '**' pattern as well.