class JRuby::Lint::Project

Constants

DEFAULT_TAGS

Attributes

collectors[R]
files[R]
findings[R]
libraries[R]
reporters[R]
tags[R]

Public Class Methods

new(options = OpenStruct.new) click to toggle source
# File lib/jruby/lint/project.rb, line 10
def initialize(options = OpenStruct.new)
  @tags = DEFAULT_TAGS.dup
  @collectors = []
  @files = Set.new

  if options.eval
    options.eval.each {|e| @collectors << JRuby::Lint::Collectors::Ruby.new(self, '-e', e) }
    @files += @collectors
  end

  if options.tags
    @tags += options.tags
  end

  @sources = options.files || (options.eval ? [] : Dir['./**/*'])
  load_collectors
  load_reporters(options)
  load_libraries
end

Public Instance Methods

run() click to toggle source
# File lib/jruby/lint/project.rb, line 30
def run
  @findings = []
  collectors.each do |c|
    c.run
    reporters.each {|r| r.report(c.findings)}
    @findings += c.findings
  end
  reporters.each {|r| r.print_report(@findings) if r.respond_to?(:print_report) }
end

Private Instance Methods

load_collectors() click to toggle source
# File lib/jruby/lint/project.rb, line 41
def load_collectors
  @sources.each do |f|
    next unless File.file?(f)
    Collector.all.each do |c|
      if c.detect?(f)
        @collectors << c.new(self, f)
        @files << f
      end
    end
  end
end
load_libraries() click to toggle source
# File lib/jruby/lint/project.rb, line 60
def load_libraries
  @libraries = Libraries.new(Libraries::Cache.new)
end
load_reporters(options) click to toggle source
# File lib/jruby/lint/project.rb, line 53
def load_reporters(options)
  @reporters = []
  @reporters << Reporters::Html.new(self, options.html, options) if options.html
  @reporters << Reporters::ANSIColor.new(self, STDOUT, options) if options.ansi || STDOUT.tty?
  @reporters << Reporters::Text.new(self, STDOUT, options) if options.text || @reporters.empty?
end