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

Cannot lint Capfile with rubocop #4242

Closed
doits opened this issue Apr 4, 2017 · 4 comments
Closed

Cannot lint Capfile with rubocop #4242

doits opened this issue Apr 4, 2017 · 4 comments

Comments

@doits
Copy link

doits commented Apr 4, 2017

Rubocop seems to ignore my "Capfile":

→   rubocop --debug Capfile
For /Users/markus/svn/time-tracker: configuration from /Users/markus/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rubocop-0.48.1/config/default.yml
Inheriting configuration from /Users/markus/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rubocop-0.48.1/config/enabled.yml
Inheriting configuration from /Users/markus/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rubocop-0.48.1/config/disabled.yml
Inspecting 0 files


0 files inspected, no offenses detected
Finished in 0.027621999965049326 seconds

It says "0 files inspeced", so it didn't even take a look.

Afaik it is included by default anyway, so shouldn't I be allowed to lint it?

@andreaswachowski
Copy link
Contributor

I suspect this is related to #3997, specifically to c2a9848. Looks like Capfile should be included in RUBY_FILENAMES.

@doits
Copy link
Author

doits commented Apr 4, 2017

I can confirm that placing #!/usr/bin/env ruby as the first line of my Capfile enables rubocop to lint it.

But I'd never expect rubocop to ignore a file I throw at it explicitly. Only exception might be if I have excluded it by my own in my config, and this is what --force-exclusion switch is for as I understand (so disabled by default, but I can enable it if I need it).

If I pass a directory (or run it without arguments), I think a user expects it to only grab ruby files (typically identified by extension, I'd think everything else is over engineering). Additionally it should respect the include and exclude configuration then.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 5, 2017

But I'd never expect rubocop to ignore a file I throw at it explicitly. Only exception might be if I have excluded it by my own in my config, and this is what --force-exclusion switch is for as I understand (so disabled by default, but I can enable it if I need it).

Yeah, this definitely is a bug. I would not expect the current behaviour either. On the other hand this would be an issue with globbing as then you'd likely get some files that are non-ruby. Probably there's no easy way to fix it for all possible use cases as we can really know if you'd like to check a file that doesn't look like a Ruby file. Keep in mind that from the perspective of RuboCop stuff like globbing are invisible - it just gets a list of filenames from the shell.

@andreaswachowski is right that we definitely need to update RUBY_FILENAMES as well.

@doits
Copy link
Author

doits commented Apr 5, 2017

@bbatsov I added a new issue #4245 for this.

Regarding to globbing: Yes, globbing on command line is invisible to rubocop. But when I glob on the command line, then I have to make sure that I pass correct files. That is not the responsibility of rubocop to filter my bad glob, or at least it should be optional behind a flag.

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

No branches or pull requests

3 participants