Skip to content

Commit

Permalink
Merge pull request #692 from sasa1977/fix-spec-check
Browse files Browse the repository at this point in the history
Fix spec check
  • Loading branch information
rrrene committed Aug 21, 2019
2 parents 7ebf30e + b6fc943 commit 40f8943
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/credo/check/readability/specs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ defmodule Credo.Check.Readability.Specs do
{ast, [{name, length(args)} | specs]}
end

defp find_specs({:impl, _, [true]} = ast, specs) do
defp find_specs({:impl, _, [impl]} = ast, specs) when impl != false do
{ast, [:impl | specs]}
end

Expand Down
22 changes: 22 additions & 0 deletions test/credo/check/readability/specs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,26 @@ defmodule Credo.Check.Readability.SpecsTest do
|> to_source_file()
|> refute_issues(@described_check)
end

test "it should NOT report functions with `@impl SomeMod`" do
"""
defmodule CredoTypespecTest do
@impl SomeMod
def foo(a), do: a
end
"""
|> to_source_file()
|> refute_issues(@described_check)
end

test "it should report functions with `@impl false`" do
"""
defmodule CredoTypespecTest do
@impl false
def foo(a), do: a
end
"""
|> to_source_file()
|> assert_issue(@described_check)
end
end

0 comments on commit 40f8943

Please sign in to comment.