Skip to content

Commit

Permalink
better name for a helper
Browse files Browse the repository at this point in the history
  • Loading branch information
novaugust committed Sep 18, 2023
1 parent 68b6275 commit e49e78d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/style/single_node.ex
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ defmodule Styler.Style.SingleNode do
do: {reverse, r_meta, [lhs, rhs]}

defp style(trivial_case(head, {_, _, [true]}, do_body, {_, _, [false]}, else_body)),
do: if_ast(head, do_body, else_body)
do: styled_if(head, do_body, else_body)

defp style(trivial_case(head, {_, _, [false]}, else_body, {_, _, [true]}, do_body)),
do: if_ast(head, do_body, else_body)
do: styled_if(head, do_body, else_body)

defp style(trivial_case(head, {_, _, [true]}, do_body, {:_, _, _}, else_body)),
do: if_ast(head, do_body, else_body)
do: styled_if(head, do_body, else_body)

# `Credo.Check.Refactor.CondStatements`
# This also detects strings and lists...
defp style({:cond, _, [[{_, [{:->, _, [[expr], do_body]}, {:->, _, [[{:__block__, _, [truthy]}], else_body]}]}]]})
when is_atom(truthy) and truthy not in [nil, false] do
if_ast(expr, do_body, else_body)
styled_if(expr, do_body, else_body)
end

# Credo.Check.Readability.WithSingleClause
Expand Down Expand Up @@ -256,7 +256,7 @@ defmodule Styler.Style.SingleNode do
Style.update_all_meta(a, fn _ -> nil end) == Style.update_all_meta(b, fn _ -> nil end)
end

defp if_ast(head, do_body, else_body) do
defp styled_if(head, do_body, else_body) do
{_, meta, _} = head
line = meta[:line]
# @TODO figure out appropriate line meta for `else` and `if->end->line`
Expand Down

0 comments on commit e49e78d

Please sign in to comment.