diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-10 13:38:49 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-11 15:03:14 +0300 |
commit | 7e87131edb431c2d7d491f29606fe88955b399eb (patch) | |
tree | 104e953f6c154c9f4b656008103ba19f6b9d768a /.golangci.yml | |
parent | f5d1a379260156181b599d1b45e162212a67e399 (diff) |
golangci-lint: Allow `testing.T` as first parameter
We currently exclude a revive rule that `context.Context` should be the
first parameter for our test sources. This can be handled better though
because golangci-lint allows us to exclude certain types from this rule.
Adapt the rule to allow `testing.T` et al before `context.Context` and
remove the excluded rule. Interestingly, this now surfaces a whole bunch
of `nolint: revive` annotations that aren't needed anymore, so we fix
them in the same commit.
Diffstat (limited to '.golangci.yml')
-rw-r--r-- | .golangci.yml | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/.golangci.yml b/.golangci.yml index a6c5a1351..4c07d598d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -63,6 +63,12 @@ linters-settings: # checks to verify we don't use `t.Parallel()` when setting envvars. - ^os.Setenv$ - ^os.Unsetenv$ + revive: + rules: + - name: context-as-argument + arguments: + # The context should always be first, except in our testing packages. + allowTypesBefore: "*testing.T,*testing.B,testing.TB" stylecheck: # ST1000 checks for missing package comments. We don't use these for most # packages, so let's disable this check. @@ -76,10 +82,6 @@ issues: # This fine thing excludes all paths which don't end with "_test.go". path: "^([^_]|_([^t]|t([^e]|e([^s]|s([^t]|t([^\\.]|\\.([^g]|g[^o])))))))*$" - linters: - - revive - text: "context.Context should be the first parameter of a function" - path: "_test.go" - - linters: - errcheck text: "Error return value of `[^`]+.(Close|Serve)` is not checked" # Maximum issues count per one linter. Set to 0 to disable. Default is 50. |