Skip to content

Commit

Permalink
Fix false positive on Credo.Check.Readability.PredicateFunctionNames
Browse files Browse the repository at this point in the history
Refs #1100
  • Loading branch information
rrrene committed Jan 2, 2024
1 parent bb43348 commit 491f8d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/credo/check/readability/predicate_function_names.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defmodule Credo.Check.Readability.PredicateFunctionNames do
issues
end

defp issues_for_name(_op, name, meta, issues, issue_meta) do
defp issues_for_name(op, name, meta, issues, issue_meta) do
name = to_string(name)

cond do
Expand All @@ -103,7 +103,7 @@ defmodule Credo.Check.Readability.PredicateFunctionNames do
| issues
]

String.starts_with?(name, "is_") ->
String.starts_with?(name, "is_") && op != :defmacro ->
[issue_for(issue_meta, meta[:line], name, :only_predicate) | issues]

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

test "it should NOT report a violation with defmacro" do
"""
defmacro is_user(cookie) do
end
"""
|> to_source_file
|> run_check(@described_check)
|> refute_issues()
end

test "it should NOT report a violation with quote" do
~S'''
defmodule ElixirScript.FFI do
Expand Down

0 comments on commit 491f8d5

Please sign in to comment.