Class: JRuby::Lint::Collector
- Inherits:
-
Object
- Object
- JRuby::Lint::Collector
- Defined in:
- lib/jruby/lint/collectors.rb
Direct Known Subclasses
JRuby::Lint::Collectors::Bundler, JRuby::Lint::Collectors::Gemspec, JRuby::Lint::Collectors::Rake, JRuby::Lint::Collectors::Ruby
Defined Under Namespace
Classes: CheckersVisitor
Instance Attribute Summary collapse
-
#checkers ⇒ Object
Returns the value of attribute checkers.
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#file ⇒ Object
Returns the value of attribute file.
-
#findings ⇒ Object
Returns the value of attribute findings.
-
#project ⇒ Object
Returns the value of attribute project.
Class Method Summary collapse
Instance Method Summary collapse
- #ast ⇒ Object
-
#initialize(project = nil, file = nil) ⇒ Collector
constructor
A new instance of Collector.
- #run ⇒ Object
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
#checkers ⇒ Object
Returns the value of attribute checkers.
3 4 5 |
# File 'lib/jruby/lint/collectors.rb', line 3 def checkers @checkers end |
#contents ⇒ Object
Returns the value of attribute contents.
3 4 5 |
# File 'lib/jruby/lint/collectors.rb', line 3 def contents @contents end |
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'lib/jruby/lint/collectors.rb', line 3 def file @file end |
#findings ⇒ Object
Returns the value of attribute findings.
3 4 5 |
# File 'lib/jruby/lint/collectors.rb', line 3 def findings @findings end |
#project ⇒ Object
Returns the value of attribute project.
3 4 5 |
# File 'lib/jruby/lint/collectors.rb', line 3 def project @project end |
Class Method Details
.all ⇒ Object
66 67 68 |
# File 'lib/jruby/lint/collectors.rb', line 66 def self.all @collectors ||= [] end |
.inherited(base) ⇒ Object
62 63 64 |
# File 'lib/jruby/lint/collectors.rb', line 62 def self.inherited(base) self.all << base end |
Instance Method Details
#ast ⇒ Object
54 55 56 |
# File 'lib/jruby/lint/collectors.rb', line 54 def ast @ast ||= JRuby.parse(contents, file, true) end |
#run ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/jruby/lint/collectors.rb', line 45 def run begin CheckersVisitor.new(ast, self, checkers).traverse rescue SyntaxError => e file, line, = e..split(/:\s*/, 3) findings << Finding.new(, [:syntax, :error], file, line) end end |