Class: JRuby::Lint::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby/lint/collectors.rb

Defined Under Namespace

Classes: CheckersVisitor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project = nil, file = nil) ⇒ Collector

Returns a new instance of Collector.



5
6
7
8
9
10
# File 'lib/jruby/lint/collectors.rb', line 5

def initialize(project = nil, file = nil)
  @checkers = Checker.loaded_checkers.map(&:new)
  @checkers.each {|c| c.collector = self }
  @findings = []
  @project, @file = project, file || '<inline-script>'
end

Instance Attribute Details

#checkersObject

Returns the value of attribute checkers.



3
4
5
# File 'lib/jruby/lint/collectors.rb', line 3

def checkers
  @checkers
end

#contentsObject

Returns the value of attribute contents.



3
4
5
# File 'lib/jruby/lint/collectors.rb', line 3

def contents
  @contents
end

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/jruby/lint/collectors.rb', line 3

def file
  @file
end

#findingsObject

Returns the value of attribute findings.



3
4
5
# File 'lib/jruby/lint/collectors.rb', line 3

def findings
  @findings
end

#projectObject

Returns the value of attribute project.



3
4
5
# File 'lib/jruby/lint/collectors.rb', line 3

def project
  @project
end

Class Method Details

.allObject



63
64
65
# File 'lib/jruby/lint/collectors.rb', line 63

def self.all
  @collectors ||= []
end

.inherited(base) ⇒ Object



59
60
61
# File 'lib/jruby/lint/collectors.rb', line 59

def self.inherited(base)
  self.all << base
end

Instance Method Details

#astObject



51
52
53
# File 'lib/jruby/lint/collectors.rb', line 51

def ast
  @ast ||= JRuby.parse(contents, file, true)
end

#runObject



42
43
44
45
46
47
48
49
# File 'lib/jruby/lint/collectors.rb', line 42

def run
  begin
    CheckersVisitor.new(ast, checkers).traverse
  rescue SyntaxError => e
    file, line, message = e.message.split(/:\s*/, 3)
    findings << Finding.new(message, [:syntax, :error], file, line)
  end
end