feat(rules): detect or {} silent fallback pattern #46
Labels
No labels
coordination/cross-repo
coordination/needed
effort
large
effort
medium
effort
small
meta/duplicate
meta/planning
meta/wontfix
priority
high
priority
low
priority
medium
session
blocker
session
handover
session
next
status
blocked
status
done
status
in-progress
status
review
status
to-go
type
admin
type/architecture
type
bug
type
config
type
deployment
type
docs
type/documentation
type
enhancement
type
feature
type
handover
type
infrastructure
type
installation
type
maintenance
type
migration
type
research
type
security
type/task
type/tech-debt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
DAW/fragjan#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
fragjan should detect the
or {}silent fallback pattern in Lua code:This pattern swallows nil returns that should be errors.
Challenge
or {}has legitimate uses (e.g. default parameters in pure utilityfunctions). A blanket rule will have false positives.
Options:
or {}-- developer suppresses legitimate casesadapters/,core/)Option 1 with suppression is the low-tech path -- evaluate first.
Acceptance criteria
or {}in target filesAdditional case in core/loader.lua load_pack():
applies_to = data.applies_to or {}
A pack without applies_to silently never matches any project type when using
auto-detection (load_packs_for_type). No warning, pack just disappears.
This was intentional (packs used only via --pack explicitly) but is invisible
when it is a misconfiguration. Should produce [WARN] so the author sees it.
Additional case in core/detect.lua:
Both read_local_config() and read_fragjan_config() silently swallow parse
errors via pcall and return {}. A corrupt .merkwerk or .fragjan produces no
warning -- the user only sees the downstream error 'no project type found'
with no indication why.
Additional case in core/config.lua:
try_parse() silently returns nil on parse errors. A corrupt but present
fragjan.conf produces no warning -- downstream error is 'program config
not found' even though the file exists and is just unparseable.
core/modules.lua: read_require_path() silently returns nil for both missing and corrupt module.conf -- caller cannot distinguish the two cases.
Implemented: pattern widened from ") or {}" to "or {}" to catch non-function-call cases.
Message updated accordingly. 8 matches in fragjan, all plausible, no obvious false positives.