View Source Recode.Task behaviour (Recode v0.6.5)

The behaviour for a recode task.

Summary

Callbacks

Sets a callback to check and manipulate config before any recode task runs.

Applies a task with the given source and opts.

Functions

Returns the category for the given task.

Returns true if the given task provides a check for sources.

Returns true if the given task provides a correction functionality for sources.

Returns the shortdoc for the given task.

Types

@type category() :: atom()
@type config() :: keyword()
@type message() :: String.t()
@type task() :: module()

Callbacks

@callback __attributes__() :: any()
@callback init(config()) :: {:ok, config()} | {:error, message()}

Sets a callback to check and manipulate config before any recode task runs.

When init returns an error tuple, the mix recode task raises an exception with the returned message.

@callback run(source :: Rewrite.Source.t(), opts :: Keyword.t()) :: Rewrite.Source.t()

Applies a task with the given source and opts.

Functions

@spec category(task()) :: category()

Returns the category for the given task.

@spec checker?(task()) :: boolean()

Returns true if the given task provides a check for sources.

@spec corrector?(task()) :: boolean()

Returns true if the given task provides a correction functionality for sources.

@spec shortdoc(task()) :: String.t() | nil

Returns the shortdoc for the given task.

Returns nil if @shortdoc is not available for the task.