Skip to content

Commit

Permalink
Fix Name.full for function calls
Browse files Browse the repository at this point in the history
Fixes #637
  • Loading branch information
René Föhring committed Mar 7, 2019
1 parent 8d4f68b commit 12610b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/credo/code/name.ex
Expand Up @@ -77,8 +77,10 @@ defmodule Credo.Code.Name do
"@#{name}"
end

def full({:unquote, _, [{name, _, nil}]}) when is_atom(name) do
"unquote(#{name})"
def full({name, _, arguments}) when is_atom(name) and is_list(arguments) do
arg_list = arguments |> Enum.map(&full/1) |> Enum.join(", ")

"#{full(name)}(#{arg_list})"
end

def parts_count(module_name) do
Expand Down
10 changes: 10 additions & 0 deletions test/credo/code/name_test.exs
Expand Up @@ -95,6 +95,16 @@ defmodule Credo.Code.NameTest do
assert mod_list |> Name.full() == expected
end

test "returns full name for a function call" do
mod_list = [
{:my_fun, [line: 62], [{:param1, [line: 62], nil}, {:param2, [line: 62], nil}]},
:Module
]

expected = "my_fun(param1, param2).Module"
assert mod_list |> Name.full() == expected
end

#
# parts_count
#
Expand Down

0 comments on commit 12610b9

Please sign in to comment.