Skip to content

Commit f23fda9

Browse files
committed
change autocorrect to autofix
1 parent acd96bb commit f23fda9

16 files changed

Lines changed: 60 additions & 60 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

lib/credo/check.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ defmodule Credo.Check do
154154
Credo.Issue.t()
155155

156156
@doc false
157-
@callback autocorrect(source_file :: String.t(), issue :: Issue.t()) :: String.t()
157+
@callback autofix(source_file :: String.t(), issue :: Issue.t()) :: String.t()
158158

159159
@base_category_exit_status_map %{
160160
consistency: 1,
@@ -400,7 +400,7 @@ defmodule Credo.Check do
400400

401401
@doc false
402402
@impl true
403-
def autocorrect(source_file, _issue) do
403+
def autofix(source_file, _issue) do
404404
source_file
405405
end
406406

lib/credo/check/consistency/line_endings.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ defmodule Credo.Check.Consistency.LineEndings do
4545
"File is using unix line endings while most of the files use windows line endings."
4646
end
4747

48-
def autocorrect(file, issue) do
48+
def autofix(file, issue) do
4949
if issue.message == message_for(:windows) do
50-
do_autocorrect(file, :unix_to_windows)
50+
do_autofix(file, :unix_to_windows)
5151
else
52-
do_autocorrect(file, :windows_to_unix)
52+
do_autofix(file, :windows_to_unix)
5353
end
5454
end
5555

56-
defp do_autocorrect(file, :windows_to_unix), do: String.replace(file, "\r\n", "\n")
57-
defp do_autocorrect(file, :unix_to_windows), do: String.replace(file, "\n", "\r\n")
56+
defp do_autofix(file, :windows_to_unix), do: String.replace(file, "\r\n", "\n")
57+
defp do_autofix(file, :unix_to_windows), do: String.replace(file, "\n", "\r\n")
5858
end

lib/credo/check/readability/alias_order.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,20 @@ defmodule Credo.Check.Readability.AliasOrder do
224224
)
225225
end
226226

227-
def autocorrect(file, _issue) do
227+
def autofix(file, _issue) do
228228
{:ok, quoted} = :"Elixir.Code".string_to_quoted(file)
229229

230230
modified =
231231
quoted
232-
|> Macro.prewalk(&do_autocorrect/1)
232+
|> Macro.prewalk(&do_autofix/1)
233233
|> Macro.to_string()
234234
|> :"Elixir.Code".format_string!()
235235
|> to_string()
236236

237237
"#{modified}\n"
238238
end
239239

240-
defp do_autocorrect({:__block__ = op, meta, [{:alias, _, _} | _] = aliases}) do
240+
defp do_autofix({:__block__ = op, meta, [{:alias, _, _} | _] = aliases}) do
241241
modified =
242242
aliases
243243
|> group_aliases()
@@ -253,7 +253,7 @@ defmodule Credo.Check.Readability.AliasOrder do
253253
{op, Keyword.delete(meta, :line), modified}
254254
end
255255

256-
defp do_autocorrect(ast), do: ast
256+
defp do_autofix(ast), do: ast
257257

258258
defp put_line_number([{op, meta, args} | tail], line) do
259259
modified = {op, Keyword.put(meta, :line, line), args}

lib/credo/check/readability/trailing_blank_line.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule Credo.Check.Readability.TrailingBlankLine do
4040
)
4141
end
4242

43-
def autocorrect(file, _issue) do
43+
def autofix(file, _issue) do
4444
"#{file}\n"
4545
end
4646
end

lib/credo/check/refactor/unless_with_else.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,22 @@ defmodule Credo.Check.Refactor.UnlessWithElse do
7272
)
7373
end
7474

75-
def autocorrect(file, _issue) do
75+
def autofix(file, _issue) do
7676
{:ok, quoted} = :"Elixir.Code".string_to_quoted(file)
7777

7878
modified =
7979
quoted
80-
|> Macro.prewalk(&do_autocorrect/1)
80+
|> Macro.prewalk(&do_autofix/1)
8181
|> Macro.to_string()
8282
|> :"Elixir.Code".format_string!()
8383
|> to_string()
8484

8585
"#{modified}\n"
8686
end
8787

88-
defp do_autocorrect({:unless, meta, [clause, [do: falsy, else: truthy]]}) do
88+
defp do_autofix({:unless, meta, [clause, [do: falsy, else: truthy]]}) do
8989
{:if, meta, [clause, [do: truthy, else: falsy]]}
9090
end
9191

92-
defp do_autocorrect(ast), do: ast
92+
defp do_autofix(ast), do: ast
9393
end

lib/credo/check/warning/unused_string_operation.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ defmodule Credo.Check.Warning.UnusedStringOperation do
4646
)
4747
end
4848

49-
def autocorrect(file, _issue) do
49+
def autofix(file, _issue) do
5050
{_, quoted} = Credo.Code.ast(file)
5151
source_file = SourceFile.parse(file, "nofile")
5252

@@ -60,15 +60,15 @@ defmodule Credo.Check.Warning.UnusedStringOperation do
6060

6161
modified =
6262
quoted
63-
|> Macro.prewalk(&do_autocorrect(&1, unused_calls))
63+
|> Macro.prewalk(&do_autofix(&1, unused_calls))
6464
|> Macro.to_string()
6565
|> :"Elixir.Code".format_string!()
6666
|> to_string()
6767

6868
"#{modified}\n"
6969
end
7070

71-
defp do_autocorrect({:__block__, meta, [{:|>, _pipe_meta, pipe_args} | tail] = args}, unused_calls) do
71+
defp do_autofix({:__block__, meta, [{:|>, _pipe_meta, pipe_args} | tail] = args}, unused_calls) do
7272
args =
7373
if List.last(pipe_args) in unused_calls do
7474
[hd(pipe_args) | tail]
@@ -79,13 +79,13 @@ defmodule Credo.Check.Warning.UnusedStringOperation do
7979
{:__block__, meta, args}
8080
end
8181

82-
defp do_autocorrect({:__block__, meta, args}, unused_calls) do
82+
defp do_autofix({:__block__, meta, args}, unused_calls) do
8383
{:__block__, meta, Enum.reject(args, & &1 in unused_calls)}
8484
end
8585

86-
defp do_autocorrect({:do, node}, unused_calls) do
87-
{:do, do_autocorrect(node, unused_calls)}
86+
defp do_autofix({:do, node}, unused_calls) do
87+
{:do, do_autofix(node, unused_calls)}
8888
end
8989

90-
defp do_autocorrect(ast, _), do: ast
90+
defp do_autofix(ast, _), do: ast
9191
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule Credo.CLI.Command.Suggest.SuggestCommand do
3030
Switch.boolean("read_from_stdin"),
3131
Switch.boolean("strict"),
3232
Switch.boolean("verbose"),
33-
Switch.boolean("autocorrect"),
33+
Switch.boolean("autofix"),
3434
Switch.boolean("watch")
3535
]
3636

@@ -42,7 +42,7 @@ defmodule Credo.CLI.Command.Suggest.SuggestCommand do
4242
print_before_analysis: [__MODULE__.PrintBeforeInfo],
4343
run_analysis: [Task.RunChecks],
4444
filter_issues: [Task.SetRelevantIssues],
45-
run_autocorrect: [Task.RunAutocorrect],
45+
run_autofix: [Task.RunAutofix],
4646
print_after_analysis: [__MODULE__.PrintResultsAndSummary]
4747
)
4848
end

lib/credo/cli/task/run_autocorrect.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
defmodule Credo.CLI.Task.RunAutocorrect do
1+
defmodule Credo.CLI.Task.RunAutofix do
22
@moduledoc false
33

44
use Credo.Execution.Task
55

66
def call(exec, opts, read_fun \\ &File.read!/1, write_fun \\ &File.write!/2) do
7-
if exec.autocorrect do
7+
if exec.autofix do
88
issues = Keyword.get_lazy(opts, :issues, fn -> Execution.get_issues(exec) end)
99

1010
issues
1111
|> group_by_file
1212
|> Enum.each(fn {file_path, issues} ->
1313
file = read_fun.(file_path)
1414

15-
corrected = Enum.reduce(issues, file, &run_autocorrect(&1, &2, exec))
15+
corrected = Enum.reduce(issues, file, &run_autofix(&1, &2, exec))
1616

1717
write_fun.(file_path, corrected)
1818
end)
@@ -27,8 +27,8 @@ defmodule Credo.CLI.Task.RunAutocorrect do
2727
end)
2828
end
2929

30-
defp run_autocorrect(issue, file, exec) do
31-
case issue.check.autocorrect(file, issue) do
30+
defp run_autofix(issue, file, exec) do
31+
case issue.check.autofix(file, issue) do
3232
^file ->
3333
file
3434

lib/credo/config_builder.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ defmodule Credo.ConfigBuilder do
8181
|> add_switch_ignore(switches)
8282
|> add_switch_mute_exit_status(switches)
8383
|> add_switch_only(switches)
84-
|> add_switch_autocorrect(switches)
84+
|> add_switch_autofix(switches)
8585
|> add_switch_read_from_stdin(switches)
8686
|> add_switch_strict(switches)
8787
|> add_switch_min_priority(switches)
@@ -263,13 +263,13 @@ defmodule Credo.ConfigBuilder do
263263

264264
defp add_switch_only(exec, _), do: exec
265265

266-
# add_switch_autocorrect
266+
# add_switch_autofix
267267

268-
defp add_switch_autocorrect(exec, %{autocorrect: true}) do
269-
%Execution{exec | autocorrect: true}
268+
defp add_switch_autofix(exec, %{autofix: true}) do
269+
%Execution{exec | autofix: true}
270270
end
271271

272-
defp add_switch_autocorrect(exec, _), do: exec
272+
defp add_switch_autofix(exec, _), do: exec
273273

274274
# add_switch_ignore
275275

0 commit comments

Comments
 (0)