Skip to content

Commit

Permalink
Fix false positive for UnsafeToAtom
Browse files Browse the repository at this point in the history
Refs #1148
  • Loading branch information
rrrene committed Sep 23, 2024
1 parent 3a6a0c0 commit 175d0ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/credo/check/warning/unsafe_to_atom.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ defmodule Credo.Check.Warning.UnsafeToAtom do
{nil, issues}
end

# module.unquote(:"some_atom")
defp traverse({{:., _, [_, :unquote]}, _, [_ | _] = _args}, issues, _) do
{nil, issues}
end

defp traverse(
{:|>, _meta1, [_lhs, {{:., _meta2, call}, meta, args}]} = ast,
issues,
Expand Down
2 changes: 2 additions & 0 deletions test/credo/check/warning/unsafe_to_atom_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ defmodule Credo.Check.Warning.UnsafeToAtomTest do
def convert_erlang_binary(parameter) do
:erlang.binary_to_existing_atom(parameter, :utf8)
unquote(context).unquote(:"get_#{type}_by")(id: id)
end
for n <- 1..4 do
Expand Down

0 comments on commit 175d0ab

Please sign in to comment.