Sha256: a23f2064cd09480efec1c85ed96de1e99ca4d431b1bd25c68d1fd2393660d634

Contents?: true

Size: 809 Bytes

Versions: 4

Compression:

Stored size: 809 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Minitest
      # Enforces the use of `refute_kind_of(Class, object)`
      # over `refute(object.kind_of?(Class))`.
      #
      # @example
      #   # bad
      #   refute(object.kind_of?(Class))
      #   refute(object.kind_of?(Class), 'message')
      #
      #   # bad
      #   # `is_a?` is an alias for `kind_of?`
      #   refute(object.is_of?(Class))
      #   refute(object.is_of?(Class), 'message')
      #
      #   # good
      #   refute_kind_of(Class, object)
      #   refute_kind_of(Class, object, 'message')
      #
      class RefuteKindOf < Base
        extend MinitestCopRule

        define_rule :refute, target_method: %i[kind_of? is_a?], preferred_method: :refute_kind_of, inverse: true
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-minitest-0.36.0 lib/rubocop/cop/minitest/refute_kind_of.rb
rubocop-minitest-0.35.1 lib/rubocop/cop/minitest/refute_kind_of.rb
rubocop-minitest-0.35.0 lib/rubocop/cop/minitest/refute_kind_of.rb
rubocop-minitest-0.34.5 lib/rubocop/cop/minitest/refute_kind_of.rb