Sha256: aec3beb8bf6b321d84969bb10a9a2be4af4cfe78fa2ffcc980c990a6fbc6c2ea
Contents?: true
Size: 988 Bytes
Versions: 7
Compression:
Stored size: 988 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 Module # This cop checks for the use of `Module#const_defined`. # # @example # # # bad # Module.const_defined?(something) # # # good # Module.cs__const_defined?(something) class ConstDefined < Cop MSG = 'The use of `Module#const_defined?` is a compatibility risk.' def eligible_node? node node.method?(:const_defined?) 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__const_defined?') } end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems