Sha256: da5f17bad8624ca6c80c7044ee3532222ab409075dd19ec1cd81d7c8e2efa37b

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 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_contexts = [Parsing::GvarContext, Parsing::GasgnContext]
          @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 & 1 rubygems

Version Path
excellent-1.7.1 lib/simplabs/excellent/checks/global_variable_check.rb
excellent-1.7.0 lib/simplabs/excellent/checks/global_variable_check.rb
excellent-1.6.0 lib/simplabs/excellent/checks/global_variable_check.rb