mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
32 lines
631 B
Crystal
32 lines
631 B
Crystal
require "./ameba/*"
|
|
require "./ameba/rules/*"
|
|
|
|
module Ameba
|
|
extend self
|
|
|
|
abstract struct BaseRule
|
|
abstract def test(source : Source)
|
|
end
|
|
|
|
def run(formatter = DotFormatter.new)
|
|
run Dir["**/*.cr"], formatter
|
|
end
|
|
|
|
def run(files, formatter : Formatter)
|
|
sources = files.map { |path| Source.new(File.read(path), path) }
|
|
|
|
reporter = Reporter.new formatter
|
|
reporter.start sources
|
|
sources.each do |source|
|
|
catch(source)
|
|
reporter.report source
|
|
end
|
|
reporter.try &.finish sources
|
|
end
|
|
|
|
def catch(source : Source)
|
|
RULES.each do |rule|
|
|
rule.new.test(source)
|
|
end
|
|
end
|
|
end
|