Sha256: 195c7c9dd6e1d143c738aef0a7ef544f5952441f1cb697286e008e7b73129265
Contents?: true
Size: 1.01 KB
Versions: 25
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Minitest # Enforces the block body of `assert_raises { ... }` to be reduced to only the raising code. # # @example # # bad # assert_raises(MyError) do # foo # bar # end # # # good # assert_raises(MyError) do # foo # end # # # good # assert_raises(MyError) do # foo do # bar # baz # end # end # class AssertRaisesCompoundBody < Base MSG = 'Reduce `assert_raises` block body to contain only the raising code.' def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless node.method?(:assert_raises) && multi_statement_begin?(node.body) add_offense(node) end private def multi_statement_begin?(node) node.begin_type? && node.children.size > 1 end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems