From b0a924f3383c99520d5277faba035723902428f2 Mon Sep 17 00:00:00 2001 From: Margret Riegert Date: Thu, 9 Jan 2025 10:07:17 -0500 Subject: [PATCH] Typing/MacroCallArgumentTypeRestriction default_value should be false ootb --- ...macro_call_argument_type_restriction_spec.cr | 17 +++++++++-------- .../macro_call_argument_type_restriction.cr | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/spec/ameba/rule/typing/macro_call_argument_type_restriction_spec.cr b/spec/ameba/rule/typing/macro_call_argument_type_restriction_spec.cr index 84bbae51a..47a8f92e9 100644 --- a/spec/ameba/rule/typing/macro_call_argument_type_restriction_spec.cr +++ b/spec/ameba/rule/typing/macro_call_argument_type_restriction_spec.cr @@ -34,33 +34,34 @@ module Ameba::Rule::Typing CRYSTAL end - it "fails if a record call arg doesn't have a type restriction" do - expect_issue subject, <<-CRYSTAL + it "passes if a record call arg with a default value doesn't have a type restriction" do + expect_no_issues subject, <<-CRYSTAL record Task, cmd : String, args = %[] - # ^^^^ error: Argument should have a type restriction CRYSTAL end context "properties" do context "#default_value" do rule = MacroCallArgumentTypeRestriction.new - rule.default_value = false + rule.default_value = true - it "passes if a macro call arg with a default value doesn't have a type restriction" do - expect_no_issues rule, <<-CRYSTAL + it "fails if a macro call arg with a default value doesn't have a type restriction" do + expect_issue rule, <<-CRYSTAL class Greeter getter name = "Kenobi" + # ^^^^ error: Argument should have a type restriction end CRYSTAL end - it "passes if a record call arg with default value doesn't have a type restriction" do - expect_no_issues rule, <<-CRYSTAL + it "fails if a record call arg with default value doesn't have a type restriction" do + expect_issue rule, <<-CRYSTAL record Task, cmd : String, args = %[] + # ^^^^ error: Argument should have a type restriction CRYSTAL end end diff --git a/src/ameba/rule/typing/macro_call_argument_type_restriction.cr b/src/ameba/rule/typing/macro_call_argument_type_restriction.cr index 68af45eeb..fab1e2d82 100644 --- a/src/ameba/rule/typing/macro_call_argument_type_restriction.cr +++ b/src/ameba/rule/typing/macro_call_argument_type_restriction.cr @@ -38,7 +38,7 @@ module Ameba::Rule::Typing # ``` # Typing/MacroCallArgumentTypeRestriction: # Enabled: false - # DefaultValue: true + # DefaultValue: false # MacroNames: # - getter # - getter? @@ -65,7 +65,7 @@ module Ameba::Rule::Typing since_version "1.7.0" description "Recommends that call arguments to certain macros have type restrictions" enabled false - default_value true + default_value false macro_names %w[ getter getter? getter! class_getter class_getter? class_getter! setter setter? setter! class_setter class_setter? class_setter!