mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Refactor ternary handling in Style/RedundantParentheses
rule
This commit is contained in:
parent
3340613a6a
commit
935296b041
2 changed files with 30 additions and 15 deletions
|
@ -55,16 +55,22 @@ module Ameba::Rule::Style
|
|||
rule.exclude_ternary = false
|
||||
|
||||
expect_issue rule, <<-CRYSTAL
|
||||
(foo > bar) ? true : false
|
||||
# ^^^^^^^^^ error: Redundant parentheses
|
||||
(foo.empty?) ? true : false
|
||||
# ^^^^^^^^^^ error: Redundant parentheses
|
||||
CRYSTAL
|
||||
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
(foo && bar) ? true : false
|
||||
CRYSTAL
|
||||
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
(foo || bar) ? true : false
|
||||
(foo = @foo) ? true : false
|
||||
foo == 42 ? true : false
|
||||
(foo = 42) ? true : false
|
||||
(foo > 42) ? true : false
|
||||
(foo >= 42) ? true : false
|
||||
(3 >= foo >= 42) ? true : false
|
||||
(3.in? 0..42) ? true : false
|
||||
(yield 42) ? true : false
|
||||
(foo rescue 42) ? true : false
|
||||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue