Sha256: 264de397b399c6af7384e90bab6c8beac58460207ea54ede3d071f377b982798
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 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>] # # :reek:FeatureEnvy def sniff(ctx) ctx.each_node(:send).flat_map do |node| next unless node.name.equal?(:respond_to?) smell_warning(context: ctx, lines: [node.line], message: MESSAGE) end.compact end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reek-4.5.4 | lib/reek/smell_detectors/manual_dispatch.rb |
reek-4.5.3 | lib/reek/smell_detectors/manual_dispatch.rb |