Merge pull request #417 from crystal-ameba/fix-issue-400

Fix false positive with dynamic literals in `Lint/LiteralsComparison`
This commit is contained in:
Sijawusz Pur Rahnama 2023-11-09 09:09:54 +01:00 committed by GitHub
commit 3f1e925e07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -6,6 +6,8 @@ module Ameba::Rule::Lint
describe LiteralsComparison do
it "passes for valid cases" do
expect_no_issues subject, <<-CRYSTAL
{start.year, start.month} == {stop.year, stop.month}
["foo"] === [foo]
"foo" == foo
"foo" != foo
foo == "foo"
@ -15,8 +17,8 @@ module Ameba::Rule::Lint
it "reports if there is a dynamic comparison possibly evaluating to the same" do
expect_issue subject, <<-CRYSTAL
[foo] === ["foo"]
# ^^^^^^^^^^^^^^^ error: Comparison most likely evaluates to the same
[foo] === [foo]
# ^^^^^^^^^^^^^ error: Comparison most likely evaluates to the same
CRYSTAL
end