Skip to content

Commit

Permalink
Remove alias to Credo.Code
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Jul 29, 2022
1 parent 1c711c5 commit 495683d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/credo/code/module.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ defmodule Credo.Code.Module do
functions or module attributes.
"""

alias Credo.Code
alias Credo.Code.Block
alias Credo.Code.Name

Expand Down Expand Up @@ -76,7 +75,7 @@ defmodule Credo.Code.Module do

@doc "Reads an attribute from a module's `ast`"
def attribute(ast, attr_name) do
case Code.postwalk(ast, &find_attribute(&1, &2, attr_name), {:error, nil}) do
case Credo.Code.postwalk(ast, &find_attribute(&1, &2, attr_name), {:error, nil}) do
{:ok, value} ->
value

Expand Down Expand Up @@ -104,14 +103,14 @@ defmodule Credo.Code.Module do

def def_count({:defmodule, _, _arguments} = ast) do
ast
|> Code.postwalk(&collect_defs/2)
|> Credo.Code.postwalk(&collect_defs/2)
|> Enum.count()
end

def defs(nil), do: []

def defs({:defmodule, _, _arguments} = ast) do
Code.postwalk(ast, &collect_defs/2)
Credo.Code.postwalk(ast, &collect_defs/2)
end

@doc "Returns the arity of the given function definition `ast`"
Expand Down Expand Up @@ -168,7 +167,7 @@ defmodule Credo.Code.Module do

def def_names({:defmodule, _, _arguments} = ast) do
ast
|> Code.postwalk(&collect_defs/2)
|> Credo.Code.postwalk(&collect_defs/2)
|> Enum.map(&def_name/1)
|> Enum.uniq()
end
Expand All @@ -178,7 +177,7 @@ defmodule Credo.Code.Module do

def def_names_with_op({:defmodule, _, _arguments} = ast) do
ast
|> Code.postwalk(&collect_defs/2)
|> Credo.Code.postwalk(&collect_defs/2)
|> Enum.map(&def_name_with_op/1)
|> Enum.uniq()
end
Expand All @@ -188,7 +187,7 @@ defmodule Credo.Code.Module do

def def_names_with_op({:defmodule, _, _arguments} = ast, arity) do
ast
|> Code.postwalk(&collect_defs/2)
|> Credo.Code.postwalk(&collect_defs/2)
|> Enum.map(&def_name_with_op(&1, arity))
|> Enum.reject(&is_nil/1)
|> Enum.uniq()
Expand All @@ -213,7 +212,7 @@ defmodule Credo.Code.Module do
@doc "Returns the list of modules used in a given module source code."
def modules({:defmodule, _, _arguments} = ast) do
ast
|> Code.postwalk(&find_dependent_modules/2)
|> Credo.Code.postwalk(&find_dependent_modules/2)
|> Enum.uniq()
end

Expand Down

0 comments on commit 495683d

Please sign in to comment.