Sha256: e6cbcb193f6a734c2310c5533b80b360ee67fe099ca4e81027284e0c149f3a97
Contents?: true
Size: 899 Bytes
Versions: 1
Compression:
Stored size: 899 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'.freeze # # Checks for +respond_to?+ usage within the given method # # @return [Array<SmellWarning>] # def sniff smelly_nodes = context.each_node(:send).select { |node| node.name == :respond_to? } return [] if smelly_nodes.empty? lines = smelly_nodes.map(&:line) [smell_warning(context: context, lines: lines, message: MESSAGE)] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-4.7.3 | lib/reek/smell_detectors/manual_dispatch.rb |