bug(rules): no-direct-sys-new fires on string literals containing module name #110

Closed
opened 2026-06-01 11:37:39 +02:00 by michael · 1 comment
Owner

Problem

The no-direct-sys-new rule matches the string daw.common.sys anywhere
in a line, including inside string literals used for error messages.

Example

return nil, "[ERROR] core.runner.file: daw.common.sys not available: " .. tostring(mod_sys)

This line does not call daw.common.sys -- it only references the name
in an error message string. The rule fires a false positive.

Expected Behaviour

The rule should only match actual require() calls or method calls on
daw.common.sys, not string literals containing the module name.

Acceptance Criteria

  • no-direct-sys-new does not fire on string literals
  • Actual require("daw.common.sys") and .new() calls still detected
  • Same fix applied to similar rules that match module names in strings

Notes

Same pattern likely affects other rules that match module names
(e.g. no-direct-io-stderr, no-unprotected-require).
May require match_type or context awareness in the pattern primitive.

## Problem The `no-direct-sys-new` rule matches the string `daw.common.sys` anywhere in a line, including inside string literals used for error messages. ## Example ```lua return nil, "[ERROR] core.runner.file: daw.common.sys not available: " .. tostring(mod_sys) ``` This line does not call `daw.common.sys` -- it only references the name in an error message string. The rule fires a false positive. ## Expected Behaviour The rule should only match actual require() calls or method calls on daw.common.sys, not string literals containing the module name. ## Acceptance Criteria - [ ] `no-direct-sys-new` does not fire on string literals - [ ] Actual `require("daw.common.sys")` and `.new()` calls still detected - [ ] Same fix applied to similar rules that match module names in strings ## Notes Same pattern likely affects other rules that match module names (e.g. no-direct-io-stderr, no-unprotected-require). May require match_type or context awareness in the pattern primitive.
michael added this to the Basic Version milestone 2026-06-01 13:36:51 +02:00
Author
Owner

Investigated. The pattern primitive does not support string-literal
context awareness. A regex-based fix is not reliably possible in Lua 5.1
(no negative lookahead). Excluding via exclude_if_contains would be
fragile. Deferring -- no fix at this time.

Investigated. The pattern primitive does not support string-literal context awareness. A regex-based fix is not reliably possible in Lua 5.1 (no negative lookahead). Excluding via exclude_if_contains would be fragile. Deferring -- no fix at this time.
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#110
No description provided.