-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Expected behavior
Style/ExplicitBlockArgument
not to crash on the code below.
Actual behavior
Style/ExplicitBlockArgument
is crashing on a file that just contains this code:
if @foo
render "partial", prop: @bar do
yield
end
end
Here's the backtrace:
An error occurred while Style/ExplicitBlockArgument cop was inspecting test.rb:3:4.
undefined method `arguments?' for nil:NilClass
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:80:in `add_block_argument'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:66:in `block (2 levels) in on_yield'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/base.rb:333:in `correct'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/base.rb:126:in `add_offense'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:60:in `block in on_yield'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:57:in `yielding_block?'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:57:in `on_yield'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/commissioner.rb:99:in `block (2 levels) in trigger_responding_cops'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/commissioner.rb:152:in `with_cop_error_handling'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/commissioner.rb:98:in `block in trigger_responding_cops'
The actual error came up when running haml_lint. But I think it's a rubocop error, because you can replicate in a ruby file.
For the record, this works fine:
def method
if @foo
render("partial", prop: @bar) do
yield
end
end
end
RuboCop version
$ [bundle exec] rubocop -V
0.92.0 (using Parser 2.7.1.5, rubocop-ast 0.7.1, running on ruby 2.7.1 x86_64-darwin19)