Skip to content

Commit 4966cc4

Browse files
committed
suite-broken-parallel: self-review
1 parent f4d3de6 commit 4966cc4

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,7 @@ func (s *MySuite) SetupTest() {
675675
s.T().Parallel() ❌
676676
}
677677

678-
func (s *MySuite) BeforeTest(suiteName, testName string) {
679-
s.T().Parallel() ❌
680-
}
678+
// And other hooks...
681679

682680
func (s *MySuite) TestSomething() {
683681
s.T().Parallel() ❌

internal/checkers/suite_broken_parallel.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import (
1616
// s.T().Parallel()
1717
// }
1818
//
19-
// func (s *MySuite) BeforeTest(suiteName, testName string) {
20-
// s.T().Parallel()
21-
// }
19+
// // And other hooks...
2220
//
2321
// func (s *MySuite) TestSomething() {
2422
// s.T().Parallel()
@@ -65,22 +63,24 @@ func (checker SuiteBrokenParallel) Check(pass *analysis.Pass, insp *inspector.In
6563
continue
6664
}
6765

68-
if isSuiteMethod(pass, fd) {
69-
nextLine := pass.Fset.Position(ce.Pos()).Line + 1
70-
d := newDiagnostic(checker.Name(), ce, report, &analysis.SuggestedFix{
71-
Message: fmt.Sprintf("Remove `%s` call", analysisutil.NodeString(pass.Fset, ce)),
72-
TextEdits: []analysis.TextEdit{
73-
{
74-
Pos: ce.Pos(),
75-
End: pass.Fset.File(ce.Pos()).LineStart(nextLine),
76-
NewText: []byte(""),
77-
},
66+
if !isSuiteMethod(pass, fd) {
67+
continue
68+
}
69+
70+
nextLine := pass.Fset.Position(ce.Pos()).Line + 1
71+
d := newDiagnostic(checker.Name(), ce, report, &analysis.SuggestedFix{
72+
Message: fmt.Sprintf("Remove `%s` call", analysisutil.NodeString(pass.Fset, ce)),
73+
TextEdits: []analysis.TextEdit{
74+
{
75+
Pos: ce.Pos(),
76+
End: pass.Fset.File(ce.Pos()).LineStart(nextLine),
77+
NewText: []byte(""),
7878
},
79-
})
79+
},
80+
})
8081

81-
diagnostics = append(diagnostics, *d)
82-
}
83-
return true
82+
diagnostics = append(diagnostics, *d)
83+
return false
8484
}
8585

8686
return true

0 commit comments

Comments
 (0)