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/OperatorMethodCall cop causes an error with the expression like obj.! #11114

Closed
092tsaito opened this issue Oct 24, 2022 · 0 comments · Fixed by #11115
Closed

Style/OperatorMethodCall cop causes an error with the expression like obj.! #11114

092tsaito opened this issue Oct 24, 2022 · 0 comments · Fixed by #11115
Labels

Comments

@092tsaito
Copy link

An error occurred while Style/OperatorMethodCall cop was inspecting a file
which contains the expression like obj.!


Steps to reproduce the problem

  1. Create a Ruby file foo.rb
class Foo
  def sample(arg)
    arg.!
  end
end
  1. run rubocop --debug foo.rb
# bundle exec rubocop --debug foo.rb
For /app/app/models: configuration from /app/.rubocop.yml
configuration from /app/vendor/bundle/ruby/2.7.0/gems/rubocop-rails-2.16.1/config/default.yml
configuration from /app/vendor/bundle/ruby/2.7.0/gems/rubocop-rails-2.16.1/config/default.yml
Default configuration from /app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/config/default.yml
configuration from /app/vendor/bundle/ruby/2.7.0/gems/rubocop-rspec-2.13.2/config/default.yml
configuration from /app/vendor/bundle/ruby/2.7.0/gems/rubocop-rspec-2.13.2/config/default.yml
Inheriting configuration from /app/.rubocop_todo.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /app/app/models/foo.rb
An error occurred while Style/OperatorMethodCall cop was inspecting /app/app/models/foo.rb:3:4.
undefined method `children' for nil:NilClass
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/style/operator_method_call.rb:30:in `on_send'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:134:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/traversal.rb:153:in `on_def'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:71:in `on_def'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/traversal.rb:153:in `on_class'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cop/team.rb:83:in `investigate'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:315:in `inspect_file'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:286:in `loop'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:255:in `do_inspection_loop'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:138:in `block in file_offenses'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:163:in `file_offense_cache'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:137:in `file_offenses'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:128:in `process_file'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:109:in `block in each_inspected_file'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:108:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:108:in `reduce'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:108:in `each_inspected_file'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:94:in `inspect_files'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/runner.rb:47:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli/command.rb:11:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli/environment.rb:18:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli.rb:72:in `run_command'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli.rb:79:in `execute_runners'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/lib/rubocop/cli.rb:48:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/exe/rubocop:19:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.7.0/gems/benchmark-0.2.0/lib/benchmark.rb:311:in `realtime'
/app/vendor/bundle/ruby/2.7.0/gems/rubocop-1.37.0/exe/rubocop:19:in `<top (required)>'
/app/vendor/bundle/ruby/2.7.0/bin/rubocop:25:in `load'
/app/vendor/bundle/ruby/2.7.0/bin/rubocop:25:in `<top (required)>'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `load'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/exec.rb:23:in `run'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:484:in `exec'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:31:in `dispatch'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli.rb:25:in `start'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:48:in `block in <top (required)>'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/root/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/exe/bundle:36:in `<top (required)>'
/root/.rbenv/versions/2.7.6/bin/bundle:25:in `load'
/root/.rbenv/versions/2.7.6/bin/bundle:25:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Style/OperatorMethodCall cop was inspecting /app/app/models/foo.rb:3:4.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.37.0 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 2.7.6) [x86_64-linux]
Finished in 0.4347307999996701 seconds

RuboCop version

$ [bundle exec] rubocop -V
1.37.0 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 2.7.6) [x86_64-linux]
  - rubocop-rails 2.16.1
  - rubocop-rspec 2.13.2
@koic koic added the bug label Oct 24, 2022
koic added a commit to koic/rubocop that referenced this issue Oct 24, 2022
Fixes rubocop#11114

This PR fixes an error for `Style/OperatorMethodCall` when using `obj.!`.
bbatsov pushed a commit that referenced this issue Oct 24, 2022
Fixes #11114

This PR fixes an error for `Style/OperatorMethodCall` when using `obj.!`.
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.

2 participants