feat(pattern): add expected param for must-contain checks #81

Closed
opened 2026-05-26 10:27:51 +02:00 by michael · 2 comments
Owner

Goal

Extend the pattern primitive to support expected: false, so rules can
warn when a pattern is NOT found in a file.

Motivation

Rules like test-has-package-path and test-has-summarize need to check
that test files contain a required pattern. The contains primitive only
works on project-level fixed paths (target.type == "project"), not on
matched files.

Proposed rule usage

when:
  file_pattern: "test/*.lua"
check:
  primitive: daw.fragjan.check.pattern
  pattern: "package.path"
  expected: true
result:
  severity: warn
  message: "{file} -- missing package.path setup"

Acceptance criteria

  • pattern primitive supports optional expected param (default: true)
  • expected: true -> warn if pattern NOT found
  • expected: false -> warn if pattern IS found (existing behaviour)
  • test-has-package-path and test-has-summarize rules added to daw-code pack
  • Repo: DAW/daw-modul-fragjan-check-pattern
## Goal Extend the `pattern` primitive to support `expected: false`, so rules can warn when a pattern is NOT found in a file. ## Motivation Rules like `test-has-package-path` and `test-has-summarize` need to check that test files contain a required pattern. The `contains` primitive only works on project-level fixed paths (target.type == "project"), not on matched files. ## Proposed rule usage ```yaml when: file_pattern: "test/*.lua" check: primitive: daw.fragjan.check.pattern pattern: "package.path" expected: true result: severity: warn message: "{file} -- missing package.path setup" ``` ## Acceptance criteria - [ ] pattern primitive supports optional `expected` param (default: true) - [ ] expected: true -> warn if pattern NOT found - [ ] expected: false -> warn if pattern IS found (existing behaviour) - [ ] test-has-package-path and test-has-summarize rules added to daw-code pack - [ ] Repo: DAW/daw-modul-fragjan-check-pattern
michael added this to the Basic Version milestone 2026-05-30 16:08:42 +02:00
Author
Owner

Blocked by DAW/fragjan#102 (feat(runner): flexible scan targets --
file_include, glob patterns, single file, auto-root detection).

Blocked by DAW/fragjan#102 (feat(runner): flexible scan targets -- file_include, glob patterns, single file, auto-root detection).
Author
Owner

Completed in v0.2.10

  • expected param added to daw.fragjan.check.pattern (0.1.7)
    • expected: true -- warn if pattern NOT found
    • expected: false -- warn if pattern IS found (existing behaviour)
  • file_path added to rule when clause in core/runner/init.lua
    • restricts search to subpath of project_root
    • project-level excludes ignored when file_path is set
  • Fixed core/runner/file.lua: status not overridden to pass when
    expected=true and matches is empty
  • test-has-package-path and test-has-summarize added to daw-lua-code
    • use file_path: "test/" with file_exclude for helper files

Note: rule YAMLs in var/rules/ are not tracked in fragjan repo.

## Completed in v0.2.10 - expected param added to daw.fragjan.check.pattern (0.1.7) - expected: true -- warn if pattern NOT found - expected: false -- warn if pattern IS found (existing behaviour) - file_path added to rule when clause in core/runner/init.lua - restricts search to subpath of project_root - project-level excludes ignored when file_path is set - Fixed core/runner/file.lua: status not overridden to pass when expected=true and matches is empty - test-has-package-path and test-has-summarize added to daw-lua-code - use file_path: "test/" with file_exclude for helper files Note: rule YAMLs in var/rules/ are not tracked in fragjan repo.
michael 2026-05-31 13:26:34 +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#81
No description provided.