Skip to content

Commit cb05cd6

Browse files
committed
refactor: ignoring variables named with reserved keywords
1 parent 0b475a1 commit cb05cd6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/refactorex/dataflow.ex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ defmodule Refactorex.Dataflow do
3636
{id, _, [{:when, _, [header, body]}]} when id in ~w(defguard defguardp)a ->
3737
analyze_sealed_scope(dataflow, header, body)
3838

39+
{:test, _, [_, {:%{}, _, setup}, scope]} ->
40+
analyze_sealed_scope(dataflow, setup, scope)
41+
42+
{:test, _, [_ | _] = scope} ->
43+
analyze_sealed_scope(dataflow, scope)
44+
3945
{id, _, [condition, clauses]} when id in ~w(if unless)a ->
4046
%__MODULE__{}
4147
|> recursive_analyze(condition)
@@ -55,10 +61,10 @@ defmodule Refactorex.Dataflow do
5561
|> recursive_analyze(catches)
5662
|> close_scope(dataflow)
5763

58-
{:case, _, expression_and_clauses} ->
64+
{:case, _, [_ | _] = expression_and_clauses} ->
5965
analyze_compound_scope(dataflow, expression_and_clauses, [])
6066

61-
{:with, _, children} ->
67+
{:with, _, [_ | _] = children} ->
6268
{
6369
statements,
6470
[[body | catches]]
@@ -68,19 +74,13 @@ defmodule Refactorex.Dataflow do
6874
|> analyze_compound_scope(statements, body)
6975
|> recursive_analyze(catches)
7076

71-
{:for, _, children} ->
77+
{:for, _, [_ | _] = children} ->
7278
{statements, body} = Enum.split_while(children, &match?({_, _, _}, &1))
7379
analyze_compound_scope(dataflow, statements, body)
7480

7581
{{:__block__, _, [:do]}, block} ->
7682
analyze_scope(dataflow, block)
7783

78-
{:test, _, [_, {:%{}, _, setup}, scope]} ->
79-
analyze_sealed_scope(dataflow, setup, scope)
80-
81-
{:test, _, scope} ->
82-
analyze_sealed_scope(dataflow, scope)
83-
8484
{:->, _, [[{:when, _, [left, guard]}], right]} ->
8585
analyze_scope(dataflow, left, [guard, right])
8686

0 commit comments

Comments
 (0)