Skip to content

Commit

Permalink
Typing/MacroCallArgumentTypeRestriction default_value should be false…
Browse files Browse the repository at this point in the history
… ootb
  • Loading branch information
nobodywasishere committed Jan 9, 2025
1 parent afb7914 commit b0a924f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ameba/rule/typing/macro_call_argument_type_restriction.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Ameba::Rule::Typing
# ```
# Typing/MacroCallArgumentTypeRestriction:
# Enabled: false
# DefaultValue: true
# DefaultValue: false
# MacroNames:
# - getter
# - getter?
Expand All @@ -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!
Expand Down

0 comments on commit b0a924f

Please sign in to comment.