Sha256: ac5afd24526f08cca4ecf380fce155d86fccb09de811f21c54a5ca365c092408

Contents?: true

Size: 980 Bytes

Versions: 4

Compression:

Stored size: 980 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

      # This check reports methods that check the value of a parameter to decide which execution path to take. Control Coupling introduces a
      # dependency between the caller and the callee. Any changes to the possible values of the parameter must be reflected at the caller side
      # as well as at the called method.
      #
      # ==== Applies to
      #
      # * methods
      class ControlCouplingCheck < Base

        def initialize(options = {}) #:nodoc:
          super
          @interesting_contexts = [Parsing::IfContext, Parsing::CaseContext]
        end

        def evaluate(context) #:nodoc:
          if tested_parameter = context.tests_parameter?
            add_warning(context, '{{method}} is coupled to {{argument}}.', { :method => context.parent.full_name, :argument => tested_parameter.to_s })
          end
        end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
excellent-2.1.1 lib/simplabs/excellent/checks/control_coupling_check.rb
excellent-2.1.0 lib/simplabs/excellent/checks/control_coupling_check.rb
excellent-2.0.1 lib/simplabs/excellent/checks/control_coupling_check.rb
excellent-2.0.0 lib/simplabs/excellent/checks/control_coupling_check.rb