Class: Simplabs::Excellent::Checks::GlobalVariableCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/simplabs/excellent/checks/global_variable_check.rb

Overview

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

Instance Attribute Summary

Attributes inherited from Base

#interesting_files, #interesting_nodes, #warnings

Instance Method Summary collapse

Methods inherited from Base

#add_warning, #evaluate_node, #warnings_for

Constructor Details

#initializeGlobalVariableCheck

:nodoc:



17
18
19
20
21
# File 'lib/simplabs/excellent/checks/global_variable_check.rb', line 17

def initialize #:nodoc:
  super
  @interesting_nodes = [:gvar, :gasgn]
  @interesting_files = [/\.rb$/, /\.erb$/]
end

Instance Method Details

#evaluate(context) ⇒ Object

:nodoc:



23
24
25
# File 'lib/simplabs/excellent/checks/global_variable_check.rb', line 23

def evaluate(context) #:nodoc:
  add_warning(context, 'Global variable {{variable}} used.', { :variable => context.full_name })
end