-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
How to make RuboCop inspect a file in a folder that starts with dot #1401
Comments
Also asked the question here: http://stackoverflow.com/q/26508803/17469 |
I think that the patterns |
Is there a reason for RuboCop to ignore files in folders that start with dot, like |
You could argue that it's more of an accident (depending, as it does, on what Directories given explicitly either on the command line or in configuration files should be searched. Currently, RuboCop only searches the directories given on the command line. Hidden files and directories should be skipped by default. So I think this needs fixing, and we should also add something in the README about hidden files. |
From an email I wrote about this issue: https://lists.wikimedia.org/pipermail/qa/2014-October/002030.html Rubocop traverses the tree hierarchy using:
Which is the equivalent of:
0 is the flag parameter which can be made File::FNM_DOTMATCH to match dotfiles (including '.' and '..'. So the Dir[] needs to be rewritten to something like:
And add additional logic to skip '.' and '..'. Related code is target_files_in_dir method: https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/target_finder.rb#L58 The actual filtering via Include/Exclude, happens AFTER the tree traversal (by invoking file_to_include?(file). So whatever you put in the config file, it is never going to find dotfiles. |
@hashar You're quite right. I've been working on a solution, but got side-tracked for a while. Now I think I'll have something ready pretty soon, and it will follow the solution you outlined. Pretty much. |
[Fix #1401] Enable including hidden directories in config
Thanks! :) |
Bump RuboCop to 0.27.1 so it can recognize '.docs', see upstream bug for details: rubocop/rubocop#1401 Fix minor whitespaces problem that `rubocop --auto-gen-config` did not put to .rubocop_todo.yml file. Bug: 63307 Change-Id: I0a640135ca8e63a8efd6e8dc0e982a05097c20aa
Fixes rubocop#5181. Fixes rubocop#4832. This PR changes the path pattern (`*`) to match the hidden file. This PR resolves the following problem. ```console AllCops: Exclude: - 'vendor/bundle/**/*' ``` The above .rubocop.yml setting is expected to cover hidden files as well. However, there is a problem that offenses occur with hidden files. ```console vendor/bundle/ruby/2.4.0/gems/backports-3.6.8/.irbrc:1:1: C: Style/SpecialGlobalVars: Prefer $LOAD_PATH over $:. $:.unshift "./lib" ^^ (snip) ``` This PR solves this problem by including hidden files in the path match target. And This PR only changes behavior to hidden files. As resolved in rubocop#1401, rubocop#1656, hidden directories keep their previous behavior. So hidden files in the hidden directory don't match. Probably it will be an intuitive path match to users.
Fixes #5181. Fixes #4832. This PR changes the path pattern (`*`) to match the hidden file. This PR resolves the following problem. ```console AllCops: Exclude: - 'vendor/bundle/**/*' ``` The above .rubocop.yml setting is expected to cover hidden files as well. However, there is a problem that offenses occur with hidden files. ```console vendor/bundle/ruby/2.4.0/gems/backports-3.6.8/.irbrc:1:1: C: Style/SpecialGlobalVars: Prefer $LOAD_PATH over $:. $:.unshift "./lib" ^^ (snip) ``` This PR solves this problem by including hidden files in the path match target. And This PR only changes behavior to hidden files. As resolved in #1401, #1656, hidden directories keep their previous behavior. So hidden files in the hidden directory don't match. Probably it will be an intuitive path match to users.
I want to run RuboCop for VisualEditor repository. At the moment, the only Ruby file I could find in the repository is .docs/CustomTags.rb.
If I run only
rubocop
, it does not find any files:I guess it ignores files in folders that start with dot (
.docs
).RuboCop documentation on including files says:
If I provide path to the file from the command line, RuboCop finds the file:
Our continuous integration just runs
rubocop
for the repository, so I can not provide path to the file from the command line. I have to useAllCops/Include
, but I can not figure out how to do it.If I create a
.rubocop.yml
in the root of the repository:and run Rubocop, it does not find the file:
I have tried several variations of the
.rubocop.yml
file, including:and
But none of them are finding the file.
The text was updated successfully, but these errors were encountered: