feat(rules): detect os.exit and :exit() calls outside main.lua #48

Closed
opened 2026-05-25 13:48:33 +02:00 by michael · 1 comment
Owner

Goal

fragjan should detect os.exit( and out:exit( calls outside of main.lua.

Design rule: only main.lua is allowed to terminate the process.
Any exit call elsewhere is a bug.

Approach

Pattern rule with contains on os.exit( and :exit(, with
file_exclude for main.lua. Two separate rules or one combined.

Note: :exit( may have false positives (other objects with an exit method).
os.exit( is unambiguous.

Evaluate whether two targeted rules are cleaner than one broad pattern.

Acceptance criteria

  • os.exit( outside main.lua flagged as error
  • :exit( outside main.lua flagged as warn (false positive risk)
  • main.lua excluded via file_exclude
  • Added to daw-code pack
## Goal fragjan should detect `os.exit(` and `out:exit(` calls outside of `main.lua`. Design rule: only `main.lua` is allowed to terminate the process. Any exit call elsewhere is a bug. ## Approach Pattern rule with `contains` on `os.exit(` and `:exit(`, with `file_exclude` for `main.lua`. Two separate rules or one combined. Note: `:exit(` may have false positives (other objects with an exit method). `os.exit(` is unambiguous. Evaluate whether two targeted rules are cleaner than one broad pattern. ## Acceptance criteria - [ ] `os.exit(` outside `main.lua` flagged as error - [ ] `:exit(` outside `main.lua` flagged as warn (false positive risk) - [ ] `main.lua` excluded via `file_exclude` - [ ] Added to daw-code pack
Author
Owner

Implemented: no-os-exit severity raised to error, no-exit-method rule added as warn.

No os.exit() violations found in fragjan. Two :exit() hits in article.lua:61 and code.lua:51 -- berhtjan-cli calls, expected.

Implemented: no-os-exit severity raised to error, no-exit-method rule added as warn. No os.exit() violations found in fragjan. Two :exit() hits in article.lua:61 and code.lua:51 -- berhtjan-cli calls, expected.
michael 2026-05-26 15:54:11 +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#48
No description provided.