class RuboCop::Cop::Minitest::AssertRaisesCompoundBody
end
end
baz
bar
foo do
assert_raises(MyError) do
# good
end
foo
assert_raises(MyError) do
# good
end
bar
foo
assert_raises(MyError) do
# bad
@example
Enforces the block body of ‘assert_raises { … }` to be reduced to only the raising code.
def multi_statement_begin?(node)
def multi_statement_begin?(node) node&.begin_type? && node.children.size > 1 end
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless node.method?(:assert_raises) && multi_statement_begin?(node.body) add_offense(node) end