feat(rules): detect unprotected require() calls #40

Closed
opened 2026-05-25 11:51:47 +02:00 by michael · 1 comment
Owner

Goal

fragjan should detect unprotected require() calls -- i.e. require( that
is not preceded by pcall( on the same line or assignment.

Challenge

The current pattern primitive uses contains match only. Detecting
"require without pcall" is context-sensitive -- pcall(require, ...) is
fine, bare require(...) is not. This cannot be expressed with a simple
contains check.

Options to investigate

  1. Two-pass pattern rule: flag all require(, suppress lines that also
    contain pcall. Possible with current primitive if suppression works.
  2. Negative pattern primitive: check that a pattern is NOT present on
    the same line as another pattern.
  3. Lua-aware primitive: structural analysis, not string matching.

Option 1 is the low-tech path -- evaluate first.

Acceptance criteria

  • Approach decided and documented
  • Rule detects bare require( without pcall
  • pcall(require, ...) form is not flagged
## Goal fragjan should detect unprotected `require()` calls -- i.e. `require(` that is not preceded by `pcall(` on the same line or assignment. ## Challenge The current `pattern` primitive uses `contains` match only. Detecting "require without pcall" is context-sensitive -- `pcall(require, ...)` is fine, bare `require(...)` is not. This cannot be expressed with a simple `contains` check. ## Options to investigate 1. **Two-pass pattern rule**: flag all `require(`, suppress lines that also contain `pcall`. Possible with current primitive if suppression works. 2. **Negative pattern primitive**: check that a pattern is NOT present on the same line as another pattern. 3. **Lua-aware primitive**: structural analysis, not string matching. Option 1 is the low-tech path -- evaluate first. ## Acceptance criteria - [ ] Approach decided and documented - [ ] Rule detects bare `require(` without pcall - [ ] `pcall(require, ...)` form is not flagged
Author
Owner

Done

New primitive daw.fragjan.check.linepattern implemented and installed
(daw-modul-fragjan-check-linepattern 0.1.1+09b9c01b).

Rule no-unprotected-require.yaml added to daw-code pack.
Verified against DAW/fragjan -- findings correct.

Notes

fragjan itself has many unprotected require() calls -- separate cleanup
issue to be created.

## Done New primitive daw.fragjan.check.linepattern implemented and installed (daw-modul-fragjan-check-linepattern 0.1.1+09b9c01b). Rule no-unprotected-require.yaml added to daw-code pack. Verified against DAW/fragjan -- findings correct. ## Notes fragjan itself has many unprotected require() calls -- separate cleanup issue to be created.
michael 2026-05-26 07:37:09 +02:00
michael added this to the Basic Version milestone 2026-05-30 16:05:00 +02:00
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#40
No description provided.