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

Error in VariableForce cop related to uninitialized constant DidYouMean::SpellChecker #8087

Closed
danielpowell4 opened this issue Jun 2, 2020 · 1 comment

Comments

@danielpowell4
Copy link

danielpowell4 commented Jun 2, 2020

Getting uninitialized constant DidYouMean::SpellChecker error while running rubocop from the VariableForce cop


Expected behavior

Run rubocop, not get error

Actual behavior

Getting error with following stacktrace:

rubocop -d app/models/model_with_error.rb
For /MyLocal/Path/work/pp/dashboard: configuration from /my_local/path/to/project/.rubocop.yml
configuration from /MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.6.0/config/default.yml
configuration from /MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.6.0/config/default.yml
Default configuration from /MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/config/default.yml
configuration from /MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.5.2/config/default.yml
configuration from /MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.5.2/config/default.yml
Inheriting configuration from /my_local/path/to/project/.rubocop_todo.yml
Inheriting configuration from /my_local/path/to/project/.rubocop_full.yml
Inspecting 1 file
Scanning /my_local/path/to/project/app/models/model_with_error.rb
An error occurred while VariableForce cop was inspecting /my_local/path/to/project/app/models/model_with_error.rb.
uninitialized constant DidYouMean::SpellChecker
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/name_similarity.rb:18:in `find_similar_names'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/name_similarity.rb:9:in `find_similar_name'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:97:in `similar_name_message'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:77:in `message_specification'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:68:in `message_for_useless_assignment'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:52:in `block in check_for_unused_assignments'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:49:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:49:in `check_for_unused_assignments'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:42:in `block in after_leaving_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:41:in `each_value'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/lint/useless_assignment.rb:41:in `after_leaving_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/force.rb:33:in `block in run_hook'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/force.rb:30:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/force.rb:30:in `run_hook'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:394:in `block (2 levels) in <class:VariableForce>'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force/variable_table.rb:17:in `invoke_hook'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force/variable_table.rb:36:in `pop_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:96:in `inspect_variables_in_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:292:in `process_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:86:in `process_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:103:in `block in process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:187:in `block in each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:100:in `process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:87:in `process_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:103:in `block in process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:187:in `block in each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:100:in `process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:95:in `inspect_variables_in_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:292:in `process_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:86:in `process_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:103:in `block in process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:187:in `block in each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:100:in `process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:87:in `process_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:103:in `block in process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:187:in `block in each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node.rb:184:in `each_child_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:100:in `process_children'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:95:in `inspect_variables_in_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:292:in `process_scope'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:86:in `process_node'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/variable_force.rb:80:in `investigate'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/commissioner.rb:87:in `block (2 levels) in invoke_custom_processing'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/commissioner.rb:115:in `with_cop_error_handling'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/commissioner.rb:86:in `block in invoke_custom_processing'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/commissioner.rb:83:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/commissioner.rb:83:in `invoke_custom_processing'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/commissioner.rb:42:in `investigate'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/team.rb:141:in `investigate'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/team.rb:129:in `offenses'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cop/team.rb:67:in `inspect_file'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:299:in `inspect_file'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:247:in `block in do_inspection_loop'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:279:in `block in iterate_until_no_changes'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:272:in `loop'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:272:in `iterate_until_no_changes'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:243:in `do_inspection_loop'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:122:in `block in file_offenses'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:146:in `file_offense_cache'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:120:in `file_offenses'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:111:in `process_file'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:90:in `block in each_inspected_file'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:89:in `each'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:89:in `reduce'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:89:in `each_inspected_file'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:78:in `inspect_files'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/runner.rb:39:in `run'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/command.rb:10:in `run'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli/environment.rb:17:in `run'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli.rb:65:in `run_command'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli.rb:72:in `execute_runners'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/lib/rubocop/cli.rb:41:in `run'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/exe/rubocop:13:in `block in <top (required)>'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/MyLocal/Path/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-0.85.0/exe/rubocop:12:in `<top (required)>'
/MyLocal/Path/.rbenv/versions/2.6.5/bin/rubocop:23:in `load'
/MyLocal/Path/.rbenv/versions/2.6.5/bin/rubocop:23:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while VariableForce cop was inspecting /my_local/path/to/project/app/models/model_with_error.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Mention the following information in the issue report:
0.85.0 (using Parser 2.7.1.3, rubocop-ast 0.0.3, running on ruby 2.6.5 x86_64-darwin18)
Finished in 1.2765789999393746 seconds

I think it is likely related to this method where a variable is set inside a transaction block

def approve!(attrs = {}, approved_by = nil)
    # ... guard clause

    transaction do
      # ... update other stuff
      update_status = update_parent!(attrs) if attrs.present? # <-- the error is coming from here
      save!
    end
    notify_listeners(:on_lesson_approved) # triggers downstream actions
    update_status # <-- then attempted to be referenced down here
  end

Steps to reproduce the problem

An error is occurring related to this line:

https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/name_similarity.rb#L18

which was recently added in this commit:

c92a591

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

Mention the following information in the issue report:
0.85.0 (using Parser 2.7.1.3, rubocop-ast 0.0.3, running on ruby 2.6.5 x86_64-darwin18)
Finished in 1.2765789999393746 seconds
@koic
Copy link
Member

koic commented Jun 4, 2020

Dup with #7979.

@koic koic closed this as completed Jun 4, 2020
@koic koic added the duplicate label Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants