list_command.ex (1770B)
1 defmodule Credo.CLI.Command.List.ListCommand do 2 @moduledoc false 3 4 use Credo.CLI.Command, 5 short_description: "List all issues grouped by files", 6 cli_switches: Credo.CLI.Command.Suggest.SuggestCommand.cli_switches() 7 8 alias Credo.CLI.Command.List.ListOutput 9 alias Credo.CLI.Filter 10 alias Credo.CLI.Task 11 alias Credo.Execution 12 13 def init(exec) do 14 Execution.put_pipeline(exec, "list", 15 load_and_validate_source_files: [ 16 {Task.LoadAndValidateSourceFiles, []} 17 ], 18 prepare_analysis: [ 19 {Task.PrepareChecksToRun, []} 20 ], 21 print_before_analysis: [ 22 {__MODULE__.PrintBeforeInfo, []} 23 ], 24 run_analysis: [ 25 {Task.RunChecks, []} 26 ], 27 filter_issues: [ 28 {Task.SetRelevantIssues, []} 29 ], 30 print_after_analysis: [ 31 {__MODULE__.PrintResultsAndSummary, []} 32 ] 33 ) 34 end 35 36 @doc false 37 def call(%Execution{help: true} = exec, _opts), do: ListOutput.print_help(exec) 38 def call(exec, _opts), do: Execution.run_pipeline(exec, __MODULE__) 39 40 defmodule PrintBeforeInfo do 41 @moduledoc false 42 43 use Credo.Execution.Task 44 45 def call(exec, _opts) do 46 source_files = 47 exec 48 |> Execution.get_source_files() 49 |> Filter.important(exec) 50 51 ListOutput.print_before_info(source_files, exec) 52 53 exec 54 end 55 end 56 57 defmodule PrintResultsAndSummary do 58 @moduledoc false 59 60 use Credo.Execution.Task 61 62 def call(exec, _opts) do 63 source_files = Execution.get_source_files(exec) 64 65 time_load = Execution.get_assign(exec, "credo.time.source_files") 66 time_run = Execution.get_assign(exec, "credo.time.run_checks") 67 68 ListOutput.print_after_info(source_files, exec, time_load, time_run) 69 70 exec 71 end 72 end 73 end