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/EmptyElse crash on master #3202

Closed
YayC opened this issue Jun 7, 2016 · 0 comments
Closed

Style/EmptyElse crash on master #3202

YayC opened this issue Jun 7, 2016 · 0 comments

Comments

@YayC
Copy link

YayC commented Jun 7, 2016

source method:

def return_time
    if round_trip
      last_trip.scheduled_start_at
    else
      nil
    end
end

for rubocop:

undefined method `begin_pos' for #<Parser::Source::Map::Condition:0x007f971cdff970>
gems/rubocop-9cf9c3c91446/lib/rubocop/cached_data.rb:39:in `serialize_offense'
gems/rubocop-9cf9c3c91446/lib/rubocop/cached_data.rb:18:in `block in to_json'
gems/rubocop-9cf9c3c91446/lib/rubocop/cached_data.rb:18:in `map'
gems/rubocop-9cf9c3c91446/lib/rubocop/cached_data.rb:18:in `to_json'
gems/rubocop-9cf9c3c91446/lib/rubocop/result_cache.rb:93:in `block in save'
gems/rubocop-9cf9c3c91446/lib/rubocop/result_cache.rb:92:in `open'
gems/rubocop-9cf9c3c91446/lib/rubocop/result_cache.rb:92:in `save'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:145:in `save_in_cache'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:89:in `process_file'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:59:in `block in inspect_files'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:57:in `each'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:57:in `inspect_files'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:35:in `run'

for rubocop -C false:

C: Style/EmptyElse: Redundant else-clause.
undefined method `source_line' for #<Parser::Source::Map::Condition:0x007f7f90dd6eb0>
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/clang_style_formatter.rb:36:in `valid_line?'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/clang_style_formatter.rb:25:in `report_offense'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/clang_style_formatter.rb:13:in `block in report_file'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/clang_style_formatter.rb:13:in `each'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/clang_style_formatter.rb:13:in `report_file'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/progress_formatter.rb:43:in `block in finished'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/progress_formatter.rb:42:in `each'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/progress_formatter.rb:42:in `finished'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/formatter_set.rb:30:in `block (3 levels) in <class:FormatterSet>'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/formatter_set.rb:30:in `each'
gems/rubocop-9cf9c3c91446/lib/rubocop/formatter/formatter_set.rb:30:in `block (2 levels) in <class:FormatterSet>'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:68:in `inspect_files'
gems/rubocop-9cf9c3c91446/lib/rubocop/runner.rb:35:in `run'

Expected behavior

No crash

Actual behavior

Crash

Steps to reproduce the problem

run rubocop on test.rb:

def truish
  if true
    true
  else
    nil
  end
end

RuboCop version

0.40.0 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-darwin15)

bbatsov added a commit that referenced this issue Jun 14, 2016
[Fix #3202] Register proper offense in `Style/EmptyElse`
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
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

No branches or pull requests

1 participant