Sha256: b512f53885f11a277e516939a72b0fffc5a189145988d09c80c1e92cec7c9b9b

Contents?: true

Size: 816 Bytes

Versions: 4

Compression:

Stored size: 816 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 SingletonVariableCheck < Base

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

        def evaluate(context) #:nodoc:
          add_warning(context, 'Singleton 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-1.7.2 lib/simplabs/excellent/checks/singleton_variable_check.rb
excellent-1.7.1 lib/simplabs/excellent/checks/singleton_variable_check.rb
excellent-1.7.0 lib/simplabs/excellent/checks/singleton_variable_check.rb
excellent-1.6.0 lib/simplabs/excellent/checks/singleton_variable_check.rb