Skip to content

Commit

Permalink
fix: fixes issue #696
Browse files Browse the repository at this point in the history
  • Loading branch information
ityonemo committed Aug 31, 2019
1 parent 13f2899 commit f7076dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/credo/check/readability/module_attribute_names.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ defmodule Credo.Check.Readability.ModuleAttributeNames do
Credo.Code.prewalk(source_file, &traverse(&1, &2, issue_meta))
end

# ignore non-alphanumeric @ ASTs, for when you're redefining the @ macro.
defp traverse({:@, _meta, [{:{}, _, _}]} = ast, issues, _) do
{ast, issues}
end

defp traverse(
{:@, _meta, [{name, meta, _arguments}]} = ast,
issues,
Expand Down
14 changes: 14 additions & 0 deletions test/credo/check/readability/module_attribute_names_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ defmodule Credo.Check.Readability.ModuleAttributeNamesTest do
|> refute_issues(@described_check)
end

test "it should NOT fail when redefining the @ operator" do
"""
defmodule CredoSampleModule do
defmacro @{_, _, _} do
quote do
# some_code_here
end
end
end
"""
|> to_source_file
|> refute_issues(@described_check)
end

#
# cases raising issues
#
Expand Down

0 comments on commit f7076dd

Please sign in to comment.