Skip to content

Commit

Permalink
Fix #867
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Dec 21, 2023
1 parent 06168c1 commit b864f94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/credo/check/readability/predicate_function_names.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ defmodule Credo.Check.Readability.PredicateFunctionNames do
{name, meta, nil} ->
issues_for_name(op, name, meta, issues, issue_meta)

{name, meta, [_|_]} ->
issues_for_name(op, name, meta, issues, issue_meta)

_ ->
issues
end
Expand Down
32 changes: 32 additions & 0 deletions test/credo/check/readability/predicate_function_names_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ defmodule Credo.Check.Readability.PredicateFunctionNamesTest do
|> refute_issues()
end

test "it should NOT report expected code with arity on function" do
"""
def valid?(a) do
end
defp has_attachment?(a) do
end
"""
|> to_source_file
|> run_check(@described_check)
|> refute_issues()
end

#
# cases raising issues
#
Expand All @@ -44,4 +56,24 @@ defmodule Credo.Check.Readability.PredicateFunctionNamesTest do
|> run_check(@described_check)
|> assert_issues()
end

test "it should report a violation with arity" do
"""
def is_valid?(a) do
end
"""
|> to_source_file
|> run_check(@described_check)
|> assert_issue()
end

test "it should report a violation with arity /2" do
"""
def is_valid(a) do
end
"""
|> to_source_file
|> run_check(@described_check)
|> assert_issue()
end
end

0 comments on commit b864f94

Please sign in to comment.