Skip to content

Commit

Permalink
Updates from review
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodywasishere committed Feb 5, 2025
1 parent 6e4d910 commit 2ce175a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
14 changes: 7 additions & 7 deletions spec/ameba/rule/lint/unused_comparison_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,49 @@ module Ameba::Rule::Lint
CRYSTAL
end

it "fails for top-level `==` operator" do
it "fails if a comparison operation with `==` is unused" do
expect_issue subject, <<-CRYSTAL
foo == 2
# ^^^^^^ error: Comparison operation is unused
CRYSTAL
end

it "fails for top-level `!=` operator" do
it "fails if a comparison operation with `!=` is unused" do
expect_issue subject, <<-CRYSTAL
foo != 2
# ^^^^^^ error: Comparison operation is unused
CRYSTAL
end

it "fails for top-level `<` operator" do
it "fails if a comparison operation with `<` is unused" do
expect_issue subject, <<-CRYSTAL
foo < 2
# ^^^^^ error: Comparison operation is unused
CRYSTAL
end

it "fails for top-level `<=` operator" do
it "fails if a comparison operation with `<=` is unused" do
expect_issue subject, <<-CRYSTAL
foo <= 2
# ^^^^^^ error: Comparison operation is unused
CRYSTAL
end

it "fails for top-level `>` operator" do
it "fails if a comparison operation with `>` is unused" do
expect_issue subject, <<-CRYSTAL
foo > 2
# ^^^^^ error: Comparison operation is unused
CRYSTAL
end

it "fails for top-level `>=` operator" do
it "fails if a comparison operation with `>=` is unused" do
expect_issue subject, <<-CRYSTAL
foo >= 2
# ^^^^^^ error: Comparison operation is unused
CRYSTAL
end

it "fails for top-level `<=>` operator" do
it "fails if a comparison operation with `<=>` is unused" do
expect_issue subject, <<-CRYSTAL
foo <=> 2
# ^^^^^^^ error: Comparison operation is unused
Expand Down
4 changes: 1 addition & 3 deletions spec/ameba/rule/lint/unused_generic_or_union_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ module Ameba::Rule::Lint
end

it "passes for an unused path" do
expect_no_issues subject, <<-CRYSTAL
Foo
CRYSTAL
expect_no_issues subject, "Foo"
end

it "passes if a generic is used for a parameter type restriction" do
Expand Down
28 changes: 14 additions & 14 deletions spec/ameba/rule/lint/unused_literal_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ module Ameba::Rule::Lint
subject = UnusedLiteral.new

it "passes if a number literal is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
expect_no_issues subject, <<-CRYSTAL
a = 1
CRYSTAL
end

it "passes if a char literal is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
expect_no_issues subject, <<-CRYSTAL
c = '\t'
CRYSTAL
end

it "passes if a string literal is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
b = "foo"
g = "bar \#{baz}"
g = "bar #{baz}"
CRYSTAL
end

it "passes if a heredoc is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
expect_no_issues subject, <<-CRYSTAL
h = <<-HEREDOC
foo
HEREDOC
CRYSTAL
end

it "passes if a symbol literal is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
expect_no_issues subject, <<-CRYSTAL
c = :foo
CRYSTAL
end

it "passes if a named tuple literal is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
expect_no_issues subject, <<-CRYSTAL
d = {foo: 1, bar: 2}
CRYSTAL
end

it "passes if an array literal is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
expect_no_issues subject, <<-CRYSTAL
e = [10_f32, 20_f32, 30_f32]
CRYSTAL
end

it "passes if a proc literal is used to assign" do
expect_no_issues subject, <<-'CRYSTAL'
expect_no_issues subject, <<-CRYSTAL
f = -> { }
CRYSTAL
end
Expand Down Expand Up @@ -123,10 +123,10 @@ module Ameba::Rule::Lint
end

it "fails if a string literal is top-level" do
expect_issue subject, <<-CRYSTAL
expect_issue subject, <<-'CRYSTAL'
"hello world"
# ^^^^^^^^^^^ error: Literal value is not used
"interp \#{string}"
"interp #{string}"
# ^^^^^^^^^^^^^^^^ error: Literal value is not used
CRYSTAL
end
Expand Down Expand Up @@ -195,11 +195,11 @@ module Ameba::Rule::Lint
end

it "fails if a string literal is in void of method body" do
expect_issue subject, <<-CRYSTAL
expect_issue subject, <<-'CRYSTAL'
def foo
"hello world"
# ^^^^^^^^^^^^^ error: Literal value is not used
"interp \#{string}"
"interp #{string}"
# ^^^^^^^^^^^^^^^^^^ error: Literal value is not used
return
end
Expand Down Expand Up @@ -291,11 +291,11 @@ module Ameba::Rule::Lint
end

it "fails if a string literal is in void of if statement body" do
expect_issue subject, <<-CRYSTAL
expect_issue subject, <<-'CRYSTAL'
if true
"hello world"
# ^^^^^^^^^^^^^ error: Literal value is not used
"interp \#{string}"
"interp #{string}"
# ^^^^^^^^^^^^^^^^^^ error: Literal value is not used
nil
end
Expand Down

0 comments on commit 2ce175a

Please sign in to comment.