Sha256: 701aec0e061a2133d4a83257dfbe2063339cdfac223893e8f43bf5ea39bc522d

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

require 'reek/smells/smell_detector'

module Reek
  module Smells

    #
    # Class variables form part of the global runtime state, and as such make
    # it easy for one part of the system to accidentally or inadvertently
    # depend on another part of the system. So the system becomes more prone to
    # problems where changing something over here breaks something over there.
    # In particular, class variables can make it hard to set up tests (because
    # the context of the test includes all global state).
    #
    class ClassVariable < SmellDetector

      def self.contexts      # :nodoc:
        [:class, :module]
      end

      #
      # Checks whether the given class declares any class variables.
      # Remembers any smells found.
      #
      def examine_context(klass)
        klass.class_variables.each do |cvar|
          found(klass, "declares the class variable #{cvar}")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-1.2.2 lib/reek/smells/class_variable.rb
reek-1.2.1 lib/reek/smells/class_variable.rb