From 5e58a60ade0bb708f3086f405309b728c3f9deda Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sun, 17 Jan 2021 17:39:32 +0100 Subject: [PATCH] Move constant definitions after `properties` call --- src/ameba/rule/performance/any_after_filter.cr | 6 +++--- src/ameba/rule/performance/first_last_after_filter.cr | 8 ++++---- src/ameba/rule/performance/join_after_map.cr | 8 ++++---- src/ameba/rule/performance/size_after_filter.cr | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ameba/rule/performance/any_after_filter.cr b/src/ameba/rule/performance/any_after_filter.cr index c6dbc2b7..da9662ee 100644 --- a/src/ameba/rule/performance/any_after_filter.cr +++ b/src/ameba/rule/performance/any_after_filter.cr @@ -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? diff --git a/src/ameba/rule/performance/first_last_after_filter.cr b/src/ameba/rule/performance/first_last_after_filter.cr index ced0a1e3..4b251ad8 100644 --- a/src/ameba/rule/performance/first_last_after_filter.cr +++ b/src/ameba/rule/performance/first_last_after_filter.cr @@ -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, diff --git a/src/ameba/rule/performance/join_after_map.cr b/src/ameba/rule/performance/join_after_map.cr index 5b374b67..3cd74263 100644 --- a/src/ameba/rule/performance/join_after_map.cr +++ b/src/ameba/rule/performance/join_after_map.cr @@ -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, diff --git a/src/ameba/rule/performance/size_after_filter.cr b/src/ameba/rule/performance/size_after_filter.cr index 0339f998..e825a8f7 100644 --- a/src/ameba/rule/performance/size_after_filter.cr +++ b/src/ameba/rule/performance/size_after_filter.cr @@ -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,