Sdlc/Structural/ExecutableLoadedInTest: match the lesson's shape (tests only) and carve out guarded scripts #1352
Labels
No labels
P0
P1
P2
P3
bug
category/code-change
category/cross-repo
category/eval-run
category/investigation
category/no-test-target
category/owner-ruling
category/prose-artifact
category/recurring-chore
category/structure
category/umbrella
crc-refactor
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
rule-proposal
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#1352
Loading…
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?
Problem
The cop
Sdlc/Structural/ExecutableLoadedInTestmatches anyload/require/require_relativeof abin/path in any file.The lesson signal says "A test file", but the matcher has no test-file check.
It also flags scripts that guard their top level, where the lesson's argv/exit hazard does not exist.
Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md).
Observed
The only hit is
plugins/os-context/eval/bin/check:7. It is not a test. It loadsplugins/os-context/audit/bin/extract, whose top level is guarded byif $PROGRAM_NAME == __FILE__(extract:428).The prescribed fix (move behavior to lib/) is not needed for a guarded script.
Reproduce
n/a: matcher is
plugins/os-sdlc/lib/os_sdlc/cops/executable_loaded_in_test/resolved_path.rb:9-18; run the cop onplugins/os-context/eval/bin/check.Approach
Carve-outs go in the cop matcher, never in a config Exclude list or a test-path exclusion.
Restrict the cop to test files by shape (the file defines a
Minitest::Testsubclass), or rewrite the lesson and message to cover any loader.Skip a load of a script whose top level is wrapped in
if $PROGRAM_NAME == __FILE__or__FILE__ == $0.Required work:
PROGRAM_NAMEinplugins/os-sdlc/lib/os_sdlc/cops/executable_loaded_in_test/*.rbAcceptance criteria
bin/script, when the cop runs, then it reports no offense.bin/script with an unguarded top level, when the cop runs, then it reports an offense.$PROGRAM_NAME == __FILE__, when the cop runs, then it reports no offense.Origin
VERDICT: CREATE