Skip to content

Commit

Permalink
Fix some predicate function names
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Jan 9, 2024
1 parent 5b2642b commit ba171a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
10 changes: 4 additions & 6 deletions lib/credo/check/consistency/space_around_operators.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,24 @@ defmodule Credo.Check.Consistency.SpaceAroundOperators do
|> Credo.Code.TokenAstCorrelation.find_tokens_in_ast(ast)
|> List.wrap()
|> List.first()
|> is_parameter_in_function_call()
|> parameter_in_function_call?()

_ ->
false
end
end

defp is_parameter_in_function_call({atom, _, arguments})
defp parameter_in_function_call?({atom, _, arguments})
when is_atom(atom) and is_list(arguments) do
true
end

defp is_parameter_in_function_call(
{{:., _, [{:__aliases__, _, _mods}, fun_name]}, _, arguments}
)
defp parameter_in_function_call?({{:., _, [{:__aliases__, _, _mods}, fun_name]}, _, arguments})
when is_atom(fun_name) and is_list(arguments) do
true
end

defp is_parameter_in_function_call(_) do
defp parameter_in_function_call?(_) do
false
end

Expand Down
6 changes: 3 additions & 3 deletions lib/credo/check/readability/parentheses_in_condition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ defmodule Credo.Check.Readability.ParenthesesInCondition do
_
)
when if_or_unless in [:if, :unless] do
if Enum.any?(collect_paren_children(t), &is_do/1) do
if Enum.any?(collect_paren_children(t), &do?/1) do
false
else
token
Expand Down Expand Up @@ -155,8 +155,8 @@ defmodule Credo.Check.Readability.ParenthesesInCondition do

defp check_for_closing_paren(_, _, _, _), do: false

defp is_do({_, _, :do}), do: true
defp is_do(_), do: false
defp do?({_, _, :do}), do: true
defp do?(_), do: false

defp collect_paren_children(x) do
{_, children} = Enum.reduce(x, {0, []}, &collect_paren_child/2)
Expand Down
6 changes: 3 additions & 3 deletions lib/credo/check/readability/string_sigils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Credo.Check.Readability.StringSigils do
line_no = meta[:line]

cond do
is_sigil(maybe_sigil) ->
sigil?(maybe_sigil) ->
{rest_ast, issues}

is_binary(str) ->
Expand All @@ -95,13 +95,13 @@ defmodule Credo.Check.Readability.StringSigils do
{ast, issues}
end

defp is_sigil(maybe_sigil) when is_atom(maybe_sigil) do
defp sigil?(maybe_sigil) when is_atom(maybe_sigil) do
maybe_sigil
|> Atom.to_string()
|> String.starts_with?("sigil_")
end

defp is_sigil(_), do: false
defp sigil?(_), do: false

defp issues_for_string_literal(
string,
Expand Down

0 comments on commit ba171a6

Please sign in to comment.