Sha256: e239bbf3081f857ae4c7c6bf004a5ac5800fb2fe7b51f999ec75702e0dc7669f

Contents?: true

Size: 676 Bytes

Versions: 12

Compression:

Stored size: 676 Bytes

Contents

module Skeptic
  module Rules
    class NoGlobalVariables
      DESCRIPTION = 'Do not allow the use of global variables'

      include SexpVisitor

      def initialize(enabled = false)
        @enabled = enabled
        @violations = []
      end

      def apply_to(code, tokens, sexp)
        visit sexp
        self
      end

      def violations
        @violations.map do |variable, line|
          "You have a global variable #{variable} on line #{line}"
        end
      end

      def name
        'No global variables'
      end

      private

      on :@gvar do |variable, location|
        @violations << [variable, location.first]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
skeptic-0.0.16 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.15 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.14 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.12 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.11 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.10 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.9 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.8 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.7 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.6 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.5 lib/skeptic/rules/no_global_variables.rb
skeptic-0.0.4 lib/skeptic/rules/no_global_variables.rb