You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When linting my code, Rubocop reports that an error occurred in the Style/IfInsideElse cop.
Expected behavior
I expect Rubocop to not produce an error.
Actual behavior
An error occurs.
Debug backtrace
> bundle exec rubocop -d tester.rbwarning: parser/current is loading parser/ruby25, which recognizeswarning: 2.5.8-compliant syntax, but you are running 2.5.7.warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.For /Users/tom/Projects/myproject: configuration from /Users/tom/Projects/myproject/.rubocop.ymlconfiguration from /Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-rake-0.5.1/config/default.ymlconfiguration from /Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-rake-0.5.1/config/default.ymlDefault configuration from /Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/config/default.ymlconfiguration from /Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-rspec-2.1.0/config/default.ymlconfiguration from /Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-rspec-2.1.0/config/default.ymlconfiguration from /Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-performance-1.9.2/config/default.ymlconfiguration from /Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-performance-1.9.2/config/default.ymlInheriting configuration from /Users/tom/Projects/myproject/.rubocop_todo.ymlInspecting 1 fileScanning /Users/tom/Projects/myproject/tester.rbAn error occurred while Style/IfInsideElse cop was inspecting /Users/tom/Projects/myproject/tester.rb:3:0.undefined method `last_line' for nil:NilClass/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/mixin/range_help.rb:72:in `range_by_whole_lines'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/style/if_inside_else.rb:90:in `autocorrect'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/style/if_inside_else.rb:76:in `block in on_if'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/base.rb:339:in `correct'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/base.rb:126:in `add_offense'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/style/if_inside_else.rb:75:in `on_if'org/jruby/RubyKernel.java:1960:in `public_send'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:100:in `block in trigger_responding_cops'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:166:in `with_cop_error_handling'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops'org/jruby/RubyArray.java:1809:in `each'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:69:in `on_if'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-ast-1.4.0/lib/rubocop/ast/traversal.rb:157:in `on_if'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:71:in `on_if'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-ast-1.4.0/lib/rubocop/ast/traversal.rb:20:in `walk'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/team.rb:157:in `investigate_partial'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cop/team.rb:83:in `investigate'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:315:in `inspect_file'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'org/jruby/RubyKernel.java:1442:in `loop'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:255:in `do_inspection_loop'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:132:in `block in file_offenses'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:157:in `file_offense_cache'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:131:in `file_offenses'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:122:in `process_file'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'org/jruby/RubyArray.java:1809:in `each'org/jruby/RubyEnumerable.java:1126:in `inject'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:100:in `each_inspected_file'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:86:in `inspect_files'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/runner.rb:47:in `run'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli/command.rb:11:in `run'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli/environment.rb:18:in `run'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli.rb:65:in `run_command'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli.rb:72:in `execute_runners'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/lib/rubocop/cli.rb:41:in `run'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/exe/rubocop:13:in `block in <main>'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/stdlib/benchmark.rb:308:in `realtime'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/rubocop-1.7.0/exe/rubocop:12:in `<main>'org/jruby/RubyKernel.java:1009:in `load'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/bin/rubocop:23:in `<main>'org/jruby/RubyKernel.java:1009:in `load'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/exe/bundle:46:in `block in <main>'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/lib/ruby/gems/shared/gems/bundler-2.1.4/exe/bundle:34:in `<main>'org/jruby/RubyKernel.java:1009:in `load'/Users/tom/.asdf/installs/ruby/jruby-9.2.13.0/bin/bundle:23:in `<main>'.1 file inspected, no offenses detected1 error occurred:An error occurred while Style/IfInsideElse cop was inspecting /Users/tom/Projects/myproject/tester.rb:3:0.Errors are usually caused by RuboCop bugs.Please, report your problems to RuboCop's issue tracker.https://github.com/rubocop-hq/rubocop/issuesMention the following information in the issue report:1.7.0 (using Parser 2.7.2.0, rubocop-ast 1.4.0, running on jruby 2.5.7 java)Finished in 2.6855570369953057 seconds
When linting my code, Rubocop reports that an error occurred in the
Style/IfInsideElse
cop.Expected behavior
I expect Rubocop to not produce an error.
Actual behavior
An error occurs.
Debug backtrace
Steps to reproduce the problem
Lint the following file using RuboCop 1.7:
RuboCop version
The text was updated successfully, but these errors were encountered: