Cerbero.Check.Helpers (cerbero v0.1.0)

Copy Markdown View Source

Shared rule scaffolding: the migration-local fold, message construction, finding assembly.

Summary

Functions

Finding assembly for every check, in-fold or global. source names where the finding anchors: a %Migration{} (only its .file is read — pass the struct whenever one is in hand), a bare file path for callers that only hold a path, or nil for a global finding about no file at all (e.g. snapshot age). Defaults: relations [], engine nil, metadata %{}.

The migration-local fold: judges each operation against the catalog as the operations before it leave it — fun.(op, catalog) returns the findings for one operation, then the op is applied via Catalog.apply/2 so later ops in the same migration see the overlay.

Functions

describe_scale(catalog, table)

@spec describe_scale(Cerbero.Catalog.t(), String.t()) :: String.t()

finding(check_module, severity, message, source, line, opts \\ [])

@spec finding(
  module(),
  Cerbero.Finding.severity(),
  String.t(),
  Cerbero.Migration.t() | String.t() | nil,
  integer() | nil,
  keyword()
) :: Cerbero.Finding.t()

Finding assembly for every check, in-fold or global. source names where the finding anchors: a %Migration{} (only its .file is read — pass the struct whenever one is in hand), a bare file path for callers that only hold a path, or nil for a global finding about no file at all (e.g. snapshot age). Defaults: relations [], engine nil, metadata %{}.

fold_operations(migration, catalog, fun)

@spec fold_operations(Cerbero.Migration.t(), Cerbero.Catalog.t(), (term(),
                                                             Cerbero.Catalog.t() ->
                                                               [
                                                                 Cerbero.Finding.t()
                                                               ])) :: [
  Cerbero.Finding.t()
]

The migration-local fold: judges each operation against the catalog as the operations before it leave it — fun.(op, catalog) returns the findings for one operation, then the op is applied via Catalog.apply/2 so later ops in the same migration see the overlay.

human_rows(n)

@spec human_rows(non_neg_integer()) :: String.t()

lock_name(other)

@spec lock_name(atom()) :: String.t()

stats_date(catalog, table)

@spec stats_date(Cerbero.Catalog.t(), String.t()) :: String.t() | nil