Sha256: d77894e502e0a656016b4cf0785b65a45775c64530e36af2008e334e74756a59
Contents?: true
Size: 876 Bytes
Versions: 3
Compression:
Stored size: 876 Bytes
Contents
# frozen_string_literal: true require_relative 'base_detector' module Reek module SmellDetectors # # A Manual Dispatch occurs when a method is only called after a # manual check that the method receiver is of the correct type. # # The +ManualDispatch+ checker reports any invocation of +respond_to?+ # # See {file:docs/Manual-Dispatch.md} for details. class ManualDispatch < BaseDetector MESSAGE = 'manually dispatches method call' # # Checks for +respond_to?+ usage within the given method # # @return [Array<SmellWarning>] # def sniff smelly_nodes = context.local_nodes(:send).select { |node| node.name == :respond_to? } return [] if smelly_nodes.empty? lines = smelly_nodes.map(&:line) [smell_warning(lines: lines, message: MESSAGE)] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reek-5.0.2 | lib/reek/smell_detectors/manual_dispatch.rb |
reek-5.0.1 | lib/reek/smell_detectors/manual_dispatch.rb |
reek-5.0.0 | lib/reek/smell_detectors/manual_dispatch.rb |