Skip to content

Commit

Permalink
simplify cond
Browse files Browse the repository at this point in the history
  • Loading branch information
novaugust committed Nov 13, 2023
1 parent 3aece4a commit fe2d190
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/style/blocks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ defmodule Styler.Style.Blocks do

{reversed_clauses, do_body} =
cond do
# Credo.Check.Refactor.RedundantWithClauseResult
Enum.empty?(postroll) and Enum.empty?(elses) and nodes_equivalent?(lhs, do_body) ->
{rest, rhs}

# Put the postroll into the body
Enum.any?(postroll) ->
{_, do_body_meta, _} = do_body
do_body = {:__block__, do_body_meta, Enum.reverse(postroll, [do_body])}
{reversed_clauses, do_body}

# Credo.Check.Refactor.RedundantWithClauseResult
Enum.empty?(elses) and nodes_equivalent?(lhs, do_body) ->
{rest, rhs}

# no change
true ->
{reversed_clauses, do_body}
end
Expand Down

0 comments on commit fe2d190

Please sign in to comment.