class Codeqa::Runner

Attributes

results[R]

the results (checker instances of the run)

sourcefile[R]

Public Class Methods

new(sourcefile) click to toggle source
# File lib/codeqa/runner.rb, line 27
def initialize(sourcefile)
  @sourcefile = sourcefile
  @results = []
end
register_checker(checker_class) click to toggle source
# File lib/codeqa/runner.rb, line 14
def register_checker(checker_class)
  @@registered_checkers << checker_class
end
registered_checkers() click to toggle source
# File lib/codeqa/runner.rb, line 6
def registered_checkers
  @@registered_checkers
end
reset_checkers() click to toggle source
# File lib/codeqa/runner.rb, line 10
def reset_checkers
  @@registered_checkers = Set.new
end
run(sourcefile) click to toggle source

run the checks on source

# File lib/codeqa/runner.rb, line 21
def self.run(sourcefile)
  runner = new(sourcefile)
  runner.run
  runner
end

Public Instance Methods

display_result(options={}) click to toggle source
# File lib/codeqa/runner.rb, line 57
def display_result(options={})
  RunnerDecorator.new(self, options)
end
failures() click to toggle source
# File lib/codeqa/runner.rb, line 49
def failures
  @failures ||= @results.reject(&:success?)
end
run() click to toggle source
# File lib/codeqa/runner.rb, line 33
def run
  return @results unless @results.empty?
  @results = @@registered_checkers.map do |checker_klass|
    next unless checker_klass.check?(sourcefile)
    checker = checker_klass.new(sourcefile)

    checker.before_check if checker.respond_to?(:before_check)
    checker.check
    checker.after_check if checker.respond_to?(:after_check)
    checker
  end.compact
end
success?() click to toggle source
# File lib/codeqa/runner.rb, line 53
def success?
  failures.empty?
end