Skip to main content

Categories and severity

A rule's category says what kind of problem a violation of it is. Nine categories are fixed:

CategoryRules about
functional_correctnesswhether the code does what it is meant to do
test_coveragethe tests a change adds or updates
securityprotecting data, access and secrets
performancespeed and use of resources
accessibilityuse by people with disabilities
observabilitylogs, metrics and traces
backwards_compatibilitynot breaking existing callers, data or clients
documentationdocumentation and comments that ship with the code
code_styleconventions of naming, structure and form

A team MAY declare its own categories in the categories list of a .loreconfig. A custom category MUST match the category pattern ^[a-z][a-z0-9_]*$, as the fixed ones do. A category is known for a Lore file when it is fixed, or declared by a .loreconfig that applies to the file: one in the directory that holds the file or above it, up to the Lore root (see .loreconfig).

A rule's category is, in order:

  1. its category attribute;
  2. otherwise, the category of its file's <defaults>;
  3. otherwise, none: the rule's category is null and it gets the warning missing-category, at its opening tag line. A rule without a category is still eligible, so a team can wrap and scope existing rules first and classify them later.

A category that matches the category pattern but is not known is unknown-category: an entry-level error when a rule's attribute names it, and a file-level error when <defaults> names it (see Defaults).

A rule's severity says what a violation costs:

  • blocking: a violation is to be fixed, or explicitly waived, before the change is merged.
  • advisory: a reviewer raises the violation, and the change's author decides what to do.

A rule's severity is its severity attribute, otherwise the severity of its file's <defaults>, otherwise advisory, so a missing value never blocks anyone. A tool MAY map the two levels onto its own scale.

A context has neither: its category and severity are always null.

A declared category is known, an undeclared one excludes its rule, and an undeclared one in <defaults> excludes the whole file, including its rule that names a declared category. A category that does not match the category pattern is an invalid value:

Example 54 (parse)​

.loreconfig
categories: [data_provenance]
.lore/provenance.lore
<rule id="price-source-recorded" category="data_provenance">
Every stored price records the quote it came from.
</rule>

<rule id="currency-source-recorded" category="data_lineage">
Every stored amount records the currency setting it was formatted with.
</rule>

<rule id="tax-source-recorded" category="Data_Provenance">
Every stored tax amount records the tax table it came from.
</rule>
.lore/lineage.lore
<defaults>
category: data_lineage
</defaults>

<rule id="quote-source-recorded" category="data_provenance">
Every stored quote records the cart it priced.
</rule>
Expected output
{
"entries": [
{
"kind": "rule", "id": "price-source-recorded", "file": ".lore/provenance.lore",
"category": "data_provenance", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Every stored price records the quote it came from.",
"prose": "Every stored price records the quote it came from.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "unknown-category", "file": ".lore/lineage.lore", "entry": null, "line": 1 },
{ "name": "unknown-category", "file": ".lore/provenance.lore", "entry": "currency-source-recorded", "line": 5 },
{ "name": "invalid-attribute-value", "file": ".lore/provenance.lore", "entry": "tax-source-recorded", "line": 9 }
],
"warnings": []
}

A rule with no category anywhere is read, with a null category and a warning. A context never gets that warning:

Example 55 (parse)​

.lore/checkout.lore
<rule id="price-from-quote" severity="blocking">
A displayed price must come from the quote that produced it.
</rule>

<context id="checkout-architecture" src="ARCHITECTURE.md">
Read before judging any change to how a price is computed.
</context>
Expected output
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": null, "severity": "blocking", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A displayed price must come from the quote that produced it.",
"prose": "A displayed price must come from the quote that produced it.",
"src": null,
"sources": []
},
{
"kind": "context", "id": "checkout-architecture", "file": ".lore/checkout.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Read before judging any change to how a price is computed.",
"prose": "Read before judging any change to how a price is computed.",
"src": "ARCHITECTURE.md",
"sources": []
}
],
"errors": [],
"warnings": [
{ "name": "missing-category", "file": ".lore/checkout.lore", "entry": "price-from-quote", "line": 1 }
]
}

With a severity in neither the rule nor <defaults>, the rule is advisory:

Example 56 (parse)​

.lore/checkout.lore
<defaults>
category: functional_correctness
</defaults>

<rule id="price-from-quote">
A displayed price must come from the quote that produced it.
</rule>
Expected output
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A displayed price must come from the quote that produced it.",
"prose": "A displayed price must come from the quote that produced it.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}