-
-
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
Ability to specify files/directories to look at and ignore everything else #4247
Comments
Welcome over from StackOverflow land. 🙂 Will have a look at the existing code and give this a think over the weekend. Any input from others is appreciated. 😊 |
The best way to do this currently is to build up a list of The alternative is that you build a wrapper script that finds the files to inspect (using the version control history for example) and gives them as command line arguments to |
I would also prefer to specify what to include instead of excluding all the things I don't want. A typical Ruby project has AllCops:
Include:
- bin/**/*
- lib/**/*.rb
- test/**/*.rb would allow one to use Rubocop easily. No temporary Ruby files would raise a false alarm. Would it be possible to add a new config option to |
I thought that the default |
So, what is the solution to this closed issue?! |
I've added all existing files in the project to |
That's not an elegant solution at all :( Couldn't there be a |
Yes, I guess so. Opening again. Either we add a Either way, the |
I, too, think that the
|
This feature makes it possible to add RuboCop inspection slowly in a legacy project. Files and directories can be added for inspection incrementally. It's an alternative or complement to the existing workflow of adding cops one at a time using the --auto-gen-config feature.
Before this change, we were hard-coding file extensions, file names, and ruby interpreters, and then adding configured includes from AllCops/Include. Now we add the parameter AllCops/RubyInterpreters and add **/*.rb to AllCops/Include. By removing the hard-coded lists of things to inspect, this feature makes it possible to introduce RuboCop inspection slowly in a legacy project. Files and directories can be added for inspection incrementally. It's an alternative or complement to the existing workflow of adding cops one at a time using the --auto-gen-config feature. Closes rubocop#5847, which was my first attempt at a fix for rubocop#4247.
Just got bitten by this - took 10 minutes of reading to work out why rubocop went from inspecting 950 files to only 5. We had an explicit Include list (and an Exclude list, if that is relevant). Was only listed as a New Feature, could it be listed as a Change with a warning? Adding |
Same here! BTW - @chuckd full list here: https://github.com/jonas054/rubocop/blob/e64d9419b9e053cd26ec2919ad69caa6d973725d/config/default.yml#L17 In my case, I simply removed the AllCops/Include rule in rubocop.yml |
Aha, thanks @Onumis - I'd missed *.rake. |
I'm not sure why we added this in the first place. Looking at the Rubocop default setup these files have been included for over a year now. This custom include also breaks Rubocop 0.56.0 due to changes in how it handles the merging (it no longer merges include by default for the all cops setting). For more details see: - [Incorrect number of inspected files](rubocop/rubocop#5822) - [Ability to specify files/directories to look at and ignore everything else](rubocop/rubocop#4247)
I got burned by this, too. Just noticed our rubocop tests were only doing 40 or so files instead of 1000+. Just to be clear, was this a change in functionality between one of the releases? If so, which one? I could have sworn that adding entries to the Thanks! |
I think we changed this in 0.56 or 0.57.
True. The problem was that this way there was no way to modify the hardcoded defaults, which was frustrating for some people. Now people have the ultimate flexibility, as nothing's hardcoded anymore. |
Thanks for the clarification. So, quick question, how does one go about adding a specific file, whilst keeping the default files included? |
See leklund@6c7e5ed Probably we should make this more prominent in the docs. |
what happened to we have a huge codebase and want to enable it step by step for small parts of the codebase (mainly new written things or things we touched) config looks
however this gives me a warning: Warning: AllCops does not support IncludeOnly parameter. |
|
Situation:
A big old project written without any specific style. It's impossible to integrate Rubocop to the whole project. But, it's possible to enable it for new code only and incrementally add new directories as we go.
What I want to do:
Add global
.rubocop.yml
to the project and specify directories to look at. Everything else should be ignored. We're going to add more directories to that list as we go, but we need to start with a small step.Right now the only way to do this looks very ugly and unreadable:
I bet everyone will give up on this after a 10 directories added.
My first try was this:
I.e. exclude everything, but include these.
Second try was:
Ok, just include these, and I'm not telling you to include anything else, so why do you even look at
./*
?I'm not sure how syntax should look like, but I hope the problem was clear. Any thoughts appretiated
The text was updated successfully, but these errors were encountered: