Class: Skeptic::Rules::NoGlobalVariables
- Inherits:
-
Object
- Object
- Skeptic::Rules::NoGlobalVariables
- Includes:
- SexpVisitor
- Defined in:
- lib/skeptic/rules/no_global_variables.rb
Constant Summary collapse
- DESCRIPTION =
'Do not allow the use of global variables'
Instance Method Summary collapse
- #apply_to(code, tokens, sexp) ⇒ Object
-
#initialize(enabled = false) ⇒ NoGlobalVariables
constructor
A new instance of NoGlobalVariables.
- #name ⇒ Object
- #violations ⇒ Object
Methods included from SexpVisitor
Constructor Details
#initialize(enabled = false) ⇒ NoGlobalVariables
Returns a new instance of NoGlobalVariables.
8 9 10 11 |
# File 'lib/skeptic/rules/no_global_variables.rb', line 8 def initialize(enabled = false) @enabled = enabled @violations = [] end |
Instance Method Details
#apply_to(code, tokens, sexp) ⇒ Object
13 14 15 16 |
# File 'lib/skeptic/rules/no_global_variables.rb', line 13 def apply_to(code, tokens, sexp) visit sexp self end |
#name ⇒ Object
24 25 26 |
# File 'lib/skeptic/rules/no_global_variables.rb', line 24 def name 'No global variables' end |
#violations ⇒ Object
18 19 20 21 22 |
# File 'lib/skeptic/rules/no_global_variables.rb', line 18 def violations @violations.map do |variable, line| "You have a global variable #{variable} on line #{line}" end end |