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

Exclude not working as expected #1022

Closed
mockdeep opened this issue Apr 21, 2014 · 6 comments
Closed

Exclude not working as expected #1022

mockdeep opened this issue Apr 21, 2014 · 6 comments
Assignees
Labels

Comments

@mockdeep
Copy link
Contributor

I'm trying to exclude a bunch of files from the HashSyntax cop and running into some issues. My config looks like this:

HashSyntax:
  Exclude:
    - app/views/**/*
    - app/controllers/**/*
    - app/helpers/**/*
    - app/mailers/**/*
    - app/models/**/*
    - app/poros/**/*
    - spec/**/*

When I run rubocop with these settings, I'm getting some really erratic behavior. Right now it is reporting every violation everywhere, without regard to the excludes. I was running it with rubocop -a and it would report back that 130 or so violations were fixed, when in fact it had fixed every violation in the app, again without regard to the excludes. I can't seem to get back to that state now, though. I've been trying some different patterns and getting different results.

@jonas054
Copy link
Collaborator

Which version of RuboCop are you running? It looks to me like you're following the instruction from the README file on the main page, which refers to the latest master. That won't work together with the relased versions (currently 0.20.1), since they use File.fnmatch to match paths. For example, app/views/**/* will not match app/views/file.rb.

Use .../** instead of .../**/* until next release.

@mockdeep
Copy link
Contributor Author

@jonas054 Yeah, I'm on 0.20.1. I also tried .../** but without success. It returned about 25% fewer violations, but we have thousands, so I was unable to figure out which ones it skipped. It did still return a lot from the directories I wanted to exclude.

@jonas054
Copy link
Collaborator

@mockdeep If you run with --only HashSyntax, you should be able to see if you get any reports in the files you want to exclude or not.

@mockdeep
Copy link
Contributor Author

@jonas054 That doesn't seem to respect .rubocop.yml at all. When I have the rule disabled, running rubocop globally works fine, but running it with --only HashSyntax reports 1637 violations.

@mockdeep
Copy link
Contributor Author

When I set Exclude: it finds the appropriate number of violations. When I run rubocop --only HashSyntax -a, it reports that it only fixed 16 violations, which is to be expected, but really it went through and fixed all of them, including in the files that were excluded.

@jonas054
Copy link
Collaborator

@mockdeep If you meant that you disabled HashSyntax by setting Enabled: false for it in a configuration file, then the --only HashSyntax will enable the cop. That's by design.

But the other thing you found is a bug IMO. Auto-correct does not respect Exclude settings. I've been able to reproduce this problem.

@jonas054 jonas054 added the bug label Apr 22, 2014
bbatsov added a commit that referenced this issue May 11, 2014
[Fix #1022] Make auto-correct honor Exclude for individual cops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants