diff --git a/lib/credo/check/readability/specs.ex b/lib/credo/check/readability/specs.ex index 42ecb2672..82cd262ec 100644 --- a/lib/credo/check/readability/specs.ex +++ b/lib/credo/check/readability/specs.ex @@ -79,6 +79,10 @@ defmodule Credo.Check.Readability.Specs do {ast, issues} end + defp traverse({:quote, _, _}, issues, _specs, _issue_meta) do + {nil, issues} + end + defp traverse( {keyword, meta, [{:when, _, def_ast} | _]}, issues, diff --git a/test/credo/check/readability/specs_test.exs b/test/credo/check/readability/specs_test.exs index 18636f728..f60c12d49 100644 --- a/test/credo/check/readability/specs_test.exs +++ b/test/credo/check/readability/specs_test.exs @@ -125,6 +125,22 @@ defmodule Credo.Check.Readability.SpecsTest do |> refute_issues() end + test "it should NOT report functions inside `quote`" do + """ + @spec to_def(t(), atom()) :: Macro.t() + def to_def(%__MODULE__{vars: vars, code: code}, name) do + quote generated: true do + def unquote(name)(unquote_splicing(vars)) do + unquote(code) + end + end + end + """ + |> to_source_file() + |> run_check(@described_check) + |> refute_issues() + end + # # cases raising issues #