Credence.Semantic (credence v0.6.0)

Copy Markdown

Semantic phase — fixes compiler warnings and errors.

Uses Code.with_diagnostics/1 to compile the source and capture diagnostics without permanently loading modules. Delegates to rules implementing Credence.Semantic.Rule behaviour.

When compilation succeeds, warning-level diagnostics are matched against rules and fixed. When compilation fails, error-level diagnostics are matched first; if any fix is applied, the phase retries (up to max_passes) to catch warnings that only appear once the error is resolved.

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: pass number, severity being targeted, rule name, whether the source changed, and a before/after diff of the lines that were modified.