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

Fix UniqBeforePluck cop by solving difference of config name #3245

Merged
merged 1 commit into from
Jun 26, 2016

Conversation

pocke
Copy link
Collaborator

@pocke pocke commented Jun 26, 2016

RuboCop 0.41 doesn't work...

repro

test.rb

puts "a"
$ rubocop test.rb -d --rails --only Rails/UniqBeforePluck
An error occurred while Rails/UniqBeforePluck cop was inspecting /tmp/test/test.rb.

1 error occurred:
An error occurred while Rails/UniqBeforePluck cop was inspecting /tmp/test/test.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.41.0 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-linux)
For /tmp/test: configuration from /home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/config/default.yml
Inheriting configuration from /home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/config/enabled.yml
Inheriting configuration from /home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/config/disabled.yml
Inspecting 1 file
Scanning /tmp/test/test.rb
undefined method `to_sym' for nil:NilClass
Did you mean?  to_s
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/rails/uniq_before_pluck.rb:71:in `mode'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/rails/uniq_before_pluck.rb:51:in `on_send'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/commissioner.rb:42:in `block (2 levels) in on_send'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/commissioner.rb:97:in `with_cop_error_handling'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/commissioner.rb:41:in `block in on_send'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/commissioner.rb:40:in `each'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/commissioner.rb:40:in `on_send'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/ast_node/traversal.rb:13:in `walk'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/commissioner.rb:59:in `investigate'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/team.rb:103:in `investigate'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/team.rb:91:in `offenses'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cop/team.rb:52:in `inspect_file'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:205:in `inspect_file'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:175:in `block in do_inspection_loop'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:165:in `loop'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:165:in `do_inspection_loop'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:87:in `process_file'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:59:in `block in inspect_files'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:57:in `each'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:57:in `inspect_files'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/runner.rb:35:in `run'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cli.rb:72:in `execute_runner'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/lib/rubocop/cli.rb:28:in `run'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/bin/rubocop:14:in `block in <top (required)>'
/usr/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
/home/pocke/.gem/ruby/2.3.0/gems/rubocop-0.41.0/bin/rubocop:13:in `<top (required)>'
/home/pocke/.gem/ruby/2.3.0/bin/rubocop:23:in `load'
/home/pocke/.gem/ruby/2.3.0/bin/rubocop:23:in `<main>'
.

1 file inspected, no offenses detected
Finished in 0.06867309300287161 seconds

Cause

In config file, config name is EnforcementMode.
However, in cop file, config name is EnforcedMode.
So, the cop can't reference the config.

13f2f5c


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Used the same coding conventions as the rest of the project.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

@pocke pocke force-pushed the work-uniq-before-pluck-cop branch from 1dcb3fb to 19e738b Compare June 26, 2016 01:32
@bbatsov bbatsov merged commit 880eb89 into rubocop:master Jun 26, 2016
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 26, 2016

0.41.1 is out.

@pocke pocke deleted the work-uniq-before-pluck-cop branch June 26, 2016 08:59
@tjwp
Copy link
Contributor

tjwp commented Jun 26, 2016

@pocke That was my mistake. Thanks for fixing!

Neodelf pushed a commit to Neodelf/rubocop that referenced this pull request Oct 15, 2016
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.

3 participants