Skip to content

Commit

Permalink
Use variant of heredoc without interpolation wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Jan 30, 2025
1 parent 6b19c0f commit cd144e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions spec/ameba/rule/lint/unused_literal_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module Ameba::Rule::Lint
subject = UnusedLiteral.new

it "passes if literals are used to assign" do
expect_no_issues subject, <<-CRYSTAL
expect_no_issues subject, <<-'CRYSTAL'
a = 1
b = "string"
g = "interp \#{string}"
g = "interp #{string}"
h = <<-HEREDOC
this is a heredoc
HEREDOC
Expand Down Expand Up @@ -293,22 +293,22 @@ module Ameba::Rule::Lint
# Locations for Regex literals were added in Crystal v1.15.0
{% if compare_versions(Crystal::VERSION, "1.15.0") >= 0 %}
it "fails if a regex literal is unused" do
expect_issue subject, <<-CRYSTAL
expect_issue subject, <<-'CRYSTAL'
a = /hello world/
/goodnight moon/
# ^^^^^^^^^^^^^^ error: Literal value is not used
b = /goodnight moon, \#{a}/
/goodnight moon, \#{a}/
b = /goodnight moon, #{a}/
/goodnight moon, #{a}/
# ^^^^^^^^^^^^^^^^^^^^ error: Literal value is not used
CRYSTAL
end
{% else %}
it "passes if a regex literal is unused" do
expect_no_issues subject, <<-CRYSTAL
expect_no_issues subject, <<-'CRYSTAL'
a = /hello world/
/goodnight moon/
b = /goodnight moon, \#{a}/
/goodnight moon, \#{a}/
b = /goodnight moon, #{a}/
/goodnight moon, #{a}/
CRYSTAL
end
{% end %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ module Ameba::Rule::Typing
rule = MethodParameterTypeRestriction.new
rule.default_value = true

expect_issue rule, <<-CRYSTAL
expect_issue rule, <<-'CRYSTAL'
def hello(a = "world")
# ^ error: Method parameter should have a type restriction
"hello \#{a}"
"hello #{a}"
end
CRYSTAL
end
Expand All @@ -187,10 +187,10 @@ module Ameba::Rule::Typing
end

it "fails if a block parameter with a name doesn't have a type restriction" do
expect_issue rule, <<-CRYSTAL
expect_issue rule, <<-'CRYSTAL'
def hello(&a)
# ^ error: Method parameter should have a type restriction
"hello, \#{a.call}"
"hello, #{a.call}"
end
CRYSTAL
end
Expand Down

0 comments on commit cd144e9

Please sign in to comment.