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

Style/EvalWithLocation error #9433

Closed
sriedel opened this issue Jan 28, 2021 · 4 comments · Fixed by #9435
Closed

Style/EvalWithLocation error #9433

sriedel opened this issue Jan 28, 2021 · 4 comments · Fixed by #9435
Labels

Comments

@sriedel
Copy link

sriedel commented Jan 28, 2021

Rubocop announces:

An error occurred while Style/EvalWithLocation cop was inspecting <file>
    undefined method `str_type?' for nil:NilClass
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/style/eval_with_location.rb:67:in `on_send'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:166:in `with_cop_error_handling'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:134:in `each'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:154:in `on_block'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:137:in `each'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:161:in `on_defs'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_defs'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:137:in `each'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:138:in `on_while'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_module'
$GEM_HOME/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:20:in `walk'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/team.rb:157:in `investigate_partial'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cop/team.rb:83:in `investigate'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:315:in `inspect_file'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:286:in `loop'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:255:in `do_inspection_loop'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:132:in `block in file_offenses'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:157:in `file_offense_cache'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:131:in `file_offenses'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:122:in `process_file'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `reduce'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:86:in `inspect_files'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/runner.rb:47:in `run'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli/command.rb:11:in `run'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli/environment.rb:18:in `run'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli.rb:65:in `run_command'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli.rb:72:in `execute_runners'
$GEM_HOME/gems/rubocop-1.9.0/lib/rubocop/cli.rb:41:in `run'
$GEM_HOME/gems/rubocop-1.9.0/exe/rubocop:13:in `block in <top (required)>'
$GEM_HOMEhmark.rb:308:in `realtime'
$GEM_HOME/gems/rubocop-1.9.0/exe/rubocop:12:in `<top (required)>'
$GEM_HOMEload'
$GEM_HOME<top (required)>'
$GEM_HOMEler/cli/exec.rb:63:in `load'
$GEM_HOMEler/cli/exec.rb:63:in `kernel_load'

Mention the following information in the issue report:
1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-linux)


Expected behavior

rubocop doesn't error

Actual behavior

rubocop errors

Steps to reproduce the problem

The code in question looks like this:

module MyModule
  def self.included(base)
     base.class_eval do
        include OtherModule
     end
  end

end

RuboCop version

1.9.0

@eric-christian
Copy link

Just ran into this error, too.

1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-darwin19)

@koic koic added the bug label Jan 28, 2021
koic added a commit to koic/rubocop that referenced this issue Jan 28, 2021
Fixes rubocop#9433

This PR fixes an error for `Style/EvalWithLocation`
when using eval with block argument.
@ShockwaveNN
Copy link
Contributor

ShockwaveNN commented Jan 28, 2021

I got very similar stacktrace for this cop:

An error occurred while Lint/SymbolConversion

on this test file:

# frozen_string_literal: true

# Class for description of horizontal alignment
class Foo
  def ==(other)
    to_sym == other if other.is_a?(Symbol)
  end
end

which reproduce only if there is .rubocop.yml with this content:

AllCops:
    TargetRubyVersion: 2.5
    NewCops: enable

on

1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-linux)

Not sure if this is same bug, I can create another issue if this is different problems

@dvandersluis
Copy link
Member

@ShockwaveNN can you create a separate issue please?

@ShockwaveNN
Copy link
Contributor

@dvandersluis Done, #9440

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.

5 participants