mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
2d9e328d97
Add autocorrect for `Style/UnlessElse`
34 lines
670 B
Crystal
34 lines
670 B
Crystal
require "../../../spec_helper"
|
|
|
|
module Ameba::Rule::Style
|
|
subject = UnlessElse.new
|
|
|
|
describe UnlessElse do
|
|
it "passes if unless hasn't else" do
|
|
expect_no_issues subject, <<-CRYSTAL
|
|
unless something
|
|
:ok
|
|
end
|
|
CRYSTAL
|
|
end
|
|
|
|
it "fails if unless has else" do
|
|
source = expect_issue subject, <<-CRYSTAL
|
|
unless something
|
|
# ^^^^^^^^^^^^^^ error: Favour if over unless with else
|
|
:one
|
|
else
|
|
:two
|
|
end
|
|
CRYSTAL
|
|
|
|
expect_correction source, <<-CRYSTAL
|
|
if something
|
|
:two
|
|
else
|
|
:one
|
|
end
|
|
CRYSTAL
|
|
end
|
|
end
|
|
end
|