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

Projects
None yet
3 participants
@pocke
Member

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.

@bbatsov bbatsov merged commit 880eb89 into rubocop-hq:master Jun 26, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Jun 26, 2016

Collaborator

0.41.1 is out.

Collaborator

bbatsov commented Jun 26, 2016

0.41.1 is out.

@pocke pocke deleted the pocke:work-uniq-before-pluck-cop branch Jun 26, 2016

@tjwp

This comment has been minimized.

Show comment
Hide comment
@tjwp

tjwp Jun 26, 2016

Contributor

@pocke That was my mistake. Thanks for fixing!

Contributor

tjwp commented Jun 26, 2016

@pocke That was my mistake. Thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment