Skip to content

Commit 435bb61

Browse files
committed
refactor: convert nested if to cond in strip_action_prefix for credo compliance
1 parent 5bc6260 commit 435bb61

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/phoenix/session_process.ex

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,11 +1599,17 @@ defmodule Phoenix.SessionProcess do
15991599

16001600
# Strip action prefix before passing to reducer if reducer has a prefix
16011601
defp strip_action_prefix(action, reducer_prefix, skip_strip \\ false) do
1602-
if skip_strip do
1603-
# When using meta.reducers for explicit targeting, don't strip prefix
1604-
action
1605-
else
1606-
if reducer_prefix && reducer_prefix != "" do
1602+
# When using meta.reducers for explicit targeting, don't strip prefix
1603+
cond do
1604+
skip_strip ->
1605+
action
1606+
1607+
is_nil(reducer_prefix) or reducer_prefix == "" ->
1608+
# No prefix or catch-all reducer, pass unchanged
1609+
action
1610+
1611+
true ->
1612+
# Try to strip matching prefix
16071613
case String.split(action.type, ".", parts: 2) do
16081614
[^reducer_prefix, local_type] ->
16091615
%{action | type: local_type}
@@ -1612,10 +1618,6 @@ defmodule Phoenix.SessionProcess do
16121618
# Prefix doesn't match, keep as-is
16131619
action
16141620
end
1615-
else
1616-
# No prefix or catch-all reducer, pass unchanged
1617-
action
1618-
end
16191621
end
16201622
end
16211623

0 commit comments

Comments
 (0)