Skip to content

Commit

Permalink
Show required Elixir version for skipped checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Nov 28, 2024
1 parent 74dd296 commit 2143bd9
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions lib/credo/cli/output.ex
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,39 @@ defmodule Credo.CLI.Output do
:reset,
:faint,
"your version of Elixir (#{System.version()}).\n\n",
"You can deactivate these checks by adding this to the `checks` list in your config:\n"
"You can deactivate these checks by adding them to the `:checks`/`:disabled` list in your config:\n"
]

UI.puts("")
UI.puts(msg)

skipped_checks
|> Enum.map(&check_name/1)
|> print_disabled_check_config
end
UI.puts([
:faint,
"""
checks: %{
disabled: [
"""
|> String.trim_trailing()
])

defp check_name({check, _check_info}), do: check_name({check})
skipped_checks
|> Enum.flat_map(fn {check, params} ->
[
:reset,
:cyan,
" {#{Credo.Code.Module.name(check)}, #{inspect(params)}},\t# requires Elixir #{check.elixir_version()}\n"
]
end)
|> UI.puts()

defp check_name({check}) do
check
|> to_string
|> String.replace(~r/^Elixir\./, "")
UI.puts([
:faint,
"""
# ...
]
}
"""
])
end

defp print_numbered_list(list) do
Expand All @@ -239,17 +255,4 @@ defmodule Credo.CLI.Output do
end)
|> UI.warn()
end

defp print_disabled_check_config(list) do
list
|> Enum.flat_map(fn string ->
[
:reset,
String.pad_leading(" ", 4),
:faint,
"{#{string}, false},\n"
]
end)
|> UI.puts()
end
end

0 comments on commit 2143bd9

Please sign in to comment.