diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-10 14:17:33 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-11 15:03:14 +0300 |
commit | 1946de54c07b881e072a0d8629a4ffe58ef65edb (patch) | |
tree | 627c0852ccd4d706435f2c0f867f7c8635cf9bdf | |
parent | 3b6e4a13fcda407cdfa1f37874fd3fc04e8c0421 (diff) |
golangci-lint: Enforce that `testing.T` must be first parameter
Enforce that `testing.T` et al must be the first parameter of test
functions. Unfortuntately, the linter explicitly allows for contexts to
precede `testing.T`, which causes us to still not enforce a uniform
style for our test functions.
Fix cases where we violate this rule.
-rw-r--r-- | .golangci.yml | 3 | ||||
-rw-r--r-- | internal/gitaly/service/commit/find_commit_test.go | 6 | ||||
-rw-r--r-- | internal/logsanitizer/url_test.go | 6 |
3 files changed, 6 insertions, 9 deletions
diff --git a/.golangci.yml b/.golangci.yml index cced853f6..3f4398b45 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -76,13 +76,10 @@ linters-settings: checks: [ "all", "-ST1000" ] thelper: test: - first: false begin: false benchmark: - first: false begin: false tb: - first: false name: false begin: false diff --git a/internal/gitaly/service/commit/find_commit_test.go b/internal/gitaly/service/commit/find_commit_test.go index 3ecfd38e0..d7d2a962e 100644 --- a/internal/gitaly/service/commit/find_commit_test.go +++ b/internal/gitaly/service/commit/find_commit_test.go @@ -291,14 +291,14 @@ func TestFailedFindCommitRequest(t *testing.T) { } func BenchmarkFindCommitNoCache(b *testing.B) { - benchmarkFindCommit(false, b) + benchmarkFindCommit(b, false) } func BenchmarkFindCommitWithCache(b *testing.B) { - benchmarkFindCommit(true, b) + benchmarkFindCommit(b, true) } -func benchmarkFindCommit(withCache bool, b *testing.B) { +func benchmarkFindCommit(b *testing.B, withCache bool) { ctx := testhelper.Context(b) cfg, repo, _, client := setupCommitServiceWithRepo(ctx, b) diff --git a/internal/logsanitizer/url_test.go b/internal/logsanitizer/url_test.go index fd2e264ff..8be57d237 100644 --- a/internal/logsanitizer/url_test.go +++ b/internal/logsanitizer/url_test.go @@ -106,7 +106,7 @@ func BenchmarkUrlSanitizerWithoutSanitization(b *testing.B) { logger.Out = io.Discard logger.Hooks.Add(urlSanitizer) - benchmarkLogging(logger, b) + benchmarkLogging(b, logger) } func BenchmarkUrlSanitizerWithSanitization(b *testing.B) { @@ -120,10 +120,10 @@ func BenchmarkUrlSanitizerWithSanitization(b *testing.B) { logger.Out = io.Discard logger.Hooks.Add(urlSanitizer) - benchmarkLogging(logger, b) + benchmarkLogging(b, logger) } -func benchmarkLogging(logger *log.Logger, b *testing.B) { +func benchmarkLogging(b *testing.B, logger *log.Logger) { for n := 0; n < b.N; n++ { logger.WithFields(log.Fields{ "grpc.method": "CreateRepositoryFromURL", |