Ancora.Finding (ancora v1.0.0)

Copy Markdown View Source

Closed 30-code finding registry: the single source every other module reads.

Each code has a family, a default severity, and a message function whose text names the subject or file and the action that clears the finding. Adding a code is a spec change in ancora.findings.

Summary

Functions

Every registry code, in declaration order.

Registry default severity for code.

Family prefix (derived, spec, …).

True when code is in the registry.

Renders the designed message for code.

Builds a finding. message is rendered from code and attrs when omitted.

The closed registry: code → %{family, default, message}.

False for config/unknown_key and config/invalid_value.

Types

code()

@type code() :: String.t()

entry()

@type entry() :: %{
  family: String.t(),
  default: :error | :warning | :info,
  message: (map() -> String.t())
}

severity()

@type severity() :: :error | :warning | :info | :off

source()

@type source() :: :config | :trailer | :default

t()

@type t() :: %Ancora.Finding{
  code: code(),
  file: String.t() | nil,
  message: String.t() | nil,
  severity: severity() | nil,
  severity_source: source() | nil,
  subject: String.t() | nil
}

Functions

codes()

@spec codes() :: [code()]

Every registry code, in declaration order.

default_severity(code)

@spec default_severity(code()) :: :error | :warning | :info

Registry default severity for code.

family(code)

@spec family(code()) :: String.t()

Family prefix (derived, spec, …).

known?(code)

@spec known?(term()) :: boolean()

True when code is in the registry.

message(code, ctx \\ %{})

@spec message(code(), map()) :: String.t()

Renders the designed message for code.

Context keys used across codes: :subject, :file, :requirement, :detail, :key. Missing keys fall back to placeholders so the registry-closure test can call every message function.

new(attrs)

@spec new(keyword() | map()) :: t()

Builds a finding. message is rendered from code and attrs when omitted.

registry()

@spec registry() :: %{optional(code()) => entry()}

The closed registry: code → %{family, default, message}.

tunable?(code)

@spec tunable?(code()) :: boolean()

False for config/unknown_key and config/invalid_value.

Non-tunable codes ignore severities:, overrides:, and Spec-Ack: trailers so a misconfigured file cannot silence the config findings it itself produces.