runner: unresolved placeholders in rule messages are printed literally #159

Open
opened 2026-11-21 09:27:32 +01:00 by michael · 0 comments
Owner

Problem

expand_message in core/runner/file.lua and core/runner/project.lua
leaves a placeholder as literal text when no value exists for it
({key} stays {key}). The file runner sets {line} and {value} only if
the result carries metrics.matches. A rule that reports a missing thing
(no match) and uses {line} in its message therefore prints the raw placeholder:

[ERROR] init.lua:{line} -- init.lua metadata missing provides field

The project runner knows only {dir}.

Scope

  • decide what an unresolved placeholder does: drop it together with its
    surrounding separator (init.lua:{line} becomes init.lua), or report the
    rule as faulty so the author notices
  • document the placeholders each runner provides ({dir}, {line}, {value}, ...)

Acceptance criteria

  • tests first: a file rule without matches and a message with {line} does not print {line}
  • tests first: a project rule with an unknown placeholder behaves as decided
  • make test passes (Lua 5.4 and 5.1)

Technical notes

  • seen with fragjan code on a module whose init.lua lacks a provides field
  • both runners carry their own copy of expand_message; a shared helper would remove the duplicate
## Problem `expand_message` in `core/runner/file.lua` and `core/runner/project.lua` leaves a placeholder as literal text when no value exists for it (`{key}` stays `{key}`). The file runner sets `{line}` and `{value}` only if the result carries `metrics.matches`. A rule that reports a missing thing (no match) and uses `{line}` in its message therefore prints the raw placeholder: [ERROR] init.lua:{line} -- init.lua metadata missing provides field The project runner knows only `{dir}`. ## Scope - decide what an unresolved placeholder does: drop it together with its surrounding separator (`init.lua:{line}` becomes `init.lua`), or report the rule as faulty so the author notices - document the placeholders each runner provides (`{dir}`, `{line}`, `{value}`, ...) ## Acceptance criteria - [ ] tests first: a file rule without matches and a message with `{line}` does not print `{line}` - [ ] tests first: a project rule with an unknown placeholder behaves as decided - [ ] `make test` passes (Lua 5.4 and 5.1) ## Technical notes - seen with `fragjan code` on a module whose `init.lua` lacks a `provides` field - both runners carry their own copy of `expand_message`; a shared helper would remove the duplicate
Sign in to join this conversation.
No milestone
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#159
No description provided.