Skip to content

Commit

Permalink
Fixing issue #866 to check predicates with arity
Browse files Browse the repository at this point in the history
  • Loading branch information
panoramix360 authored and rrrene committed Jul 18, 2021
1 parent db252cc commit d9474a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/credo/check/readability/predicate_function_names.ex
Expand Up @@ -77,7 +77,7 @@ defmodule Credo.Check.Readability.PredicateFunctionNames do

defp issues_for_definition(op, body, issues, issue_meta) do
case Enum.at(body, 0) do
{name, meta, nil} ->
{name, meta, _} ->
issues_for_name(op, name, meta, issues, issue_meta)

_ ->
Expand Down
20 changes: 20 additions & 0 deletions test/credo/check/readability/predicate_function_names_test.exs
Expand Up @@ -44,4 +44,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 d9474a1

Please sign in to comment.