Refactor rules’ default group severity handling

This commit is contained in:
Sijawusz Pur Rahnama 2022-11-23 15:04:47 +01:00
parent e7a6b6b153
commit 3b7cd3723c

View file

@ -255,9 +255,8 @@ class Ameba::Config
{% end %}
{% if properties["severity".id] == nil %}
{% default = @type.name.starts_with?("Ameba::Rule::Lint") ? "Ameba::Severity::Warning".id : "Ameba::Severity::Convention".id %}
@[YAML::Field(key: "Severity", converter: Ameba::SeverityYamlConverter)]
property severity = {{ default }}
property severity = {{ @type }}.default_severity
{% end %}
{% if properties["excluded".id] == nil %}
@ -267,6 +266,14 @@ class Ameba::Config
end
macro included
GROUP_SEVERITY = {
Lint: Ameba::Severity::Warning,
}
class_getter default_severity : Ameba::Severity do
GROUP_SEVERITY[group_name]? || Ameba::Severity::Convention
end
macro inherited
include YAML::Serializable
include YAML::Serializable::Strict