Sha256: 573a339a2b885146811c00eed87e35ba1f81f6482bd8e0ab18bf230fec5979ab
Contents?: true
Size: 946 Bytes
Versions: 7
Compression:
Stored size: 946 Bytes
Contents
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true module RuboCop module Cop module Security module Object # This cop checks for the use of `Object#respond_to?`. # # @example # # # bad # Object.respond_to? # # # good # Object.cs__respond_to? class RespondTo < Cop MSG = 'The use of `Object#respond_to?` is a compatibility risk.' def eligible_node? node node.method?(:respond_to?) end def on_send node return false unless eligible_node?(node) add_offense(node, location: :selector) end def autocorrect node ->(corrector) { corrector.replace(node.loc.selector, 'cs__respond_to?') } end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems