Sha256: d0ea93306ef161130f2858ade28925bcbd55950c30ed738c233cae4f951cf09b

Contents?: true

Size: 751 Bytes

Versions: 3

Compression:

Stored size: 751 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

      # This check reports global variables. Global variables introduce strong dependencies between otherwise unrelated parts of code and their use is
      # usually considered extremely bad style.
      #
      # ==== Applies to
      #
      # * global variables
      class GlobalVariableCheck < Base

        def initialize #:nodoc:
          super
          @interesting_nodes = [:gvar, :gasgn]
          @interesting_files = [/\.rb$/, /\.erb$/]
        end

        def evaluate(context) #:nodoc:
          add_warning(context, 'Global variable {{variable}} used.', { :variable => context.full_name })
        end

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/global_variable_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/global_variable_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/global_variable_check.rb