We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
No rubocop error when invoking Style/NilComparison
Style/NilComparison
rubocop error when invoking Style/NilComparison
Create a.rb with:
a.rb
class A def foo bar if baz == nil end end
Then:
$ rubocop -d --only Style/NilComparison a.rb For /path/to/project: configuration from /path/to/project/.rubocop.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-performance-1.9.2/config/default.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-performance-1.9.2/config/default.yml Default configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/config/default.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-rake-0.5.1/config/default.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-rake-0.5.1/config/default.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-2.1.0/config/default.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-2.1.0/config/default.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/config/default.yml configuration from /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/config/default.yml Inspecting 1 file Scanning /path/to/project/a.rb An error occurred while Style/NilComparison cop was inspecting /path/to/project/a.rb:3:11. undefined method `method?' for #<RuboCop::AST::IfNode:0x00007ff1a8babed0> Did you mean? method methods /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/style/nil_comparison.rb:53:in `block (2 levels) in on_send' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/base.rb:339:in `correct' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/base.rb:126:in `add_offense' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/style/nil_comparison.rb:45:in `block in on_send' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/style/nil_comparison.rb:48:in `nil_comparison?' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/style/nil_comparison.rb:68:in `style_check?' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/style/nil_comparison.rb:44:in `on_send' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:136:in `public_send' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:166:in `with_cop_error_handling' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:134:in `each' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:70:in `on_send' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:153:in `on_if' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_if' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:154:in `on_def' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_def' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:154:in `on_class' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:71:in `on_class' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-ast-1.4.1/lib/rubocop/ast/traversal.rb:20:in `walk' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/commissioner.rb:86:in `investigate' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/team.rb:157:in `investigate_partial' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cop/team.rb:83:in `investigate' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:315:in `inspect_file' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:286:in `loop' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:255:in `do_inspection_loop' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:132:in `block in file_offenses' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:157:in `file_offense_cache' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:131:in `file_offenses' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:122:in `process_file' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `reduce' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each_inspected_file' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:86:in `inspect_files' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:47:in `run' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli/command.rb:11:in `run' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli/environment.rb:18:in `run' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:65:in `run_command' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:72:in `execute_runners' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:41:in `run' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/exe/rubocop:13:in `block in <top (required)>' /path/to/.rbenv/versions/2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime' /path/to/project/vendor/bundle/ruby/2.6.0/gems/rubocop-1.9.0/exe/rubocop:12:in `<top (required)>' /path/to/project/vendor/bundle/ruby/2.6.0/bin/rubocop:23:in `load' /path/to/project/vendor/bundle/ruby/2.6.0/bin/rubocop:23:in `<top (required)>' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/cli/exec.rb:63:in `load' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/cli/exec.rb:63:in `kernel_load' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/cli/exec.rb:28:in `run' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/cli.rb:494:in `exec' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/cli.rb:30:in `dispatch' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/cli.rb:24:in `start' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/exe/bundle:49:in `block in <top (required)>' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors' /path/to/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.6/exe/bundle:37:in `<top (required)>' /path/to/.rbenv/versions/2.6.6/bin/bundle:23:in `load' /path/to/.rbenv/versions/2.6.6/bin/bundle:23:in `<main>' . 1 file inspected, no offenses detected 1 error occurred: An error occurred while Style/NilComparison cop was inspecting /path/to/project/a.rb:3:11. 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: 1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.6.6 x86_64-darwin19) Finished in 0.5082079999847338 seconds
$ rubocop -V 1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.6.6 x86_64-darwin19) - rubocop-performance 1.9.2 - rubocop-rake 0.5.1 - rubocop-rspec 2.1.0 - rubocop-sorbet 0.5.1
The text was updated successfully, but these errors were encountered:
[Fix rubocop#9449] Fix an error for Style/NilComparison
972273f
Fixes rubocop#9449. This PR fixes an error for `Style/NilComparison` when using `x == nil` as a guard condition'.
[Fix #9449] Fix an error for Style/NilComparison
f8de973
Fixes #9449. This PR fixes an error for `Style/NilComparison` when using `x == nil` as a guard condition'.
Successfully merging a pull request may close this issue.
Expected behavior
No rubocop error when invoking
Style/NilComparison
Actual behavior
rubocop error when invoking
Style/NilComparison
Steps to reproduce the problem
Create
a.rb
with:Then:
RuboCop version
The text was updated successfully, but these errors were encountered: