fix(style): properly tokenize in RedundantBegin rule

This commit is contained in:
Vitalii Elenhaupt 2022-10-14 21:09:30 +03:00
parent 80532da357
commit 60bf8e13ce
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
2 changed files with 22 additions and 1 deletions

View file

@ -241,6 +241,27 @@ module Ameba::Rule::Style
CRYSTAL
end
it "fails if there is a redundant block with string with inner quotes" do
source = expect_issue subject, <<-CRYSTAL
def method
begin
# ^^^^^ error: Redundant `begin` block detected
"'"
rescue
end
end
CRYSTAL
expect_correction source, <<-CRYSTAL
def method
#{trailing_whitespace}
"'"
rescue
#{trailing_whitespace}
end
CRYSTAL
end
it "fails if there is top level redundant block in a method" do
source = expect_issue subject, <<-CRYSTAL
def method