Merge pull request #325 from FnControlOption/unless_else

Add autocorrect for `Style/UnlessElse`
This commit is contained in:
Sijawusz Pur Rahnama 2022-12-22 21:43:49 +01:00 committed by GitHub
commit 2d9e328d97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 151 additions and 18 deletions

View file

@ -13,7 +13,7 @@ module Ameba::Rule::Style
end
it "fails if unless has else" do
expect_issue subject, <<-CRYSTAL
source = expect_issue subject, <<-CRYSTAL
unless something
# ^^^^^^^^^^^^^^ error: Favour if over unless with else
:one
@ -21,6 +21,14 @@ module Ameba::Rule::Style
:two
end
CRYSTAL
expect_correction source, <<-CRYSTAL
if something
:two
else
:one
end
CRYSTAL
end
end
end