diff --git a/lib/credo/check/readability/function_names.ex b/lib/credo/check/readability/function_names.ex index 9ce09b9d1..f0e59474f 100644 --- a/lib/credo/check/readability/function_names.ex +++ b/lib/credo/check/readability/function_names.ex @@ -66,7 +66,7 @@ defmodule Credo.Check.Readability.FunctionNames do _issue_meta, _allow_acronyms? ) - when op in [:def, :defmacro, :defmacrop] do + when op in [:def, :defp, :defmacro, :defmacrop] do {ast, issues} end @@ -77,7 +77,7 @@ defmodule Credo.Check.Readability.FunctionNames do _issue_meta, _allow_acronyms? ) - when op in [:def, :defmacro, :defmacrop] do + when op in [:def, :defp, :defmacro, :defmacrop] do {ast, issues} end end diff --git a/test/credo/check/readability/function_names_test.exs b/test/credo/check/readability/function_names_test.exs index 6f5da87d3..f18004856 100644 --- a/test/credo/check/readability/function_names_test.exs +++ b/test/credo/check/readability/function_names_test.exs @@ -63,6 +63,9 @@ defmodule Credo.Check.Readability.FunctionNamesTest do def sigil_O(input, args) do # ... end + def sigil_o(input, args) do + # ... + end defmacro sigil_U({:<<>>, _, [string]}, []) do # ... end @@ -77,7 +80,27 @@ defmodule Credo.Check.Readability.FunctionNamesTest do |> refute_issues() end - test "it should NOT report expected code for multi letter sigils /5" do + test "it should NOT report expected code /6" do + """ + defp sigil_O(input, args) do + # ... + end + defp sigil_p(input, args) do + # ... + end + defmacrop sigil_U({:<<>>, _, [string]}, []) do + # ... + end + defmacrop sigil_U({:<<>>, _, [string]}, []) when is_binary(string) do + # ... + end + """ + |> to_source_file + |> run_check(@described_check) + |> refute_issues() + end + + test "it should NOT report expected code for multi letter sigils" do """ def sigil_ZZO(input, args) do # ... @@ -94,6 +117,23 @@ defmodule Credo.Check.Readability.FunctionNamesTest do |> refute_issues() end + test "it should NOT report expected code for private multi letter sigils" do + """ + defp sigil_ZZO(input, args) do + # ... + end + defmacrop sigil_ZZU({:<<>>, _, [string]}, []) do + # ... + end + defmacrop sigil_ZZU({:<<>>, _, [string]}, []) when is_binary(string) do + # ... + end + """ + |> to_source_file + |> run_check(@described_check) + |> refute_issues() + end + test "it should NOT report expected code (for operators) /6" do """ defmacro @expr2