shard-ameba/src/ameba/rule/base.cr

30 lines
491 B
Crystal
Raw Normal View History

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
def test(source : Source, node : Crystal::ASTNode)
# can't be abstract
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