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

Lint/SymbolConversion raise undefined method `str_type?' for nil:NilClas #9440

Closed
ShockwaveNN opened this issue Jan 28, 2021 · 0 comments · Fixed by #9442
Closed

Lint/SymbolConversion raise undefined method `str_type?' for nil:NilClas #9440

ShockwaveNN opened this issue Jan 28, 2021 · 0 comments · Fixed by #9442
Assignees

Comments

@ShockwaveNN
Copy link
Contributor

Steps to reproduce the problem

  1. Create .rubocop.yml with content:
AllCops:
    TargetRubyVersion: 2.5
    NewCops: enable

For some reason failure is not reproduces without .rubocop.yml config, not sure which line is caused it

  1. Create test.rb with content:
# frozen_string_literal: true

# Class for description of horizontal alignment
class Foo
  def ==(other)
    to_sym == other if other.is_a?(Symbol)
  end
end
  1. run rubocop -d test.rb will result:
rubocop -d test.rb   
For /home/lobashov/temp: configuration from /home/lobashov/temp/.rubocop.yml
Default configuration from /home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/config/default.yml
Inspecting 1 file
Scanning /home/lobashov/temp/test.rb
An error occurred while Lint/SymbolConversion cop was inspecting /home/lobashov/temp/test.rb:6:4.
undefined method `str_type?' for nil:NilClass
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/lint/symbol_conversion.rb:31:in `on_send'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:166:in `with_cop_error_handling'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:134:in `each'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:159:in `block in on_send'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:156:in `each'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:156:in `each_with_index'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:156:in `on_send'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_send'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:155:in `on_if'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_if'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:154:in `on_def'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_def'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:154:in `on_class'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:20:in `walk'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/team.rb:157:in `investigate_partial'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cop/team.rb:83:in `investigate'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:315:in `inspect_file'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:286:in `loop'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:255:in `do_inspection_loop'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:132:in `block in file_offenses'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:157:in `file_offense_cache'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:131:in `file_offenses'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:122:in `process_file'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `reduce'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:86:in `inspect_files'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/runner.rb:47:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli/command.rb:11:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli.rb:65:in `run_command'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli.rb:72:in `execute_runners'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/lib/rubocop/cli.rb:41:in `run'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/exe/rubocop:13:in `block in <top (required)>'
/usr/share/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/home/lobashov/.rvm/gems/ruby-2.7.2/gems/rubocop-1.9.0/exe/rubocop:12:in `<top (required)>'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/rubocop:23:in `load'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/rubocop:23:in `<main>'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:24:in `eval'
/home/lobashov/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:24:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Lint/SymbolConversion cop was inspecting /home/lobashov/temp/test.rb:6:4

RuboCop version

1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-linux)
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 a pull request may close this issue.

2 participants