Sha256: 7ecb2df0d4ce3ec58ac4e4c2003d902ebc31e09c32ac305cb6dcb4ebe84826a4
Contents?: true
Size: 1.07 KB
Versions: 16
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Minitest # Enforces the use of `refute_instance_of(Class, object)` # over `refute(object.instance_of?(Class))`. # # @example # # bad # refute(object.instance_of?(Class)) # refute(object.instance_of?(Class), 'message') # # # bad # refute_equal(Class, object.class) # refute_equal(Class, object.class, 'message') # # # good # refute_instance_of(Class, object) # refute_instance_of(Class, object, 'message') # class RefuteInstanceOf < Base include InstanceOfAssertionHandleable extend AutoCorrector RESTRICT_ON_SEND = %i[refute refute_equal].freeze def_node_matcher :instance_of_assertion?, <<~PATTERN { (send nil? :refute (send $_ :instance_of? $const) $_?) (send nil? :refute_equal $const (send $_ :class) $_?) } PATTERN def on_send(node) investigate(node, :refute) end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems