Sha256: 4eeed32f563491d6ea40125767161bd4e7d05ad6173bbe64e5d142a769ba5a59

Contents?: true

Size: 937 Bytes

Versions: 12

Compression:

Stored size: 937 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 #:nodoc:
          super
          @interesting_nodes = [:if, :case]
        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 }, -2)
          end
        end

      end

    end

  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
simplabs-excellent-1.2.1 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.2.2 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.3.0 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.3.1 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.4.0 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.5.0 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.5.1 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/control_coupling_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/control_coupling_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/control_coupling_check.rb