hank_rule behaviour (rebar3_hank v2.0.0)

View Source

Behavior for defining a rule for Hank.

Summary

Functions

Analyze the given files with the rule.

The list of default rules to apply.

Check if given rule should be ignored from results.

Types

asts()

-type asts() :: [{file:filename(), erl_syntax:forms()}].

ignore_pattern()

-type ignore_pattern() :: undefined | tuple().

ignore_spec()

-type ignore_spec() :: {file:filename(), t() | all} | {file:filename(), t(), term()}.

result()

-type result() ::
          #{file := file:filename(),
            line := non_neg_integer(),
            text := iodata(),
            rule => t(),
            pattern => ignore_pattern()}.

t()

-type t() :: module().

Callbacks

analyze/2

-callback analyze(asts(), hank_context:t()) -> [result()].

ignored/2

-callback ignored(ignore_pattern(), term()) -> boolean().

Functions

analyze(Rule, ASTs, Context)

-spec analyze(t(), asts(), hank_context:t()) -> [result()].

Analyze the given files with the rule.

default_rules()

-spec default_rules() -> [].

The list of default rules to apply.

is_ignored(Rule, Pattern, IgnoreSpec)

-spec is_ignored(t(), ignore_pattern(), all | term()) -> boolean().

Check if given rule should be ignored from results.