2017-11-07 21:50:25 +00:00
|
|
|
module Ameba::Rule
|
|
|
|
abstract struct Base
|
2017-11-13 21:20:22 +00:00
|
|
|
include Config::Rule
|
|
|
|
|
2017-10-30 20:00:01 +00:00
|
|
|
abstract def test(source : Source)
|
|
|
|
|
2017-11-13 21:20:22 +00:00
|
|
|
prop enabled? = true
|
|
|
|
|
2017-10-31 22:47:29 +00:00
|
|
|
def test(source : Source, node : Crystal::ASTNode)
|
2017-11-06 18:54:58 +00:00
|
|
|
# can't be abstract
|
2017-10-31 22:47:29 +00:00
|
|
|
end
|
|
|
|
|
2017-10-30 20:00:01 +00:00
|
|
|
def catch(source : Source)
|
|
|
|
source.tap { |s| test s }
|
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
2017-11-07 21:50:25 +00:00
|
|
|
self.class.name.gsub("Ameba::Rule::", "")
|
2017-10-30 20:00:01 +00:00
|
|
|
end
|
2017-11-01 10:49:03 +00:00
|
|
|
|
2017-11-07 21:50:25 +00:00
|
|
|
protected def self.subclasses
|
2017-11-01 10:49:03 +00:00
|
|
|
{{ @type.subclasses }}
|
|
|
|
end
|
2017-10-30 20:00:01 +00:00
|
|
|
end
|
2017-11-07 21:50:25 +00:00
|
|
|
|
|
|
|
def self.rules
|
|
|
|
Base.subclasses
|
|
|
|
end
|
2017-10-30 20:00:01 +00:00
|
|
|
end
|