-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Thanks for the linter – it’s great.
I wanted to share a use‑case that the current checks don’t cover yet, and suggest a first‑iteration implementation.
Example usage
func TestFoo(t *testing.T) {
sut := newSUT(t)
got := sut.Do()
assert.NotNil(t, got)
}where the helper looks like:
func newSUT(t *testing.T) *sut {
t.Helper()
t.Parallel()
return &sut{
// something...
}
}In this pattern the test creates a fixture (newSUT) that calls t.Parallel. The linter should be able to detect such cases and ignore them.
Proposed first‑iteration algorithm
- Find all calls to unexported functions from a test (
*_test.go). - For each such function, check whether it has a
*testing.T(ortesting.T) parameter. - Scan the function body for a call to
t.Parallel(). - Recursively analyze any nested helper calls.
This should be relatively straightforward to implement and would catch a large portion of the current false‑positives.
Future extensions
- Detect similar patterns in functions imported from other packages.
- Handle additional testing utilities, etc.
Why this matters
Adding this check would directly address the issue discussed in #49, especially since these helper functions are often used in fixtures.
I’d be happy to contribute an implementation if that sounds useful—just let me know the best way to get started!
Metadata
Metadata
Assignees
Labels
No labels