Sdlc/Minitest/SeedSweepAssertion: stay wide, but skip assertions inside a define_method loop #1371
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#1371
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
Rewritten 2026-10-27 (fast-batch-cop-matchers): added the message change of analysis option A (required work 3, acceptance criterion 5).
Sdlc/Minitest/SeedSweepAssertionflags an assertion inside atimesoreachblock. Jared ruled on 2026-10-27 that the cop stays wide: an assertion inside a loop over fixed data is the smell too, because one test runs many cases and a failure does not name the case. The cop has one false positive: a loop that callsdefine_methoddefines one test for each element. Each test has its own name, so a failure names the case. The cop flags the assertion inside the defined method because theeachblock encloses it.Observed
The original ticket asked to flag only loops that use randomness. That scope is overruled: the 17 hits on fixed data stay true positives.
Reproduce
Save as
kinds_test.rband runrubocop --only Sdlc/Minitest/SeedSweepAssertion: it reports an offense at the assertion.Approach
Fix by shape in the matcher, never in a config Exclude list or a test-path exclusion. An assertion whose nearest enclosing block is a
define_method(ordefine_singleton_method) call is not inside a sweep: stop the walk up the ancestors at that block.Required work:
define_methodblock — check: presentdefine_methodinplugins/os-sdlc/lib/os_sdlc/cops/minitest/seed_sweep_assertion/assertion_candidate.rbdefine_methodloop is not the smell — check: presentdefine_methodinplugins/os-sdlc/lint-lessons/*seed-sweep*.ymldocs/lint-lessons/analyses/sdlc-minitest-seed-sweep-assertion.mdsection 8) — check: absentRNG/iteration internalsinplugins/os-sdlc/lib/os_sdlc/cops/minitest/seed_sweep_assertion.rbRejected: flag only loops that use randomness — Jared ruled 2026-10-27 that the cop stays wide; loops over fixed data are true positives.
Rejected: exclude the test file — a file list is a baseline.
Acceptance criteria
%w[a b].each { |n| define_method("test_#{n}") { assert_equal n, n.downcase } }in a_test.rbfile, when the cop runs, then it reports no offense.%w[a b].each { |n| assert_equal n, n.downcase }inside a test method, when the cop runs, then it reports an offense.5.times { assert_operator rand(3), :<, 3 }inside a test method, when the cop runs, then it reports an offense.define_methodblock whose body has its owneachloop with an assertion inside it, when the cop runs, then it reports an offense for that inner loop.%w[a b].each { |n| assert_equal n, n.downcase }inside a test method, when the cop runs, then the message says that many cases run in one test and names the corrections (one assertion per case, one assertion over the set, or a fixed seed).Owner sketch
Origin
define_methodshape.VERDICT: CREATE
Sdlc/Minitest/SeedSweepAssertion: flag only loops that involve randomnessto Sdlc/Minitest/SeedSweepAssertion: stay wide, but skip assertions inside a define_method loop2026-10-27: work started in fast-batch-cop-matchers (AFK). Ticket confirmed valid on main
a02b9458.Resolution
Done: SeedSweepAssertion loop search stops at the first define_method/define_singleton_method block; message names many cases in one test; lesson decision names define_method. Commit
1e9c1b2d(mergedf5310f2b). Ticket rewritten to add the option A message change (AC 5); predicted row J1 (86%).Evidence: AC1-AC5 fixtures in plugins/os-sdlc/tests/cops/seed_sweep_assertion_test.rb; plugins/os-me/test/extract_moment_kinds_test.rb now 0 offenses; suite 2825 runs 0 failures.
Follow-ups: Cop key SeedSweepAssertion no longer describes the wide rule; a rename is a separate change for Jared (cop key is parsed by configs and lessons).