View Source Credo.Execution (Credo v1.7.5)
Every run of Credo is configured via an Credo.Execution
struct, which is created and
manipulated via the Credo.Execution
module.
Summary
Functions
The Credo.Execution
struct is created and manipulated via the Credo.Execution
module.
Builds an Execution struct for the given argv
.
Returns the checks that should be run for a given exec
struct.
Ensures that the given value
is a %Credo.Execution{}
struct, raises an error otherwise.
Returns the assign with the given name
for the given exec
struct (or return the given default
value).
Returns the Credo.CLI.Command
module for the given name
.
Returns the name of the command, which should be run by the given execution.
Returns the value for the given switch_name
.
Returns all issues for the given exec
struct.
Returns all issues for the given exec
struct that relate to the given filename
.
Returns all issues grouped by filename for the given exec
struct.
Returns the Credo.Plugin
module's param value.
Returns the result with the given name
for the given exec
struct (or return the given default
value).
Returns all source files for the given exec
struct.
Returns all valid command names.
Halts further execution of the pipeline meaning all subsequent steps are skipped.
Halts further execution of the pipeline using the given halt_message
.
Puts the given value
with the given name
as assign into the given exec
struct and returns the struct.
Sets the issues for the given exec
struct, overwriting any existing issues.
Puts a given pipeline
in exec
under pipeline_key
.
Puts the given value
with the given name
as result into the given exec
struct.
Runs the pipeline with the given pipeline_key
and returns the result Credo.Execution
struct.
Sets the exec values which strict
implies (if applicable).
Returns the tags for a given check
and its params
.
Functions
The Credo.Execution
struct is created and manipulated via the Credo.Execution
module.
Builds an Execution struct for the given argv
.
Returns the checks that should be run for a given exec
struct.
Takes all checks from the checks:
field of the exec, matches those against
any patterns to include or exclude certain checks given via the command line.
Ensures that the given value
is a %Credo.Execution{}
struct, raises an error otherwise.
Example:
exec
|> mod.init()
|> Credo.Execution.ensure_execution_struct("#{mod}.init/1")
Returns the assign with the given name
for the given exec
struct (or return the given default
value).
Credo.Execution.get_assign(exec, "foo")
# => nil
Credo.Execution.get_assign(exec, "foo", 42)
# => 42
Returns the Credo.CLI.Command
module for the given name
.
Credo.Execution.get_command(exec, "explain")
# => Credo.CLI.Command.Explain.ExplainCommand
Returns the name of the command, which should be run by the given execution.
Credo.Execution.get_command_name(exec)
# => "suggest"
Returns the value for the given switch_name
.
Credo.Execution.get_given_cli_switch(exec, "foo")
# => "bar"
Returns all issues for the given exec
struct.
Returns all issues for the given exec
struct that relate to the given filename
.
Returns all issues grouped by filename for the given exec
struct.
Returns the Credo.Plugin
module's param value.
Credo.Execution.get_command(exec, CredoDemoPlugin, "foo")
# => nil
Credo.Execution.get_command(exec, CredoDemoPlugin, "foo", 42)
# => 42
Returns the result with the given name
for the given exec
struct (or return the given default
value).
Credo.Execution.get_result(exec, "foo")
# => nil
Credo.Execution.get_result(exec, "foo", 42)
# => 42
Returns all source files for the given exec
struct.
Credo.Execution.get_source_files(exec)
# => [%SourceFile<lib/my_project.ex>,
# %SourceFile<lib/credo/my_project/foo.ex>]
Returns all valid command names.
Credo.Execution.get_valid_command_names(exec)
# => ["categories", "diff", "explain", "gen.check", "gen.config", "help", "info",
# "list", "suggest", "version"]
Halts further execution of the pipeline meaning all subsequent steps are skipped.
The error
callback is called for the current Task.
defmodule FooTask do
use Credo.Execution.Task
def call(exec) do
Execution.halt(exec)
end
def error(exec) do
IO.puts("Execution has been halted!")
exec
end
end
Halts further execution of the pipeline using the given halt_message
.
The error
callback is called for the current Task.
If the callback is not implemented, Credo outputs the given halt_message
.
defmodule FooTask do
use Credo.Execution.Task
def call(exec) do
Execution.halt(exec, "Execution has been halted!")
end
end
Puts the given value
with the given name
as assign into the given exec
struct and returns the struct.
Credo.Execution.put_assign(exec, "foo", 42)
# => %Credo.Execution{...}
Sets the issues for the given exec
struct, overwriting any existing issues.
Puts a given pipeline
in exec
under pipeline_key
.
A pipeline is a keyword list of named groups. Each named group is a list of Credo.Execution.Task
modules:
Execution.put_pipeline(exec, :my_pipeline_key,
load_things: [ MyProject.LoadThings ],
run_analysis: [ MyProject.Run ],
print_results: [ MyProject.PrintResults ]
)
A named group can also be a list of two-element tuples, consisting of a Credo.Execution.Task
module and a
keyword list of options, which are passed to the Task module's call/2
function:
Execution.put_pipeline(exec, :my_pipeline_key,
load_things: [ {MyProject.LoadThings, []} ],
run_analysis: [ {MyProject.Run, [foo: "bar"]} ],
print_results: [ {MyProject.PrintResults, []} ]
)
Puts the given value
with the given name
as result into the given exec
struct.
Credo.Execution.put_result(exec, "foo", 42)
# => %Credo.Execution{...}
Runs the pipeline with the given pipeline_key
and returns the result Credo.Execution
struct.
Execution.run_pipeline(exec, :my_pipeline_key)
# => %Credo.Execution{...}
Sets the exec values which strict
implies (if applicable).
Returns the tags for a given check
and its params
.