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
The cop throws an error when inspecting a conditional with more than one empty branch.
It should not throw an error.
It throws an error.
An error occurred while Lint/EmptyConditionalBody cop was inspecting /Users/david/code/rubocop-test/app.rb:7:0. undefined method `line' for nil:NilClass /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/mixin/comments_help.rb:55:in `find_end_line' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/mixin/comments_help.rb:16:in `contains_comments?' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/lint/empty_conditional_body.rb:62:in `on_if' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:100:in `public_send' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:98:in `each' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:69:in `on_if' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:156:in `on_if' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:71:in `on_if' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:156:in `on_if' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:71:in `on_if' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:20:in `walk' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:86:in `investigate' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/team.rb:155:in `investigate_partial' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cop/team.rb:83:in `investigate' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:309:in `inspect_file' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:253:in `block in do_inspection_loop' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:287:in `block in iterate_until_no_changes' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:280:in `loop' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:280:in `iterate_until_no_changes' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:249:in `do_inspection_loop' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:130:in `block in file_offenses' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:155:in `file_offense_cache' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:129:in `file_offenses' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:67:in `block in warm_cache' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:587:in `call_with_index' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:557:in `process_incoming_jobs' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:537:in `block in worker' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:528:in `fork' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:528:in `worker' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:519:in `block in create_workers' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:518:in `each' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:518:in `each_with_index' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:518:in `create_workers' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:457:in `work_in_processes' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:294:in `map' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/parallel-1.22.1/lib/parallel.rb:238:in `each' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:67:in `warm_cache' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/runner.rb:46:in `run' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli/command.rb:11:in `run' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli/environment.rb:18:in `run' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli.rb:71:in `run_command' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli.rb:78:in `execute_runners' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/lib/rubocop/cli.rb:47:in `run' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/exe/rubocop:12:in `block in <top (required)>' /Users/david/.rbenv/versions/2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime' /Users/david/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.27.0/exe/rubocop:12:in `<top (required)>' /Users/david/.rbenv/versions/2.6.6/bin/rubocop:23:in `load' /Users/david/.rbenv/versions/2.6.6/bin/rubocop:23:in `<main>'
Create app.rb with the following code:
# frozen_string_literal: true if condition_a puts 'hello' elsif condition_b # Do nothing elsif condition_c # Do nothing end
Run rubocop app.rb
rubocop app.rb
% rubocop -V 1.27.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 2.6.6 -darwin20)
The text was updated successfully, but these errors were encountered:
[Fix rubocop#10514] Fix an error for Lint/EmptyConditionalBody
Lint/EmptyConditionalBody
0dc992e
Fixes rubocop#10514. This PR fixes an error for `Lint/EmptyConditionalBody` when missing second `elsif` body.
[Fix #10514] Fix an error for Lint/EmptyConditionalBody
1fe7d0d
Fixes #10514. This PR fixes an error for `Lint/EmptyConditionalBody` when missing second `elsif` body.
Successfully merging a pull request may close this issue.
The cop throws an error when inspecting a conditional with more than one empty branch.
Expected behavior
It should not throw an error.
Actual behavior
It throws an error.
Steps to reproduce the problem
Create app.rb with the following code:
Run
rubocop app.rb
RuboCop version
The text was updated successfully, but these errors were encountered: