diff --git a/lib/style/single_node.ex b/lib/style/single_node.ex index ef4ec768..5fd9b255 100644 --- a/lib/style/single_node.ex +++ b/lib/style/single_node.ex @@ -214,8 +214,8 @@ defmodule Styler.Style.SingleNode do # IF / UNLESS & NEGATION REWRITES # Credo.Check.Refactor.UnlessWithElse - defp style({:unless, m, [{_, hm, _} = head, [{do_, do_body}, {else_, else_body}]]}), - do: style({:if, m, [{:!, hm, [head]}, [{do_, else_body}, {else_, do_body}]]}) + defp style({:unless, m, [{_, hm, _} = head, [_, _] = do_else]}), + do: style({:if, m, [{:!, hm, [head]}, do_else]}) # Credo.Check.Refactor.NegatedConditionsInUnless defp style({:unless, m, [{negator, _, [expr]}, [{do_, do_body}]]}) when negator in [:!, :not], diff --git a/test/style/single_node_test.exs b/test/style/single_node_test.exs index e9d60b7a..18fc9746 100644 --- a/test/style/single_node_test.exs +++ b/test/style/single_node_test.exs @@ -533,9 +533,9 @@ defmodule Styler.Style.SingleNodeTest do """, """ if a do - c - else b + else + c end """ ) @@ -551,9 +551,9 @@ defmodule Styler.Style.SingleNodeTest do """, """ if a do - b - else c + else + b end """ ) @@ -636,9 +636,9 @@ defmodule Styler.Style.SingleNodeTest do """, """ if true do - b - else a + else + b end """ )