feat(primitive): lua-metadata primitive for init.lua metadata block checks #18

Open
opened 2026-05-19 20:37:59 +02:00 by michael · 0 comments
Owner

Problem

The init-has-* rules in daw-module pack use the pattern primitive to
check for metadata fields (id, version, tier, type, provides) in init.lua.
This causes false positives when the same field names appear in other
contexts (e.g. return tables, local variables).

Example: init.lua line 162 -- type = "git" in a return table triggers
the init-has-type rule even though the metadata block is correct.

Solution

New primitive: daw.fragjan.check.lua-metadata

Finds the local M = { block in a Lua file and checks for required
fields only within that block. Independent of indentation and position
in the file.

params:
field: "type" -- field name to check
block: "M" -- table variable name (default: "M")

Affected Files

  • new repo: DAW/daw-modul-fragjan-check-lua-metadata
  • var/rules/daw-module/rules/init-has-*.yaml: switch primitive once available

Notes

Current init-has-* rules remain active but produce false positives
until this primitive is available.
Pattern primitive is not suitable for structured Lua code analysis.

## Problem The init-has-* rules in daw-module pack use the pattern primitive to check for metadata fields (id, version, tier, type, provides) in init.lua. This causes false positives when the same field names appear in other contexts (e.g. return tables, local variables). Example: init.lua line 162 -- `type = "git"` in a return table triggers the init-has-type rule even though the metadata block is correct. ## Solution New primitive: daw.fragjan.check.lua-metadata Finds the `local M = {` block in a Lua file and checks for required fields only within that block. Independent of indentation and position in the file. params: field: "type" -- field name to check block: "M" -- table variable name (default: "M") ## Affected Files - new repo: DAW/daw-modul-fragjan-check-lua-metadata - var/rules/daw-module/rules/init-has-*.yaml: switch primitive once available ## Notes Current init-has-* rules remain active but produce false positives until this primitive is available. Pattern primitive is not suitable for structured Lua code analysis.
michael added this to the Basic Version milestone 2026-05-30 16:08:29 +02:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#18
No description provided.