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

Naming/FileName Cop not working #6132

Closed
jhavero opened this issue Jul 26, 2018 · 1 comment · Fixed by #6145
Closed

Naming/FileName Cop not working #6132

jhavero opened this issue Jul 26, 2018 · 1 comment · Fixed by #6145
Labels

Comments

@jhavero
Copy link

jhavero commented Jul 26, 2018

Expected behavior

I created lib/layoutManager.rb (not a script) but when I run rubocop it doesn't tell me it should be snake case.

Actual behavior

rubocop returns with "no offenses detected"

Steps to reproduce the problem

  1. create file lib/layoutManager.rb
  2. run rubocop lib/layoutManager.rb

RuboCop version

$ rubocop -V
0.58.2 (using Parser 2.5.1.2, running on ruby 2.3.3 x86_64-darwin16)
@koic
Copy link
Member

koic commented Jul 31, 2018

Thanks for the feedback. I confirmed this reproduction and I opened a PR #6145.

koic added a commit to koic/rubocop that referenced this issue Aug 2, 2018
Fixes rubocop#6132.

### Summary

This PR fixes a false negative for `Naming/FileName`
when `Include` of `AllCops` is the default setting.

The important change in this PR is below.

```diff
diff --git a/lib/rubocop/cop/naming/file_name.rb
b/lib/rubocop/cop/naming/file_name.rb
index a025a73b7..be3f1c5aa 100644
--- a/lib/rubocop/cop/naming/file_name.rb
+++ b/lib/rubocop/cop/naming/file_name.rb
@@ -32,7 +32,7 @@ module RuboCop

         def investigate(processed_source)
           file_path = processed_source.file_path
-          return if config.file_to_include?(file_path)
+          return if config.file_to_exclude?(file_path)
```

The problem is that the target to be excluded was
`Include` instead of `Exclude`.

Also this PR adds the `RuboCop::Config#allowed_camel_case_file?`
method to judge ignoring `Gemfile`, `Rakefile`, etc
described in` Include`.

### Other Information

This false negative was noticed by adding `**/*.rb` to
config/default.yml at rubocop#5882.

https://github.com/rubocop-hq/rubocop/pull/5882/files#diff-e93280b3b31a6438c533a5f3232340d8R18
bbatsov pushed a commit that referenced this issue Aug 3, 2018
Fixes #6132.

### Summary

This PR fixes a false negative for `Naming/FileName`
when `Include` of `AllCops` is the default setting.

The important change in this PR is below.

```diff
diff --git a/lib/rubocop/cop/naming/file_name.rb
b/lib/rubocop/cop/naming/file_name.rb
index a025a73b7..be3f1c5aa 100644
--- a/lib/rubocop/cop/naming/file_name.rb
+++ b/lib/rubocop/cop/naming/file_name.rb
@@ -32,7 +32,7 @@ module RuboCop

         def investigate(processed_source)
           file_path = processed_source.file_path
-          return if config.file_to_include?(file_path)
+          return if config.file_to_exclude?(file_path)
```

The problem is that the target to be excluded was
`Include` instead of `Exclude`.

Also this PR adds the `RuboCop::Config#allowed_camel_case_file?`
method to judge ignoring `Gemfile`, `Rakefile`, etc
described in` Include`.

### Other Information

This false negative was noticed by adding `**/*.rb` to
config/default.yml at #5882.

https://github.com/rubocop-hq/rubocop/pull/5882/files#diff-e93280b3b31a6438c533a5f3232340d8R18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants