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 %}
|
{% type = Float64 %}
|
||||||
{% end %}
|
{% end %}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
{% type = Nil if type == nil %}
|
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
{% properties[name] = {key: key, default: value, type: type, converter: converter} %}
|
{% 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 %}
|
{% if type == Bool %}
|
||||||
property? {{ name }} : {{ type }} = {{ value }}
|
property? {{ name }}{{ " : #{type}".id if type }} = {{ value }}
|
||||||
{% else %}
|
{% else %}
|
||||||
property {{ name }} : {{ type }} = {{ value }}
|
property {{ name }}{{ " : #{type}".id if type }} = {{ value }}
|
||||||
{% end %}
|
{% end %}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Ameba::Rule::Lint
|
||||||
class DebugCalls < Base
|
class DebugCalls < Base
|
||||||
properties do
|
properties do
|
||||||
description "Disallows debug-related calls"
|
description "Disallows debug-related calls"
|
||||||
method_names : Array(String) = %w(p p! pp pp!)
|
method_names %w(p p! pp pp!)
|
||||||
end
|
end
|
||||||
|
|
||||||
MSG = "Possibly forgotten debug-related `%s` call detected"
|
MSG = "Possibly forgotten debug-related `%s` call detected"
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Ameba::Rule::Performance
|
||||||
class AnyAfterFilter < Base
|
class AnyAfterFilter < Base
|
||||||
properties do
|
properties do
|
||||||
description "Identifies usage of `any?` calls that follow filters"
|
description "Identifies usage of `any?` calls that follow filters"
|
||||||
filter_names : Array(String) = %w(select reject)
|
filter_names %w(select reject)
|
||||||
end
|
end
|
||||||
|
|
||||||
ANY_NAME = "any?"
|
ANY_NAME = "any?"
|
||||||
|
|
|
@ -45,7 +45,7 @@ module Ameba::Rule::Performance
|
||||||
# All of those have bang method variants returning `self`
|
# All of those have bang method variants returning `self`
|
||||||
# and are not modifying the receiver type (like `compact` does),
|
# and are not modifying the receiver type (like `compact` does),
|
||||||
# thus are safe to switch to the bang variant.
|
# 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
|
end
|
||||||
|
|
||||||
# All these methods are allocating a new object
|
# All these methods are allocating a new object
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Ameba::Rule::Performance
|
||||||
class FirstLastAfterFilter < Base
|
class FirstLastAfterFilter < Base
|
||||||
properties do
|
properties do
|
||||||
description "Identifies usage of `first/last/first?/last?` calls that follow filters"
|
description "Identifies usage of `first/last/first?/last?` calls that follow filters"
|
||||||
filter_names : Array(String) = %w(select)
|
filter_names %w(select)
|
||||||
end
|
end
|
||||||
|
|
||||||
CALL_NAMES = %w(first last first? last?)
|
CALL_NAMES = %w(first last first? last?)
|
||||||
|
|
|
@ -35,7 +35,7 @@ module Ameba::Rule::Performance
|
||||||
class SizeAfterFilter < Base
|
class SizeAfterFilter < Base
|
||||||
properties do
|
properties do
|
||||||
description "Identifies usage of `size` calls that follow filter"
|
description "Identifies usage of `size` calls that follow filter"
|
||||||
filter_names : Array(String) = %w(select reject)
|
filter_names %w(select reject)
|
||||||
end
|
end
|
||||||
|
|
||||||
SIZE_NAME = "size"
|
SIZE_NAME = "size"
|
||||||
|
|
|
@ -41,7 +41,7 @@ module Ameba::Rule::Style
|
||||||
class IsAFilter < Base
|
class IsAFilter < Base
|
||||||
properties do
|
properties do
|
||||||
description "Identifies usage of `is_a?/nil?` calls within filters"
|
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
|
end
|
||||||
|
|
||||||
MSG = "Use `%s` instead of `%s`"
|
MSG = "Use `%s` instead of `%s`"
|
||||||
|
|
Loading…
Reference in a new issue