Skip to content
Permalink
Browse files

Fix bug in Scope

  • Loading branch information
rrrene committed Jan 12, 2020
1 parent 895f4aa commit d77eab696f7a7e485ba6ef3c1a7cc41ccd834fba
Showing with 16 additions and 2 deletions.
  1. +14 −2 lib/credo/code/module.ex
  2. +2 −0 test/credo/code/module_test.exs
@@ -244,11 +244,23 @@ defmodule Credo.Code.Module do
{ast, modules}
end

@doc "Returns the name of a module's given ast node."
@doc """
Returns the name of a module's given ast node.
"""
def name(ast)

def name({:defmodule, _, [{:__aliases__, _, name_list}, _]}) do
Enum.join(name_list, ".")
name_list
|> Enum.map(&name/1)
|> Enum.join(".")
end

def name({:__MODULE__, _meta, nil}), do: "__MODULE__"

def name(atom) when is_atom(atom), do: atom

def name(string) when is_binary(string), do: string

def name(_), do: "<Unknown Module Name>"

# TODO: write unit test
@@ -3,6 +3,8 @@ defmodule Credo.Code.ModuleTest do

alias Credo.Code.Module

doctest Credo.Code.Module

#
# attribute
#

0 comments on commit d77eab6

Please sign in to comment.
You can’t perform that action at this time.