mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Cleanup properties definition macro
This commit is contained in:
parent
596b0dd9d0
commit
16141a376e
7 changed files with 9 additions and 11 deletions
|
@ -292,17 +292,15 @@ class Ameba::Config
|
|||
{% type = Float64 %}
|
||||
{% end %}
|
||||
{% end %}
|
||||
|
||||
{% type = Nil if type == nil %}
|
||||
{% end %}
|
||||
|
||||
{% properties[name] = {key: key, default: value, type: type, converter: converter} %}
|
||||
|
||||
@[YAML::Field(key: {{ key }}, converter: {{ converter }}, type: {{ type }})]
|
||||
@[YAML::Field(key: {{ key }}, converter: {{ converter }})]
|
||||
{% if type == Bool %}
|
||||
property? {{ name }} : {{ type }} = {{ value }}
|
||||
property? {{ name }}{{ " : #{type}".id if type }} = {{ value }}
|
||||
{% else %}
|
||||
property {{ name }} : {{ type }} = {{ value }}
|
||||
property {{ name }}{{ " : #{type}".id if type }} = {{ value }}
|
||||
{% end %}
|
||||
{% end %}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ module Ameba::Rule::Lint
|
|||
class DebugCalls < Base
|
||||
properties do
|
||||
description "Disallows debug-related calls"
|
||||
method_names : Array(String) = %w(p p! pp pp!)
|
||||
method_names %w(p p! pp pp!)
|
||||
end
|
||||
|
||||
MSG = "Possibly forgotten debug-related `%s` call detected"
|
||||
|
|
|
@ -29,7 +29,7 @@ module Ameba::Rule::Performance
|
|||
class AnyAfterFilter < Base
|
||||
properties do
|
||||
description "Identifies usage of `any?` calls that follow filters"
|
||||
filter_names : Array(String) = %w(select reject)
|
||||
filter_names %w(select reject)
|
||||
end
|
||||
|
||||
ANY_NAME = "any?"
|
||||
|
|
|
@ -45,7 +45,7 @@ module Ameba::Rule::Performance
|
|||
# All of those have bang method variants returning `self`
|
||||
# and are not modifying the receiver type (like `compact` does),
|
||||
# thus are safe to switch to the bang variant.
|
||||
call_names : Array(String) = %w(uniq sort sort_by shuffle reverse)
|
||||
call_names %w(uniq sort sort_by shuffle reverse)
|
||||
end
|
||||
|
||||
# All these methods are allocating a new object
|
||||
|
|
|
@ -28,7 +28,7 @@ module Ameba::Rule::Performance
|
|||
class FirstLastAfterFilter < Base
|
||||
properties do
|
||||
description "Identifies usage of `first/last/first?/last?` calls that follow filters"
|
||||
filter_names : Array(String) = %w(select)
|
||||
filter_names %w(select)
|
||||
end
|
||||
|
||||
CALL_NAMES = %w(first last first? last?)
|
||||
|
|
|
@ -35,7 +35,7 @@ module Ameba::Rule::Performance
|
|||
class SizeAfterFilter < Base
|
||||
properties do
|
||||
description "Identifies usage of `size` calls that follow filter"
|
||||
filter_names : Array(String) = %w(select reject)
|
||||
filter_names %w(select reject)
|
||||
end
|
||||
|
||||
SIZE_NAME = "size"
|
||||
|
|
|
@ -41,7 +41,7 @@ module Ameba::Rule::Style
|
|||
class IsAFilter < Base
|
||||
properties do
|
||||
description "Identifies usage of `is_a?/nil?` calls within filters"
|
||||
filter_names : Array(String) = %w(select reject any? all? none? one?)
|
||||
filter_names %w(select reject any? all? none? one?)
|
||||
end
|
||||
|
||||
MSG = "Use `%s` instead of `%s`"
|
||||
|
|
Loading…
Reference in a new issue