Skip to content

Commit 35abc4d

Browse files
committed
Merge branch 'mhanberg-fix-deprecatoins'
2 parents e48a5eb + 8e8808a commit 35abc4d

File tree

16 files changed

+43
-43
lines changed

16 files changed

+43
-43
lines changed

lib/credo/check/params.ex

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Credo.Check.Params do
3636
def get(params, field, check_mod) do
3737
case params[field] do
3838
nil ->
39-
check_mod.param_defaults[field]
39+
check_mod.param_defaults()[field]
4040

4141
val ->
4242
val
@@ -71,12 +71,12 @@ defmodule Credo.Check.Params do
7171

7272
@doc false
7373
def category(params, check_mod) do
74-
params[:__category__] || params[:category] || check_mod.category
74+
params[:__category__] || params[:category] || check_mod.category()
7575
end
7676

7777
@doc false
7878
def exit_status(params, check_mod) do
79-
params[:__exit_status__] || params[:exit_status] || check_mod.exit_status
79+
params[:__exit_status__] || params[:exit_status] || check_mod.exit_status()
8080
end
8181

8282
@doc false
@@ -95,11 +95,11 @@ defmodule Credo.Check.Params do
9595

9696
@doc false
9797
def priority(params, check_mod) do
98-
params[:__priority__] || params[:priority] || check_mod.base_priority
98+
params[:__priority__] || params[:priority] || check_mod.base_priority()
9999
end
100100

101101
@doc false
102102
def tags(params, check_mod) do
103-
params[:__tags__] || params[:tags] || check_mod.tags
103+
params[:__tags__] || params[:tags] || check_mod.tags()
104104
end
105105
end

lib/credo/cli/command/diff/output/default.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ defmodule Credo.CLI.Command.Diff.Output.Default do
316316
UI.edge(outer_color),
317317
outer_color,
318318
tag_style,
319-
Output.check_tag(check.category),
319+
Output.check_tag(check.category()),
320320
" ",
321321
priority |> Output.priority_arrow(),
322322
:normal,

lib/credo/cli/command/explain/explain_command.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ defmodule Credo.CLI.Command.Explain.ExplainCommand do
8484

8585
defp cast_to_explanation(check) do
8686
%{
87-
category: check.category,
87+
category: check.category(),
8888
check: check,
89-
explanation_for_issue: check.explanation,
90-
priority: check.base_priority
89+
explanation_for_issue: check.explanation(),
90+
priority: check.base_priority()
9191
}
9292
end
9393
end
@@ -181,7 +181,7 @@ defmodule Credo.CLI.Command.Explain.ExplainCommand do
181181
category: issue.category,
182182
check: issue.check,
183183
column: issue.column,
184-
explanation_for_issue: issue.check.explanation,
184+
explanation_for_issue: issue.check.explanation(),
185185
filename: issue.filename,
186186
line_no: issue.line_no,
187187
message: issue.message,

lib/credo/cli/command/explain/output/default.ex

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ defmodule Credo.CLI.Command.Explain.Output.Default do
5252
term_width
5353
) do
5454
check_name = check |> to_string |> String.replace(~r/^Elixir\./, "")
55-
color = Output.check_color(check.category)
55+
color = Output.check_color(check.category())
5656

5757
UI.puts()
5858

@@ -84,9 +84,9 @@ defmodule Credo.CLI.Command.Explain.Output.Default do
8484
inner_color,
8585
tag_style,
8686
" ",
87-
Output.check_tag(check.category),
87+
Output.check_tag(check.category()),
8888
:reset,
89-
" Category: #{check.category} "
89+
" Category: #{check.category()} "
9090
]
9191
|> UI.puts()
9292

@@ -189,9 +189,9 @@ defmodule Credo.CLI.Command.Explain.Output.Default do
189189
inner_color,
190190
tag_style,
191191
" ",
192-
Output.check_tag(check.category),
192+
Output.check_tag(check.category()),
193193
:reset,
194-
" Category: #{check.category} "
194+
" Category: #{check.category()} "
195195
]
196196
|> UI.puts()
197197

lib/credo/cli/command/list/output/default.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ defmodule Credo.CLI.Command.List.Output.Default do
102102
UI.edge(outer_color),
103103
inner_color,
104104
tag_style,
105-
Output.check_tag(check.category),
105+
Output.check_tag(check.category()),
106106
" ",
107107
priority |> Output.priority_arrow(),
108108
:normal,

lib/credo/cli/command/suggest/output/default.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ defmodule Credo.CLI.Command.Suggest.Output.Default do
250250
UI.edge(outer_color),
251251
outer_color,
252252
tag_style,
253-
Output.check_tag(check.category),
253+
Output.check_tag(check.category()),
254254
" ",
255255
priority |> Output.priority_arrow(),
256256
:normal,

lib/credo/cli/command/suggest/suggest_command.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ defmodule Credo.CLI.Command.Suggest.SuggestCommand do
115115
def modify_config_to_only_include_needed_checks(%Credo.Execution{} = exec, files_that_changed) do
116116
checks =
117117
Enum.map(exec.checks, fn {check, params} ->
118-
if check.category == :consistency do
118+
if check.category() == :consistency do
119119
{check, params}
120120
else
121121
{check, Params.put_rerun_files_that_changed(params, files_that_changed)}

lib/credo/cli/output.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ defmodule Credo.CLI.Output do
3333
end
3434

3535
def check_tag(check_mod, in_parens) do
36-
check_mod.category
36+
check_mod.category()
3737
|> to_string
3838
|> check_tag(in_parens)
3939
end
@@ -55,8 +55,8 @@ defmodule Credo.CLI.Output do
5555
|> check_color
5656
end
5757

58-
def check_color(check_mod) do
59-
check_mod.category
58+
def check_color(%{} = issue_or_map) do
59+
issue_or_map.category
6060
|> to_string
6161
|> check_color
6262
end

lib/credo/cli/output/formatter/oneline.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defmodule Credo.CLI.Output.Formatter.Oneline do
2828

2929
[
3030
inner_color,
31-
Output.check_tag(check.category),
31+
Output.check_tag(check.category()),
3232
" ",
3333
priority |> Output.priority_arrow(),
3434
" ",

lib/credo/cli/output/formatter/sarif.ex

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ defmodule Credo.CLI.Output.Formatter.SARIF do
1717

1818
final_rules =
1919
issues
20-
|> Enum.uniq_by(& &1.check.id)
20+
|> Enum.uniq_by(& &1.check.id())
2121
|> Enum.map(fn issue ->
2222
%{
23-
"id" => issue.check.id,
23+
"id" => issue.check.id(),
2424
"name" => Credo.Code.Name.full(issue.check),
2525
"fullDescription" => %{
26-
"text" => issue.check.explanation |> String.replace("`", "'"),
27-
"markdown" => issue.check.explanation
26+
"text" => issue.check.explanation() |> String.replace("`", "'"),
27+
"markdown" => issue.check.explanation()
2828
},
2929
"properties" => %{
3030
"tags" => [
3131
issue.category
3232
]
3333
},
34-
"helpUri" => issue.check.docs_uri
34+
"helpUri" => issue.check.docs_uri()
3535
}
3636
end)
3737

@@ -158,21 +158,21 @@ defmodule Credo.CLI.Output.Formatter.SARIF do
158158

159159
rule_and_issue = {
160160
%{
161-
"id" => issue.check.id,
161+
"id" => issue.check.id(),
162162
"name" => Credo.Code.Name.full(issue.check),
163163
"fullDescription" => %{
164-
"text" => issue.check.explanation |> String.replace("`", "'"),
165-
"markdown" => issue.check.explanation
164+
"text" => issue.check.explanation() |> String.replace("`", "'"),
165+
"markdown" => issue.check.explanation()
166166
},
167167
"properties" => %{
168168
"tags" => [
169169
issue.category
170170
]
171171
},
172-
"helpUri" => issue.check.docs_uri
172+
"helpUri" => issue.check.docs_uri()
173173
},
174174
%{
175-
"ruleId" => issue.check.id,
175+
"ruleId" => issue.check.id(),
176176
"level" => sarif_level,
177177
"rank" => priority_to_sarif_rank(issue.priority),
178178
"message" => %{
@@ -208,7 +208,7 @@ defmodule Credo.CLI.Output.Formatter.SARIF do
208208
rule_and_issue
209209
|> remove_nil_endcolumn(!column_end)
210210
|> remove_warning_level(sarif_level == :warning)
211-
|> remove_redundant_name(issue.check.id == Credo.Code.Name.full(issue.check))
211+
|> remove_redundant_name(issue.check.id() == Credo.Code.Name.full(issue.check))
212212
end
213213

214214
defp remove_nil_endcolumn(sarif, false), do: sarif

lib/credo/cli/task/prepare_checks_to_run.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ defmodule Credo.CLI.Task.PrepareChecksToRun do
4949
Enum.reject(exec.checks.enabled, fn
5050
# deprecated
5151
{check} ->
52-
Credo.Priority.to_integer(check.base_priority) < below_priority
52+
Credo.Priority.to_integer(check.base_priority()) < below_priority
5353

5454
{_check, false} ->
5555
true
@@ -83,7 +83,7 @@ defmodule Credo.CLI.Task.PrepareChecksToRun do
8383
end
8484

8585
defp matches_requirement?({check}, elixir_version) do
86-
Version.match?(elixir_version, check.elixir_version)
86+
Version.match?(elixir_version, check.elixir_version())
8787
end
8888

8989
defp to_match_regexes(nil), do: []

lib/credo/cli/task/set_relevant_issues.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule Credo.CLI.Task.SetRelevantIssues do
1212
|> Filter.important(exec)
1313
|> Filter.valid_issues(exec)
1414
|> Enum.sort_by(fn issue ->
15-
{issue.check.id, issue.filename, issue.line_no}
15+
{issue.check.id(), issue.filename, issue.line_no}
1616
end)
1717

1818
put_issues(exec, issues)

lib/credo/execution.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ defmodule Credo.Execution do
255255
"""
256256
def tags_for_check(check, params)
257257

258-
def tags_for_check(check, nil), do: check.tags
259-
def tags_for_check(check, []), do: check.tags
258+
def tags_for_check(check, nil), do: check.tags()
259+
def tags_for_check(check, []), do: check.tags()
260260

261261
def tags_for_check(check, params) when is_list(params) do
262262
params
263263
|> Credo.Check.Params.tags(check)
264264
|> Enum.flat_map(fn
265-
:__initial__ -> check.tags
265+
:__initial__ -> check.tags()
266266
tag -> [tag]
267267
end)
268268
end

lib/credo/execution/task/initialize_command.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule Credo.Execution.Task.InitializeCommand do
2222
end
2323

2424
defp cli_options_switches(command_mod) do
25-
command_mod.cli_switches
25+
command_mod.cli_switches()
2626
|> List.wrap()
2727
|> Enum.map(fn
2828
%{name: name, type: type} when is_binary(name) -> {String.to_atom(name), type}
@@ -31,7 +31,7 @@ defmodule Credo.Execution.Task.InitializeCommand do
3131
end
3232

3333
defp cli_options_aliases(command_mod) do
34-
command_mod.cli_switches
34+
command_mod.cli_switches()
3535
|> List.wrap()
3636
|> Enum.map(fn
3737
%{name: name, alias: alias} when is_binary(name) -> {alias, String.to_atom(name)}

lib/credo/execution/task/parse_options.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule Credo.Execution.Task.ParseOptions do
3030
command_name = Execution.get_command_name(exec)
3131
command_mod = Execution.get_command(exec, command_name)
3232

33-
command_mod.treat_unknown_args_as_files?
33+
command_mod.treat_unknown_args_as_files?()
3434
else
3535
false
3636
end

lib/credo/execution/task/validate_config.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ defmodule Credo.Execution.Task.ValidateConfig do
6767
end
6868

6969
defp do_warn_if_check_params_invalid({check, params}) do
70-
valid_param_names = check.param_names ++ Params.builtin_param_names()
70+
valid_param_names = check.param_names() ++ Params.builtin_param_names()
7171
check = check |> to_string |> String.to_existing_atom()
7272

7373
Enum.each(params, fn {param_name, _param_value} ->

0 commit comments

Comments
 (0)