mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Merge pull request #310 from crystal-ameba/Sija/refactor-rule-default-group-severity
This commit is contained in:
commit
f89e7c2d3c
4 changed files with 14 additions and 5 deletions
|
@ -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,16 @@ class Ameba::Config
|
|||
end
|
||||
|
||||
macro included
|
||||
GROUP_SEVERITY = {
|
||||
Lint: Ameba::Severity::Warning,
|
||||
Metrics: Ameba::Severity::Warning,
|
||||
Performance: 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
|
||||
|
|
|
@ -9,7 +9,7 @@ module Ameba::Rule::Layout
|
|||
# ```
|
||||
class TrailingWhitespace < Base
|
||||
properties do
|
||||
description "Disallows trailing whitespaces"
|
||||
description "Disallows trailing whitespace"
|
||||
end
|
||||
|
||||
MSG = "Trailing whitespace detected"
|
||||
|
|
|
@ -2,6 +2,7 @@ module Ameba::Rule::Lint
|
|||
# A rule that disallows redundant `with_index` calls.
|
||||
#
|
||||
# For example, this is considered invalid:
|
||||
#
|
||||
# ```
|
||||
# collection.each.with_index do |e|
|
||||
# # ...
|
||||
|
|
|
@ -88,8 +88,7 @@ module Ameba
|
|||
@formatter.started @sources
|
||||
|
||||
channels = @sources.map { Channel(Exception?).new }
|
||||
@sources.each_with_index do |source, idx|
|
||||
channel = channels[idx]
|
||||
@sources.zip(channels).each do |source, channel|
|
||||
spawn do
|
||||
run_source(source)
|
||||
rescue e
|
||||
|
|
Loading…
Reference in a new issue