Credence.Syntax (credence v0.6.0)

Copy Markdown

Syntax phase — fixes code that won't parse.

Only runs when Sourceror.parse_string/1 fails. Delegates to rules implementing Credence.Syntax.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(source, opts \\ [])

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

fix(source, opts \\ [])

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

fix_with_trace(source, 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, whether the source changed, and a before/after diff of the lines that were modified. If the source already parses, the pipeline is skipped entirely.