Style/IfWithSemicolon
- undefined method `source' for nil:NilClass
#11996
Labels
Style/IfWithSemicolon
- undefined method `source' for nil:NilClass
#11996
Hello 馃憢 I hope I'll give enough information, do not hesitate if you need more context.
Given a file
foo.rb
:Which is a valid syntax:
Expected behavior
Should not trigger an error, display the offense and propose a fix (reading the code I think this is the expected behavior, not sure to be honest, at least not trigger an error as it's a valid syntax).
Actual behavior
bin/rubocop -d --only Style/IfWithSemicolon foo.rb
Steps to reproduce the problem
In
IfWithSemicolon
theon_normal_if_unless
receive a node:Then to propose a fix the cop calls the
correct_elsif
, asif node.else_branch&.if_type?
istrue
But it's interpolate
#{node.if_branch.source}
which isnil
rubocop/lib/rubocop/cop/style/if_with_semicolon.rb
Lines 23 to 34 in aaf1c3f
rubocop/lib/rubocop/cop/style/if_with_semicolon.rb
Lines 38 to 45 in aaf1c3f
rubocop/lib/rubocop/cop/style/if_with_semicolon.rb
Lines 47 to 54 in aaf1c3f
RuboCop version
The text was updated successfully, but these errors were encountered: