Sha256: 7f0ec03da095e70398ca118a7fff101021074f8e8442caf54e9d02f0f4e5ad95
Contents?: true
Size: 974 Bytes
Versions: 9
Compression:
Stored size: 974 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Minitest # Enforces the test to use `assert_empty` instead of using `assert(object.empty?)`. # # @example # # bad # assert(object.empty?) # assert(object.empty?, 'message') # # # good # assert_empty(object) # assert_empty(object, 'message') # class AssertEmpty < Base extend MinitestCopRule define_rule :assert, target_method: :empty? remove_method :on_send def on_send(node) return unless node.method?(:assert) return unless node.first_argument.respond_to?(:method?) && node.first_argument.method?(:empty?) return unless node.first_argument.arguments.empty? add_offense(node, message: offense_message(node.arguments)) do |corrector| autocorrect(corrector, node, node.arguments) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems