Sha256: 78426d72ac6cdb8f26072729af0fec9ec1bf58f4d035fa0ed84146c9bb81ec68

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

      # This check reports class variables. Class variables in Ruby have a very complicated inheritance policy that often leads to errors. Usually class
      # variables can be replaced with another construct which will also lead to better design.
      #
      # ==== Applies to
      #
      # * class variables
      class ClassVariableCheck < Base

        def initialize(options = {}) #:nodoc:
          super
          @interesting_contexts = [Parsing::CvarContext]
          @interesting_files = [/\.rb$/, /\.erb$/]
        end

        def evaluate(context) #:nodoc:
          add_warning(context, 'Class variable {{variable}} used.', { :variable => context.full_name })
        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/class_variable_check.rb
excellent-2.1.0 lib/simplabs/excellent/checks/class_variable_check.rb
excellent-2.0.1 lib/simplabs/excellent/checks/class_variable_check.rb
excellent-2.0.0 lib/simplabs/excellent/checks/class_variable_check.rb