mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Move constant definitions after properties
call
This commit is contained in:
parent
66a4b283d4
commit
5e58a60ade
4 changed files with 14 additions and 14 deletions
|
@ -25,14 +25,14 @@ module Ameba::Rule::Performance
|
|||
# - reject
|
||||
# ```
|
||||
struct AnyAfterFilter < Base
|
||||
ANY_NAME = "any?"
|
||||
MSG = "Use `any? {...}` instead of `%s {...}.any?`"
|
||||
|
||||
properties do
|
||||
filter_names : Array(String) = %w(select reject)
|
||||
description "Identifies usage of `any?` calls that follow filters."
|
||||
end
|
||||
|
||||
ANY_NAME = "any?"
|
||||
MSG = "Use `any? {...}` instead of `%s {...}.any?`"
|
||||
|
||||
def test(source, node : Crystal::Call)
|
||||
return unless node.name == ANY_NAME && (obj = node.obj)
|
||||
return unless obj.is_a?(Crystal::Call) && obj.block && node.block.nil?
|
||||
|
|
|
@ -24,15 +24,15 @@ module Ameba::Rule::Performance
|
|||
# - select
|
||||
# ```
|
||||
struct FirstLastAfterFilter < Base
|
||||
CALL_NAMES = %w(first last first? last?)
|
||||
MSG = "Use `find {...}` instead of `%s {...}.%s`"
|
||||
MSG_REVERSE = "Use `reverse_each.find {...}` instead of `%s {...}.%s`"
|
||||
|
||||
properties do
|
||||
filter_names : Array(String) = %w(select)
|
||||
description "Identifies usage of `first/last/first?/last?` calls that follow filters."
|
||||
end
|
||||
|
||||
CALL_NAMES = %w(first last first? last?)
|
||||
MSG = "Use `find {...}` instead of `%s {...}.%s`"
|
||||
MSG_REVERSE = "Use `reverse_each.find {...}` instead of `%s {...}.%s`"
|
||||
|
||||
def test(source)
|
||||
AST::NodeVisitor.new self, source, skip: [
|
||||
Crystal::Macro,
|
||||
|
|
|
@ -20,14 +20,14 @@ module Ameba::Rule::Performance
|
|||
# Enabled: true
|
||||
# ```
|
||||
struct JoinAfterMap < Base
|
||||
MAP_NAME = "map"
|
||||
JOIN_NAME = "join"
|
||||
MSG = "Use `join(separator) {...}` instead of `map {...}.join(separator)`"
|
||||
|
||||
properties do
|
||||
description "Identifies usage of `join` calls that follow `map`."
|
||||
end
|
||||
|
||||
MAP_NAME = "map"
|
||||
JOIN_NAME = "join"
|
||||
MSG = "Use `join(separator) {...}` instead of `map {...}.join(separator)`"
|
||||
|
||||
def test(source)
|
||||
AST::NodeVisitor.new self, source, skip: [
|
||||
Crystal::Macro,
|
||||
|
|
|
@ -31,14 +31,14 @@ module Ameba::Rule::Performance
|
|||
# - reject
|
||||
# ```
|
||||
struct SizeAfterFilter < Base
|
||||
SIZE_NAME = "size"
|
||||
MSG = "Use `count {...}` instead of `%s {...}.size`."
|
||||
|
||||
properties do
|
||||
filter_names : Array(String) = %w(select reject)
|
||||
description "Identifies usage of `size` calls that follow filter"
|
||||
end
|
||||
|
||||
SIZE_NAME = "size"
|
||||
MSG = "Use `count {...}` instead of `%s {...}.size`."
|
||||
|
||||
def test(source)
|
||||
AST::NodeVisitor.new self, source, skip: [
|
||||
Crystal::Macro,
|
||||
|
|
Loading…
Reference in a new issue