Credence.Pattern (credence v0.4.4)

Copy Markdown

Pattern phase — detects and fixes anti-patterns in Elixir code.

Delegates to the 80+ rules implementing Credence.Pattern.Rule behaviour. Rules are discovered automatically and run in priority order (lower first), with module name as tiebreaker for determinism.

Summary

Functions

Like fix/2, but also returns a list of {rule_module, issue_count} tuples for every rule that actually fired and was applied.

Functions

analyze(code_string, opts \\ [])

@spec analyze(
  String.t(),
  keyword()
) :: [Credence.Issue.t()]

fix(code_string, opts \\ [])

@spec fix(
  String.t(),
  keyword()
) :: String.t()

fix_with_trace(code_string, opts \\ [])

@spec fix_with_trace(
  String.t(),
  keyword()
) :: {String.t(), [{module(), non_neg_integer()}]}

Like fix/2, but also returns a list of {rule_module, issue_count} tuples for every rule that actually fired and was applied.

Every step is logged via Logger.debug with [credence_fix] prefix: rule name, issue count, whether the source changed, and a before/after diff of the lines that were modified.