KEMBAR78
[Fix #4247] Add AllCops/IncludeOnly config parameter by jonas054 · Pull Request #5847 · rubocop/rubocop · GitHub
Skip to content

Conversation

jonas054
Copy link
Collaborator

@jonas054 jonas054 commented May 1, 2018

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.

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.
@jonas054 jonas054 force-pushed the 4247_include_only branch from 608e5a3 to 2f27aa6 Compare May 3, 2018 17:29
@bbatsov
Copy link
Collaborator

bbatsov commented May 5, 2018

Hmm, I'm on the fence about this one, mostly about the naming. I have a feeling many people will not easily get the difference between Include and IncludeOnly. I wonder how we can improve this.

@jonas054
Copy link
Collaborator Author

jonas054 commented May 5, 2018

There was an alternative idea mentioned in #4247, which is a boolean AllCops/DisableImplicitIncludes. And then you'd just list your files under AllCops/Include. Is that better?

@bbatsov
Copy link
Collaborator

bbatsov commented May 6, 2018

Hmmm, that might be better I guess. Now I just have to remember what did we include by default. :D

@bbatsov
Copy link
Collaborator

bbatsov commented May 6, 2018

There's another option of course - make the implicit includes explicit. That solves the problem that we're supposed to solve and doesn't require a new boolean option.

@jonas054
Copy link
Collaborator Author

jonas054 commented May 9, 2018

I think that would mean that users who override AllCops/Include suddenly won't get their ordinary *.rb files inspected -- until they add **/*.rb in their configuration.

@bbatsov
Copy link
Collaborator

bbatsov commented May 9, 2018

Yeah, I'm aware of this, but I'd rather fix a bad default now rather than make a pretty complex config even more complex. At least this is my perspective. I highly doubt that many people are overriding this, and we can always issue some warning if **/*.rb is missing.

@jonas054
Copy link
Collaborator Author

Good! I'll be happy to get rid of the duplication between for example TargetFinder.RUBY_FILENAMES and AllCops/Include.

What about extensionless files with a ruby hashbang? Because the point of this issue here is to get rid of finding files by default. We would have to add a parameter for recognized ruby interpreters.

@bbatsov
Copy link
Collaborator

bbatsov commented May 10, 2018

That's fine by me - the fewer the hardcoded things, the better.

jonas054 added a commit to jonas054/rubocop that referenced this pull request May 13, 2018
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.
bbatsov pushed a commit that referenced this pull request May 13, 2018
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 #5847, which was my first attempt at a fix for #4247.
@jonas054 jonas054 deleted the 4247_include_only branch May 23, 2018 03:31
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.

2 participants