Skip to content

l0.MoonCats.Diagnostics

MoonCatsDiagnostics = require "l0.MoonCats.Diagnostics"
local MoonCatsDiagnostics = require("l0.MoonCats.Diagnostics")

MoonCatsDiagnostics

Collects, classifies, and formats the findings produced while extracting LuaCATS definitions.

Constructor

moonCatsDiagnostics = MoonCatsDiagnostics!
local moonCatsDiagnostics = MoonCatsDiagnostics()

Creates an empty findings collection.

Instance methods

add

moonCatsDiagnostics\add code, requireId, line, ...
moonCatsDiagnostics:add(code, requireId, line, ...)

Records a finding against a module; its severity derives from the finding code.

param type description
code MoonCatsFindingCode
requireId string Require identifier of the module the finding is about.
line? integer 1-based source line the finding anchors to.
... any Values for the finding message's format string.

Returns:

hasCheckFailures

moonCatsDiagnostics\hasCheckFailures!
moonCatsDiagnostics:hasCheckFailures()

Reports whether any finding is severe enough to fail a check run.

Returns:

  • failed boolean — True when at least one error-severity finding was recorded.

getCounts

moonCatsDiagnostics\getCounts!
moonCatsDiagnostics:getCounts()

Returns the number of findings recorded per severity.

Returns:

  • counts table<MoonCatsSeverity, integer> — Keyed by severity value; zero for severities without findings.

format

moonCatsDiagnostics\format!
moonCatsDiagnostics:format()

Formats all findings as one line each, sorted by module, line, and code.

Returns:

  • report string — The formatted findings joined with newlines; empty when there are none.

Fields

field type description
findings MoonCatsFinding[] All findings recorded so far, in insertion order.

Enums

MoonCatsSeverity

member value description
Error "error" fails a check run; the source or the extractor needs fixing
Warning "warning" a construct the extractor degraded gracefully; the definition may be imprecise
Info "info" a benign note about a fallback taken during emission

MoonCatsFindingCode

member value description
ParseFailure "E-PARSE" the MoonScript source failed to parse
MissingDoc "E-MISSING-DOC" a public function member carries no annotation block
ParamNameMismatch "E-PARAM-NAME" a documented parameter name differs from the signature
ParamCountMismatch "E-PARAM-COUNT" the @param tags do not match the signature's parameter count
MissingReturn "E-MISSING-RETURN" the body explicitly returns a value but no @return is documented
EmitFailure "E-EMIT" the emitted definition is not loadable Lua
ComputedKeySkipped "W-COMPUTED-KEY" a member with a computed table key was skipped
UnresolvedReference "W-UNRESOLVED" an identifier could not be resolved and was typed as any
AccessorFieldMissing "W-ACCESSOR-FIELD" a computed property has no matching @field on its class
ClassNameMismatch "W-CLASS-NAME" the @class annotation names a different class than the statement
NoExport "W-NO-EXPORT" the module's export could not be determined
ExternalRequire "I-EXTERNAL-REQUIRE" a required module is outside the extraction run and was typed as any
NestedTableFlattened "I-NESTED-TABLE" a nested table value was flattened to the plain table type
CtorOverloadFallback "I-CTOR-FALLBACK" a subclass without its own constructor got a fun(...) overload
DuplicateMemberFolded "I-DUPLICATE-MEMBER" a same-name member was folded into the primary declaration's overloads

Types

MoonCatsFinding

A single finding produced while extracting definitions.

field type description
severity MoonCatsSeverity
code MoonCatsFindingCode
requireId string Require identifier of the module the finding is about.
line? integer 1-based source line the finding anchors to.
message string Fully formatted human-readable description.