Implement a linter to check for the order of testing.TB parameter
A follow-up of !6183 (comment 1505963171)
This MR implements an analyzer to detect parameters of test helper functions. testing.TB arguments should always be passed as first parameter, followed by context.Context. This rule is noted in https://gitlab.com/gitlab-org/gitaly/-/blob/master/STYLE.md?ref_type=heads#test-helpers.
-
Bad
func testHelper(paramA string, t *testing.T)
-
Bad
func testHelper(ctx context.Context, t *testing.T)
-
Bad
func testHelper(t *testing.T, paramA string, ctx context.Context)
-
Good
func testHelper(t *testing.T)
-
Good
func testHelper(t *testing.T, ctx context.Context)
-
Good
func testHelper(t *testing.T, ctx context.Context, paramA string)
Edited by Quang-Minh Nguyen