Sha256: 893f75efd19551baa1d4dc02a33119e37410c84ef5abd3a1c9cece8b2a9c1602
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
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 DEFAULT_WHITELIST = %w(! @ & ` ' + \d+ ~ = / \ , ; \. < > _ 0 * $ ? : " DEBUG FILENAME LOAD_PATH stdin stdout stderr VERBOSE -0 -a -d -F -i -I -l -p -v) def initialize(options = {}) #:nodoc: super @whitelist = options[:whitelist] ||= DEFAULT_WHITELIST @interesting_contexts = [Parsing::GvarContext, Parsing::GasgnContext] @interesting_files = [/\.rb$/, /\.erb$/] end def evaluate(context) #:nodoc: if context.is_a?(Parsing::GasgnContext) || !@whitelist.include?(context.full_name) add_warning(context, 'Global variable {{variable}} used.', { :variable => context.full_name }) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems