Skip to content

feat: add eventually-with-t checker - #311

Open
mmorel-35 wants to merge 2 commits into
Antonboom:masterfrom
mmorel-35:issue-284
Open

feat: add eventually-with-t checker#311
mmorel-35 wants to merge 2 commits into
Antonboom:masterfrom
mmorel-35:issue-284

Conversation

@mmorel-35

@mmorel-35 mmorel-35 commented May 31, 2026

Copy link
Copy Markdown
Contributor

assert.EventuallyWithT provides a *assert.CollectT to the callback for accumulating failures across retries. Using the outer t or require bypasses this mechanism — require calls runtime.Goexit(), killing the tick entirely instead of collecting failures.

New checker: eventually-with-t (enabled by default)

Three violation patterns are detected:

Pattern Autofix
assert.xxx(outerT, ...) — outer t passed instead of collect ✅ replaces arg with collect param name
require.xxx(outerT, ...) — require semantics differ from assert ❌ report only
Assertion object (a := assert.New(t)) used inside callback ❌ report only
a := assert.New(t)
assert.EventuallyWithT(t, func(collect *assert.CollectT) {
    assert.Equal(t, expected, actual)  // ❌ autofix → assert.Equal(collect, ...)
    require.NoError(t, err)            // ❌ use assert.NoError(collect, err)
    a.Equal(expected, actual)          // ❌ a was created with outer t
}, timeout, interval)

Handles both package-level calls (assert.Equal(t, ...)) and assertion-object calls (a.Equal(...)). Nested function literals inside the callback are intentionally excluded to avoid false positives in goroutines or sub-tests.

Closes #284

mmorel-35 added 2 commits May 31, 2026 18:35
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
@Antonboom Antonboom added the llm-based LLM shit label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-based LLM shit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check EventuallyWithT() use assert (not require), use collect, not t

2 participants