Skip to content
Permalink
Browse files

Update public funs to be private

  • Loading branch information...
rrrene committed Mar 9, 2019
1 parent 7a92ac2 commit 162abc1edece64b8a65542d40025639bca86d302
@@ -69,7 +69,7 @@ defmodule Credo.Check.Consistency.ExceptionNames do
to_one_line(message)
end

def to_one_line(str) do
defp to_one_line(str) do
str
|> String.split()
|> Enum.join(" ")
@@ -57,7 +57,7 @@ defmodule Credo.Check.Readability.FunctionNames do
end
end

def issues_for_name(name, meta, issues, issue_meta) do
defp issues_for_name(name, meta, issues, issue_meta) do
if name |> to_string |> Name.snake_case?() do
issues
else
@@ -144,7 +144,7 @@ defmodule Credo.Check.Readability.LargeNumbers do
|> String.reverse()
end

def issue_for(issue_meta, line_no, column, trigger, expected) do
defp issue_for(issue_meta, line_no, column, trigger, expected) do
format_issue(
issue_meta,
message: "Large numbers should be written with underscores: #{expected}",
@@ -125,15 +125,15 @@ defmodule Credo.Check.Readability.ModuleDoc do
{ast, {continue, issues}}
end

def matches_any?(name, list) when is_list(list) do
defp matches_any?(name, list) when is_list(list) do
Enum.any?(list, &matches_any?(name, &1))
end

def matches_any?(name, string) when is_binary(string) do
defp matches_any?(name, string) when is_binary(string) do
String.contains?(name, string)
end

def matches_any?(name, regex) do
defp matches_any?(name, regex) do
String.match?(name, regex)
end

@@ -54,7 +54,7 @@ defmodule Credo.Check.Readability.ModuleNames do
end
end

def issues_for_name(name, meta, issues, issue_meta) do
defp issues_for_name(name, meta, issues, issue_meta) do
all_pascal_case? =
name
|> to_string
@@ -69,7 +69,7 @@ defmodule Credo.Check.Readability.PredicateFunctionNames do
end
end

def 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
@@ -40,7 +40,7 @@ defmodule Credo.Check.Readability.Semicolons do

defp collect_issues([_ | rest], acc, issue_meta), do: collect_issues(rest, acc, issue_meta)

def issue_for(issue_meta, line_no, column) do
defp issue_for(issue_meta, line_no, column) do
format_issue(
issue_meta,
message: "Don't use ; to separate statements and expressions",
@@ -52,7 +52,7 @@ defmodule Credo.Check.Readability.SinglePipe do
{ast, {true, issues}}
end

def issue_for(issue_meta, line_no, trigger) do
defp issue_for(issue_meta, line_no, trigger) do
format_issue(
issue_meta,
message: "Use a function call when a pipeline is only one function long",
@@ -54,12 +54,12 @@ defmodule Credo.Check.Readability.StringSigils do
|> SourceFile.parse(source_file.filename)
end

def traverse(
{maybe_sigil, meta, [str | rest_ast]} = ast,
issues,
issue_meta,
maximum_allowed_quotes
) do
defp traverse(
{maybe_sigil, meta, [str | rest_ast]} = ast,
issues,
issue_meta,
maximum_allowed_quotes
) do
line_no = meta[:line]

cond do
@@ -83,7 +83,7 @@ defmodule Credo.Check.Readability.StringSigils do
end
end

def traverse(ast, issues, _issue_meta, _maximum_allowed_quotes) do
defp traverse(ast, issues, _issue_meta, _maximum_allowed_quotes) do
{ast, issues}
end

@@ -31,7 +31,7 @@ defmodule Credo.Check.Readability.TrailingBlankLine do
end
end

def issue_for(issue_meta, line_no) do
defp issue_for(issue_meta, line_no) do
format_issue(
issue_meta,
message: "There should be a final \\n at the end of each file.",
@@ -57,7 +57,7 @@ defmodule Credo.Check.Readability.TrailingWhiteSpace do

defp traverse_line([], issues, _issue_meta), do: issues

def issue_for(issue_meta, line_no, column, line_length) do
defp issue_for(issue_meta, line_no, column, line_length) do
format_issue(
issue_meta,
message: "There should be no trailing white-space at the end of a line.",
@@ -113,7 +113,7 @@ defmodule Credo.Check.Refactor.ABCSize do
:math.sqrt(a * a + b * b + c * c)
end

def get_parameters(arguments) do
defp get_parameters(arguments) do
case Enum.at(arguments, 0) do
{_name, _meta, nil} ->
[]
@@ -232,21 +232,21 @@ defmodule Credo.Check.Refactor.ABCSize do
defp var_name({name, _, nil}) when is_atom(name), do: name
defp var_name(_), do: nil

def fn_parameters([params, tuple]) when is_list(params) and is_tuple(tuple) do
defp fn_parameters([params, tuple]) when is_list(params) and is_tuple(tuple) do
fn_parameters(params)
end

def fn_parameters([[{:when, _, params}], _]) when is_list(params) do
defp fn_parameters([[{:when, _, params}], _]) when is_list(params) do
fn_parameters(params)
end

def fn_parameters(params) when is_list(params) do
defp fn_parameters(params) when is_list(params) do
params
|> Enum.map(&var_name/1)
|> Enum.reject(&is_nil/1)
end

def issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
defp issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
format_issue(
issue_meta,
message: "Function is too complex (ABC size is #{actual_value}, max is #{max_value}).",
@@ -40,7 +40,7 @@ defmodule Credo.Check.Refactor.CaseTrivialMatches do
defp case_statement_for({:->, _, [[false], _]}), do: false
defp case_statement_for(_), do: nil

def issue_for(issue_meta, line_no, trigger) do
defp issue_for(issue_meta, line_no, trigger) do
format_issue(
issue_meta,
message: "Case statements should not only contain `true` and `false`.",
@@ -51,7 +51,7 @@ defmodule Credo.Check.Refactor.CondStatements do
{ast, issues}
end

def issue_for(issue_meta, line_no, trigger) do
defp issue_for(issue_meta, line_no, trigger) do
format_issue(
issue_meta,
message:
@@ -165,7 +165,7 @@ defmodule Credo.Check.Refactor.CyclomaticComplexity do
count * @op_complexity_map[op]
end

def issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
defp issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
format_issue(
issue_meta,
message: "Function is too complex (CC is #{actual_value}, max is #{max_value}).",
@@ -65,7 +65,7 @@ defmodule Credo.Check.Refactor.FunctionArity do
def issue?(_, _, arity, max_arity) when arity > max_arity, do: true
def issue?(_, _, _, _), do: false

def issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
defp issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
format_issue(
issue_meta,
message:
@@ -120,7 +120,7 @@ defmodule Credo.Check.Refactor.Nesting do
{Enum.count(nest_list), line_no, trigger}
end

def issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
defp issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
format_issue(
issue_meta,
message:
@@ -165,7 +165,7 @@ defmodule Credo.Check.Refactor.PerceivedComplexity do
count * @op_complexity_map[op]
end

def issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
defp issue_for(issue_meta, line_no, trigger, max_value, actual_value) do
format_issue(
issue_meta,
message: "Function is too complex (CC is #{actual_value}, max is #{max_value}).",
@@ -49,7 +49,7 @@ defmodule Credo.Check.Refactor.VariableRebinding do
Credo.Code.prewalk(source_file, &traverse(&1, &2, issue_meta))
end

def traverse([do: {:__block__, _, ast}], issues, {_, _, opt} = issue_meta) do
defp traverse([do: {:__block__, _, ast}], issues, {_, _, opt} = issue_meta) do
variables =
ast
|> Enum.map(&find_assignments/1)
@@ -78,7 +78,7 @@ defmodule Credo.Check.Refactor.VariableRebinding do
end
end

def traverse(ast, issues, _issue_meta) do
defp traverse(ast, issues, _issue_meta) do
{ast, issues}
end

@@ -53,7 +53,7 @@ defmodule Credo.Check.Warning.ExpensiveEmptyEnumCheck do
{ast, issues}
end

def issues_for_call(meta, issues, issue_meta, ast) do
defp issues_for_call(meta, issues, issue_meta, ast) do
[issue_for(issue_meta, meta[:line], Macro.to_string(ast)) | issues]
end

@@ -32,7 +32,7 @@ defmodule Credo.Check.Warning.IExPry do
{ast, issues}
end

def issues_for_call(meta, issues, issue_meta) do
defp issues_for_call(meta, issues, issue_meta) do
[issue_for(issue_meta, meta[:line], @call_string) | issues]
end

@@ -32,7 +32,7 @@ defmodule Credo.Check.Warning.IoInspect do
{ast, issues}
end

def issues_for_call(meta, issues, issue_meta) do
defp issues_for_call(meta, issues, issue_meta) do
[issue_for(issue_meta, meta[:line], @call_string) | issues]
end

0 comments on commit 162abc1

Please sign in to comment.
You can’t perform that action at this time.