diff --git a/lib/credo/check/params.ex b/lib/credo/check/params.ex index 39df819cc..08ca4fa4f 100644 --- a/lib/credo/check/params.ex +++ b/lib/credo/check/params.ex @@ -36,7 +36,7 @@ defmodule Credo.Check.Params do def get(params, field, check_mod) do case params[field] do nil -> - check_mod.param_defaults[field] + check_mod.param_defaults()[field] val -> val @@ -71,12 +71,12 @@ defmodule Credo.Check.Params do @doc false def category(params, check_mod) do - params[:__category__] || params[:category] || check_mod.category + params[:__category__] || params[:category] || check_mod.category() end @doc false def exit_status(params, check_mod) do - params[:__exit_status__] || params[:exit_status] || check_mod.exit_status + params[:__exit_status__] || params[:exit_status] || check_mod.exit_status() end @doc false @@ -95,11 +95,11 @@ defmodule Credo.Check.Params do @doc false def priority(params, check_mod) do - params[:__priority__] || params[:priority] || check_mod.base_priority + params[:__priority__] || params[:priority] || check_mod.base_priority() end @doc false def tags(params, check_mod) do - params[:__tags__] || params[:tags] || check_mod.tags + params[:__tags__] || params[:tags] || check_mod.tags() end end diff --git a/lib/credo/cli/command/diff/output/default.ex b/lib/credo/cli/command/diff/output/default.ex index 154a23f65..467e6e963 100644 --- a/lib/credo/cli/command/diff/output/default.ex +++ b/lib/credo/cli/command/diff/output/default.ex @@ -316,7 +316,7 @@ defmodule Credo.CLI.Command.Diff.Output.Default do UI.edge(outer_color), outer_color, tag_style, - Output.check_tag(check.category), + Output.check_tag(check.category()), " ", priority |> Output.priority_arrow(), :normal, diff --git a/lib/credo/cli/command/explain/explain_command.ex b/lib/credo/cli/command/explain/explain_command.ex index b58167146..bcbdd4880 100644 --- a/lib/credo/cli/command/explain/explain_command.ex +++ b/lib/credo/cli/command/explain/explain_command.ex @@ -84,10 +84,10 @@ defmodule Credo.CLI.Command.Explain.ExplainCommand do defp cast_to_explanation(check) do %{ - category: check.category, + category: check.category(), check: check, - explanation_for_issue: check.explanation, - priority: check.base_priority + explanation_for_issue: check.explanation(), + priority: check.base_priority() } end end @@ -181,7 +181,7 @@ defmodule Credo.CLI.Command.Explain.ExplainCommand do category: issue.category, check: issue.check, column: issue.column, - explanation_for_issue: issue.check.explanation, + explanation_for_issue: issue.check.explanation(), filename: issue.filename, line_no: issue.line_no, message: issue.message, diff --git a/lib/credo/cli/command/explain/output/default.ex b/lib/credo/cli/command/explain/output/default.ex index 75426b41e..490032284 100644 --- a/lib/credo/cli/command/explain/output/default.ex +++ b/lib/credo/cli/command/explain/output/default.ex @@ -52,7 +52,7 @@ defmodule Credo.CLI.Command.Explain.Output.Default do term_width ) do check_name = check |> to_string |> String.replace(~r/^Elixir\./, "") - color = Output.check_color(check.category) + color = Output.check_color(check.category()) UI.puts() @@ -84,9 +84,9 @@ defmodule Credo.CLI.Command.Explain.Output.Default do inner_color, tag_style, " ", - Output.check_tag(check.category), + Output.check_tag(check.category()), :reset, - " Category: #{check.category} " + " Category: #{check.category()} " ] |> UI.puts() @@ -189,9 +189,9 @@ defmodule Credo.CLI.Command.Explain.Output.Default do inner_color, tag_style, " ", - Output.check_tag(check.category), + Output.check_tag(check.category()), :reset, - " Category: #{check.category} " + " Category: #{check.category()} " ] |> UI.puts() diff --git a/lib/credo/cli/command/list/output/default.ex b/lib/credo/cli/command/list/output/default.ex index dd624d3b1..fe85fe8b2 100644 --- a/lib/credo/cli/command/list/output/default.ex +++ b/lib/credo/cli/command/list/output/default.ex @@ -102,7 +102,7 @@ defmodule Credo.CLI.Command.List.Output.Default do UI.edge(outer_color), inner_color, tag_style, - Output.check_tag(check.category), + Output.check_tag(check.category()), " ", priority |> Output.priority_arrow(), :normal, diff --git a/lib/credo/cli/command/suggest/output/default.ex b/lib/credo/cli/command/suggest/output/default.ex index 21d49182b..60f4ed917 100644 --- a/lib/credo/cli/command/suggest/output/default.ex +++ b/lib/credo/cli/command/suggest/output/default.ex @@ -250,7 +250,7 @@ defmodule Credo.CLI.Command.Suggest.Output.Default do UI.edge(outer_color), outer_color, tag_style, - Output.check_tag(check.category), + Output.check_tag(check.category()), " ", priority |> Output.priority_arrow(), :normal, diff --git a/lib/credo/cli/command/suggest/suggest_command.ex b/lib/credo/cli/command/suggest/suggest_command.ex index d67a41710..0f6a95727 100644 --- a/lib/credo/cli/command/suggest/suggest_command.ex +++ b/lib/credo/cli/command/suggest/suggest_command.ex @@ -115,7 +115,7 @@ defmodule Credo.CLI.Command.Suggest.SuggestCommand do def modify_config_to_only_include_needed_checks(%Credo.Execution{} = exec, files_that_changed) do checks = Enum.map(exec.checks, fn {check, params} -> - if check.category == :consistency do + if check.category() == :consistency do {check, params} else {check, Params.put_rerun_files_that_changed(params, files_that_changed)} diff --git a/lib/credo/cli/output.ex b/lib/credo/cli/output.ex index d85300ac4..cf7fad119 100644 --- a/lib/credo/cli/output.ex +++ b/lib/credo/cli/output.ex @@ -33,7 +33,7 @@ defmodule Credo.CLI.Output do end def check_tag(check_mod, in_parens) do - check_mod.category + check_mod.category() |> to_string |> check_tag(in_parens) end @@ -55,8 +55,8 @@ defmodule Credo.CLI.Output do |> check_color end - def check_color(check_mod) do - check_mod.category + def check_color(%{} = issue_or_map) do + issue_or_map.category |> to_string |> check_color end diff --git a/lib/credo/cli/output/formatter/oneline.ex b/lib/credo/cli/output/formatter/oneline.ex index 9c51ce371..14c656aa1 100644 --- a/lib/credo/cli/output/formatter/oneline.ex +++ b/lib/credo/cli/output/formatter/oneline.ex @@ -28,7 +28,7 @@ defmodule Credo.CLI.Output.Formatter.Oneline do [ inner_color, - Output.check_tag(check.category), + Output.check_tag(check.category()), " ", priority |> Output.priority_arrow(), " ", diff --git a/lib/credo/cli/output/formatter/sarif.ex b/lib/credo/cli/output/formatter/sarif.ex index ef808c81e..50553d363 100644 --- a/lib/credo/cli/output/formatter/sarif.ex +++ b/lib/credo/cli/output/formatter/sarif.ex @@ -17,21 +17,21 @@ defmodule Credo.CLI.Output.Formatter.SARIF do final_rules = issues - |> Enum.uniq_by(& &1.check.id) + |> Enum.uniq_by(& &1.check.id()) |> Enum.map(fn issue -> %{ - "id" => issue.check.id, + "id" => issue.check.id(), "name" => Credo.Code.Name.full(issue.check), "fullDescription" => %{ - "text" => issue.check.explanation |> String.replace("`", "'"), - "markdown" => issue.check.explanation + "text" => issue.check.explanation() |> String.replace("`", "'"), + "markdown" => issue.check.explanation() }, "properties" => %{ "tags" => [ issue.category ] }, - "helpUri" => issue.check.docs_uri + "helpUri" => issue.check.docs_uri() } end) @@ -158,21 +158,21 @@ defmodule Credo.CLI.Output.Formatter.SARIF do rule_and_issue = { %{ - "id" => issue.check.id, + "id" => issue.check.id(), "name" => Credo.Code.Name.full(issue.check), "fullDescription" => %{ - "text" => issue.check.explanation |> String.replace("`", "'"), - "markdown" => issue.check.explanation + "text" => issue.check.explanation() |> String.replace("`", "'"), + "markdown" => issue.check.explanation() }, "properties" => %{ "tags" => [ issue.category ] }, - "helpUri" => issue.check.docs_uri + "helpUri" => issue.check.docs_uri() }, %{ - "ruleId" => issue.check.id, + "ruleId" => issue.check.id(), "level" => sarif_level, "rank" => priority_to_sarif_rank(issue.priority), "message" => %{ @@ -208,7 +208,7 @@ defmodule Credo.CLI.Output.Formatter.SARIF do rule_and_issue |> remove_nil_endcolumn(!column_end) |> remove_warning_level(sarif_level == :warning) - |> remove_redundant_name(issue.check.id == Credo.Code.Name.full(issue.check)) + |> remove_redundant_name(issue.check.id() == Credo.Code.Name.full(issue.check)) end defp remove_nil_endcolumn(sarif, false), do: sarif diff --git a/lib/credo/cli/task/prepare_checks_to_run.ex b/lib/credo/cli/task/prepare_checks_to_run.ex index 0da823497..97e8d5847 100644 --- a/lib/credo/cli/task/prepare_checks_to_run.ex +++ b/lib/credo/cli/task/prepare_checks_to_run.ex @@ -49,7 +49,7 @@ defmodule Credo.CLI.Task.PrepareChecksToRun do Enum.reject(exec.checks.enabled, fn # deprecated {check} -> - Credo.Priority.to_integer(check.base_priority) < below_priority + Credo.Priority.to_integer(check.base_priority()) < below_priority {_check, false} -> true @@ -83,7 +83,7 @@ defmodule Credo.CLI.Task.PrepareChecksToRun do end defp matches_requirement?({check}, elixir_version) do - Version.match?(elixir_version, check.elixir_version) + Version.match?(elixir_version, check.elixir_version()) end defp to_match_regexes(nil), do: [] diff --git a/lib/credo/cli/task/set_relevant_issues.ex b/lib/credo/cli/task/set_relevant_issues.ex index 51483f689..29f3aa00a 100644 --- a/lib/credo/cli/task/set_relevant_issues.ex +++ b/lib/credo/cli/task/set_relevant_issues.ex @@ -12,7 +12,7 @@ defmodule Credo.CLI.Task.SetRelevantIssues do |> Filter.important(exec) |> Filter.valid_issues(exec) |> Enum.sort_by(fn issue -> - {issue.check.id, issue.filename, issue.line_no} + {issue.check.id(), issue.filename, issue.line_no} end) put_issues(exec, issues) diff --git a/lib/credo/execution.ex b/lib/credo/execution.ex index 3e9750f9a..a621cb771 100644 --- a/lib/credo/execution.ex +++ b/lib/credo/execution.ex @@ -255,14 +255,14 @@ defmodule Credo.Execution do """ def tags_for_check(check, params) - def tags_for_check(check, nil), do: check.tags - def tags_for_check(check, []), do: check.tags + def tags_for_check(check, nil), do: check.tags() + def tags_for_check(check, []), do: check.tags() def tags_for_check(check, params) when is_list(params) do params |> Credo.Check.Params.tags(check) |> Enum.flat_map(fn - :__initial__ -> check.tags + :__initial__ -> check.tags() tag -> [tag] end) end diff --git a/lib/credo/execution/task/initialize_command.ex b/lib/credo/execution/task/initialize_command.ex index a8e4bdbbb..329f5e8e9 100644 --- a/lib/credo/execution/task/initialize_command.ex +++ b/lib/credo/execution/task/initialize_command.ex @@ -22,7 +22,7 @@ defmodule Credo.Execution.Task.InitializeCommand do end defp cli_options_switches(command_mod) do - command_mod.cli_switches + command_mod.cli_switches() |> List.wrap() |> Enum.map(fn %{name: name, type: type} when is_binary(name) -> {String.to_atom(name), type} @@ -31,7 +31,7 @@ defmodule Credo.Execution.Task.InitializeCommand do end defp cli_options_aliases(command_mod) do - command_mod.cli_switches + command_mod.cli_switches() |> List.wrap() |> Enum.map(fn %{name: name, alias: alias} when is_binary(name) -> {alias, String.to_atom(name)} diff --git a/lib/credo/execution/task/parse_options.ex b/lib/credo/execution/task/parse_options.ex index b81be9ec0..18d7564f5 100644 --- a/lib/credo/execution/task/parse_options.ex +++ b/lib/credo/execution/task/parse_options.ex @@ -30,7 +30,7 @@ defmodule Credo.Execution.Task.ParseOptions do command_name = Execution.get_command_name(exec) command_mod = Execution.get_command(exec, command_name) - command_mod.treat_unknown_args_as_files? + command_mod.treat_unknown_args_as_files?() else false end diff --git a/lib/credo/execution/task/validate_config.ex b/lib/credo/execution/task/validate_config.ex index 884309251..e8af47db7 100644 --- a/lib/credo/execution/task/validate_config.ex +++ b/lib/credo/execution/task/validate_config.ex @@ -67,7 +67,7 @@ defmodule Credo.Execution.Task.ValidateConfig do end defp do_warn_if_check_params_invalid({check, params}) do - valid_param_names = check.param_names ++ Params.builtin_param_names() + valid_param_names = check.param_names() ++ Params.builtin_param_names() check = check |> to_string |> String.to_existing_atom() Enum.each(params, fn {param_name, _param_value} ->