Skip to content

Commit b7f91e1

Browse files
authored
chore: Upgrades golangci-lint to v2 (#556)
1 parent f608790 commit b7f91e1

File tree

4 files changed

+102
-86
lines changed

4 files changed

+102
-86
lines changed

.github/workflows/pr.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ jobs:
1717
go-version-file: go.mod
1818
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807
1919
- name: lint
20-
uses: golangci/golangci-lint-action@v6.5.1
20+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd
2121
with:
22-
version: v1.64.7
23-
args: --timeout=10m
22+
version: v2.0.2 # Also update GOLANGCI_VERSION variable in Makefile when updating this version
2423
- name: tests
2524
run: make test
2625
- name: example-tests

.golangci.yml

Lines changed: 96 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,98 @@
1-
linters-settings:
2-
gocritic:
3-
enabled-tags:
4-
- diagnostic
5-
- experimental
6-
- opinionated
7-
- performance
8-
- style
9-
disabled-checks:
10-
- octalLiteral
11-
# We cannot control openapi format
12-
- hugeParam
13-
# Types are dynamic/OpenAPI driven.
14-
- paramTypeCombine
15-
- wrapperFunc
16-
- ptrToRefParam
17-
- emptyFallthrough
18-
- nestingReduce
19-
- sloppyReassign
20-
- typeAssertChain
21-
- builtinShadow
22-
gocyclo:
23-
min-complexity: 15
24-
revive:
25-
# see https://github.com/mgechev/revive#available-rules for details.
26-
ignore-generated-header: true
27-
severity: warning
28-
rules:
29-
- name: blank-imports
30-
- name: context-as-argument
31-
- name: context-keys-type
32-
- name: dot-imports
33-
- name: error-return
34-
- name: error-strings
35-
- name: error-naming
36-
- name: errorf
37-
- name: exported
38-
# - name: indent-error-flow
39-
- name: if-return
40-
- name: increment-decrement
41-
# We want to maintain OpenAPI consistency and ignore golang standards
42-
# - name: var-naming
43-
# - name: var-declaration
44-
# - name: receiver-naming
45-
- name: package-comments
46-
- name: range
47-
- name: time-naming
48-
- name: unexported-return
49-
- name: errorf
50-
- name: empty-block
51-
- name: superfluous-else
52-
- name: struct-tag
53-
# OpenAPI paths can have 0 parameters
54-
# - name: unused-parameter
55-
# We still want empty methods for consistency - do not control if method will be empty.
56-
# - name: unused-receiver
57-
- name: unreachable-code
1+
version: "2"
582
linters:
59-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
60-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
61-
disable-all: true
3+
default: none
624
enable:
63-
- bodyclose # checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
64-
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
65-
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
66-
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
67-
- gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
68-
- gocritic # Provides many diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false]
69-
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
70-
- gosec # Inspects source code for security problems [fast: false, auto-fix: false]
71-
- gosimple # Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
72-
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
73-
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
74-
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
75-
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
76-
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
77-
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
78-
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
79-
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
80-
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
81-
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
82-
- unparam # Reports unused function parameters [fast: false, auto-fix: false]
83-
- unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
5+
- bodyclose
6+
- dogsled
7+
- errcheck
8+
- errorlint
9+
- gochecknoinits
10+
- gocritic
11+
- goprintffuncname
12+
- gosec
13+
- govet
14+
- misspell
15+
- nakedret
16+
- nolintlint
17+
- revive
18+
- rowserrcheck
19+
- staticcheck
20+
- thelper
21+
- unconvert
22+
- unparam
23+
- unused
24+
settings:
25+
gocritic:
26+
disabled-checks:
27+
- octalLiteral
28+
# We cannot control OpenAPI format
29+
- hugeParam
30+
# Types are dynamic/OpenAPI driven.
31+
- paramTypeCombine
32+
- wrapperFunc
33+
- ptrToRefParam
34+
- emptyFallthrough
35+
- nestingReduce
36+
- sloppyReassign
37+
- typeAssertChain
38+
- builtinShadow
39+
enabled-tags:
40+
- diagnostic
41+
- experimental
42+
- opinionated
43+
- performance
44+
- style
45+
gocyclo:
46+
min-complexity: 15
47+
revive:
48+
severity: warning
49+
rules:
50+
- name: blank-imports
51+
- name: context-as-argument
52+
- name: context-keys-type
53+
- name: dot-imports
54+
- name: error-return
55+
- name: error-strings
56+
- name: error-naming
57+
- name: errorf
58+
- name: exported
59+
- name: if-return
60+
- name: increment-decrement
61+
- name: package-comments
62+
- name: range
63+
- name: time-naming
64+
- name: unexported-return
65+
- name: errorf
66+
- name: empty-block
67+
- name: superfluous-else
68+
- name: struct-tag
69+
# OpenAPI paths can have 0 parameters
70+
# - name: unused-parameter
71+
# We still want empty methods for consistency - do not control if method will be empty.
72+
# - name: unused-receiver
73+
- name: unreachable-code
74+
# We want to maintain OpenAPI consistency and ignore golang standards
75+
# - name: var-naming
76+
# - name: var-declaration
77+
# - name: receiver-naming
78+
exclusions:
79+
generated: lax
80+
presets:
81+
- comments
82+
- common-false-positives
83+
- legacy
84+
- std-error-handling
85+
rules: # Exceptions for auto-generated code from OpenAPI spec
86+
- text: "ST1023:"
87+
path: (.+)\.go$
88+
comment: "ST1023: should omit type XXX from declaration; it will be inferred from the right-hand side (staticcheck)"
89+
- text: "QF1011:"
90+
path: (.+)\.go$
91+
comment: "QF1011: could omit type XXX from declaration; it will be inferred from the right-hand side (staticcheck)"
92+
- text: "QF1004:"
93+
path: (.+)\.go$
94+
comment: "QF1004: could use strings.ReplaceAll instead (staticcheck)"
95+
formatters:
96+
enable:
97+
- gofmt
98+
- goimports

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SOURCE_FILES?=./...
2-
GOLANGCI_VERSION=v1.64.7
2+
GOLANGCI_VERSION=v2.0.2 # Also update golangci-lint GH action in pr.yml when updating this version
3+
34
GOIMPORTS_VERSION=v0.21.0
45
COVERAGE=coverage.out
56

auth/clientcredentials/clientcredentials.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"golang.org/x/oauth2"
87
"io"
98
"net/http"
109
"net/url"
1110
"strings"
1211

12+
"golang.org/x/oauth2"
13+
1314
"go.mongodb.org/atlas-sdk/v20250312001/auth"
1415
"go.mongodb.org/atlas-sdk/v20250312001/internal/core"
1516
"golang.org/x/oauth2/clientcredentials"

0 commit comments

Comments
 (0)