Credence.Pattern.Rule behaviour (credence v0.4.5)

Copy Markdown

Behaviour for pattern-level rules that detect and fix anti-patterns.

These rules work on parsed ASTs and are the core of Credence's 80+ anti-pattern detection rules.

Summary

Callbacks

Detect issues in the AST. Returns list of issues.

Auto-fix the source code. Returns modified source string.

Whether this rule supports auto-fixing.

Callbacks

check(ast, opts)

@callback check(ast :: Macro.t(), opts :: keyword()) :: [Credence.Issue.t()]

Detect issues in the AST. Returns list of issues.

fix(source, opts)

@callback fix(source :: String.t(), opts :: keyword()) :: String.t()

Auto-fix the source code. Returns modified source string.

fixable?()

@callback fixable?() :: boolean()

Whether this rule supports auto-fixing.

priority()

@callback priority() :: integer()