Credo v1.1.5 Credo.Check behaviour View Source

Check modules represent the checks which are run during Credo’s analysis.

Example:

defmodule MyCheck do
  use Credo.Check, category: :warning, base_priority: :high

  def run(source_file, params) do
    #
  end
end

The run/2 function takes two parameters: a source file and a list of parameters for the check. It has to return a list of found issues.

Link to this section Summary

Functions

format_issue takes an issue_meta and returns an issue. The resulting issue can be made more explicit by passing the following options to format_issue/2

Converts a given category to an exit status

Callbacks

Returns the base priority for the check

Returns the category for the check

Link to this section Types

Link to this section Functions

Link to this function explanation_for(keywords, key) View Source
Link to this function format_issue(issue_meta, opts, issue_category, issue_base_priority, check) View Source

format_issue takes an issue_meta and returns an issue. The resulting issue can be made more explicit by passing the following options to format_issue/2:

  • :priority Sets the issue’s priority.
  • :trigger Sets the issue’s trigger.
  • :line_no Sets the issue’s line number. Tries to find column if :trigger is supplied.
  • :column Sets the issue’s column.
  • :exit_status Sets the issue’s exit_status.
  • :severity Sets the issue’s severity.

Converts a given category to an exit status

Link to this section Callbacks

Link to this callback base_priority() View Source
base_priority() :: integer()

Returns the base priority for the check.

Link to this callback category() View Source
category() :: atom()

Returns the category for the check.

Link to this callback explanation() View Source
explanation() :: String.t()
Link to this callback explanation_for_params() View Source
explanation_for_params() :: Keyword.t()
Link to this callback format_issue(issue_meta, opts) View Source
format_issue(issue_meta :: Credo.IssueMeta.t(), opts :: Keyword.t()) ::
  Issue.t()
Link to this callback run_on_all?() View Source
run_on_all?() :: boolean()