Class: LintFu::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/lint_fu/checker.rb

Constant Summary collapse

SUPPRESSION_COMMENT =
/#\s*lint\s*[-:]\s*(suppress|ignore) (.*)/i

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scan, context, file = nil) ⇒ Checker

Returns a new instance of Checker.



7
8
9
10
11
12
# File 'lib/lint_fu/checker.rb', line 7

def initialize(scan, context, file=nil)
  @scan       = scan
  @context    = context
  @file       = file
  @suppressed = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object

This class responds to any method beginning with “observe_” in order to provide a default callback for every kind of Sexp it might encounter.



16
17
18
19
# File 'lib/lint_fu/checker.rb', line 16

def method_missing(meth, *args)
  return true if meth.to_s =~ /^observe_/
  super(meth, *args)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/lint_fu/checker.rb', line 5

def context
  @context
end

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/lint_fu/checker.rb', line 5

def file
  @file
end

#scanObject (readonly)

Returns the value of attribute scan.



5
6
7
# File 'lib/lint_fu/checker.rb', line 5

def scan
  @scan
end

Instance Method Details

#observe_class_begin(sexp) ⇒ Object



21
22
23
# File 'lib/lint_fu/checker.rb', line 21

def observe_class_begin(sexp)
  enter_suppression_scope(sexp)
end

#observe_class_end(sexp) ⇒ Object



25
26
27
# File 'lib/lint_fu/checker.rb', line 25

def observe_class_end(sexp)
  leave_suppression_scope(sexp)
end