feat: implement graceful-teardown checker - #305
Open
mmorel-35 wants to merge 1 commit into
Open
Conversation
mmorel-35
force-pushed
the
graceful-teardown
branch
4 times, most recently
from
April 9, 2026 18:24
5a0c1cc to
8f87040
Compare
Copilot AI
added a commit
to mmorel-35/testifylint
that referenced
this pull request
May 28, 2026
…leanup/TearDown functions
mmorel-35
pushed a commit
to mmorel-35/testifylint
that referenced
this pull request
May 28, 2026
…leanup/TearDown functions
mmorel-35
force-pushed
the
graceful-teardown
branch
5 times, most recently
from
August 7, 2026 12:19
6df5f8f to
790ca2e
Compare
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
mmorel-35
force-pushed
the
graceful-teardown
branch
from
August 7, 2026 12:59
790ca2e to
4e23d51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the
graceful-teardownchecker proposed in CONTRIBUTING.md. Usingrequireint.Cleanupcallbacks or suite teardown methods callsruntime.Goexit(), which aborts the goroutine mid-cleanup and can leave resources unreleased.Checker
Detects
require.*calls (includings.Require().Method()) inside:t.Cleanup(func() { ... })TearDownTest,TearDownSuite,AfterTest,HandleStats,TearDownSubTestAutofix
Two fix strategies:
require.X(t, ...)requirequalifier withassert; addassertimport if absent (viaaddImportFix)s.Require().X(...)Require()withAssert()in the method chainThe
addImportFixhelper (ported from thehttp-constbranch) handles existing imports, aliases, name conflicts with top-level declarations, and insertion into the correct import group.Configuration
falsetrueTest coverage
graceful-teardown-no-importtest verifying the autofix correctly inserts theassertimport when the file only importsrequireCloses #142