Skip to content

Commit 173fdb0

Browse files
AnmolxSinghyurishkuro
authored andcommitted
Update module github.com/golangci/golangci-lint to v2 (jaegertracing#6959)
## Which problem is this PR solving? Resolves jaegertracing#6927 ## Description of the changes - changed the version to v2 ## How was this change tested? - Ran `go mod tidy` && ` (cd internal/tools && go mod tidy)` - Ran `make lint` test ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: anmol7344 <[email protected]> Signed-off-by: Anmol <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: amol-verma-allen <[email protected]>
1 parent d595ecd commit 173fdb0

File tree

61 files changed

+365
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+365
-387
lines changed

.golangci.yml

Lines changed: 116 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,196 +1,93 @@
1-
issues:
2-
# Excluding configuration per-path, per-linter, per-text and per-source
3-
exclude-rules:
4-
# Exclude some linters from running on tests files.
5-
- path: _test\.go
6-
linters: [gosec, bodyclose, noctx]
7-
8-
- path: crossdock
9-
linters: [noctx]
10-
11-
# See https://github.com/jaegertracing/jaeger/issues/4488
12-
- path: internal/grpctest/
13-
linters: [staticcheck]
14-
15-
- linters: [gocritic]
16-
text: "dupArg"
17-
- linters: [gocritic]
18-
text: "exitAfterDefer"
19-
- linters: [gocritic]
20-
text: "appendAssign"
21-
exclude-dirs-use-default: false
22-
exclude-dirs:
23-
- mocks
24-
- thrift-0.9.2
25-
- .*-gen
26-
exclude-files:
27-
- ".*.pb.go$"
28-
max-issues-per-linter: 0
29-
max-same-issues: 0
30-
1+
version: "2"
2+
run:
3+
go: "1.23"
314
linters:
32-
disable:
33-
- errcheck
345
enable:
35-
# Plain ASCII identifiers.
366
- asciicheck
37-
38-
# Checks for dangerous unicode character sequences.
397
- bidichk
40-
41-
# Checks whether HTTP response body is closed successfully.
42-
# TODO enable this but maybe find a way to disable in tests.
438
- bodyclose
44-
45-
# Check whether the function uses a non-inherited context.
469
- contextcheck
47-
48-
# Check declaration order of types, consts, vars and funcs.
10+
- copyloopvar
4911
- decorder
50-
51-
# Checks if package imports are in a list of acceptable packages (see cfg below).
5212
- depguard
53-
54-
# Check for two durations multiplied together.
5513
- durationcheck
56-
57-
# Checks `Err-` prefix for var and `-Error` suffix for error type.
5814
- errname
59-
60-
# Suggests to use `%w` for error-wrapping.
6115
- errorlint
62-
63-
# Checks for pointers to enclosing loop variables.
64-
- copyloopvar
65-
6616
- gocritic
67-
- gofmt
68-
- gofumpt
69-
- goimports
70-
71-
# Allow or ban replace directives in go.mod
72-
# or force explanation for retract directives.
73-
# Maybe enable once we get rid of old sarama.
74-
# - gomoddirectives
75-
7617
- gosec
77-
78-
# Linter that specializes in simplifying code.
79-
- gosimple
80-
- govet
81-
82-
# Detects when assignments to existing variables are not used.
83-
- ineffassign
84-
8518
- misspell
86-
87-
# Finds naked/bare returns and requires change them.
8819
- nakedret
89-
90-
# Require a bit more explicit returns.
9120
- nilerr
92-
93-
# Finds sending HTTP request without context.Context.
9421
- noctx
95-
96-
# Reports ill-formed or insufficient nolint directives.
9722
- nolintlint
98-
99-
# Checks that fmt.Sprintf can be replaced with a faster alternative.
10023
- perfsprint
101-
102-
# Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
10324
- revive
104-
105-
# Checks usage of github.com/stretchr/testify.
10625
- testifylint
107-
108-
# Detects the possibility to use variables/constants from the Go standard library.
10926
- usestdlibvars
110-
111-
# TODO consider adding more linters, cf. https://olegk.dev/go-linters-configuration-the-right-version
112-
113-
linters-settings:
114-
depguard:
115-
rules:
116-
disallowed-deps:
117-
deny:
118-
- pkg: go.uber.org/atomic
119-
desc: "Use 'sync/atomic' instead of go.uber.org/atomic"
120-
- pkg: io/ioutil
121-
desc: "Use os or io instead of io/ioutil"
122-
- pkg: github.com/hashicorp/go-multierror
123-
desc: "Use errors.Join instead of github.com/hashicorp/go-multierror"
124-
- pkg: go.uber.org/multierr
125-
desc: "Use errors.Join instead of github.com/hashicorp/go-multierror"
126-
- pkg: "github.com/jaegertracing/jaeger/model$"
127-
desc: "Use github.com/jaegertracing/jaeger-idl/model/v1"
128-
- pkg: "github.com/jaegertracing/jaeger/internal/proto-gen/api_v2$"
129-
desc: "Use github.com/jaegertracing/jaeger-idl/proto-gen/api_v2"
130-
# crossdock-go provides assert/require similar to stretchr/testify
131-
# but we never want to use them outside of the crossdock tests.
132-
disallow-crossdock:
133-
deny:
134-
- pkg: github.com/crossdock/crossdock-go
135-
desc: "Do not refer to crossdock from other packages"
136-
files:
137-
- "!**/crossdock/**"
138-
139-
disallow-uber/goleak:
140-
deny:
141-
- pkg: go.uber.org/goleak
142-
desc: "Use github.com/jaegertracing/jaeger/internal/testutils"
143-
files:
144-
- "**_test.go"
145-
146-
disallow-otel-contrib-translator:
147-
deny:
148-
- pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger
149-
desc: "Use v1adapter package instead of opentelemetry-collector-contrib/pkg/translator/jaeger"
150-
files:
151-
- "!**/v1adapter/**"
152-
153-
goimports:
154-
local-prefixes: github.com/jaegertracing/jaeger
155-
gosec:
156-
# To specify a set of rules to explicitly exclude.
157-
# Available rules: https://github.com/securego/gosec#available-rules
158-
excludes:
159-
- G104
160-
- G107
161-
- G404
162-
- G601
163-
govet:
164-
enable-all: true
165-
disable:
166-
# There is rarely performance differences due to padding,
167-
# the most noticable impact is memory usage. However,
168-
# the main trace data is Protobuf-generated and we ignore
169-
# those files from linting, so this linter is not useful.
170-
- fieldalignment
171-
# Disable shadow
172-
- shadow
173-
perfsprint:
174-
# Optimizes even if it requires an int or uint type cast.
175-
int-conversion: true
176-
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
177-
err-error: true
178-
# Optimizes `fmt.Errorf`.
179-
errorf: true
180-
# Optimizes `fmt.Sprintf` with only one argument.
181-
sprintf1: true
182-
# Optimizes into strings concatenation.
183-
strconcat: true
184-
revive:
185-
ignore-generated-header: true
27+
disable:
28+
- errcheck
29+
- staticcheck
30+
settings:
31+
depguard:
32+
rules:
33+
disallow-crossdock:
34+
files:
35+
- '!**/crossdock/**'
36+
deny:
37+
- pkg: github.com/crossdock/crossdock-go
38+
desc: Do not refer to crossdock from other packages
39+
disallow-otel-contrib-translator:
40+
files:
41+
- '!**/v1adapter/**'
42+
deny:
43+
- pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger
44+
desc: Use v1adapter package instead of opentelemetry-collector-contrib/pkg/translator/jaeger
45+
disallow-uber/goleak:
46+
files:
47+
- '**_test.go'
48+
deny:
49+
- pkg: go.uber.org/goleak
50+
desc: Use github.com/jaegertracing/jaeger/internal/testutils
51+
disallowed-deps:
52+
deny:
53+
- pkg: go.uber.org/atomic
54+
desc: Use 'sync/atomic' instead of go.uber.org/atomic
55+
- pkg: io/ioutil
56+
desc: Use os or io instead of io/ioutil
57+
- pkg: github.com/hashicorp/go-multierror
58+
desc: Use errors.Join instead of github.com/hashicorp/go-multierror
59+
- pkg: go.uber.org/multierr
60+
desc: Use errors.Join instead of github.com/hashicorp/go-multierror
61+
- pkg: github.com/jaegertracing/jaeger/model$
62+
desc: Use github.com/jaegertracing/jaeger-idl/model/v1
63+
- pkg: github.com/jaegertracing/jaeger/internal/proto-gen/api_v2$
64+
desc: Use github.com/jaegertracing/jaeger-idl/proto-gen/api_v2
65+
gosec:
66+
excludes:
67+
- G104
68+
- G107
69+
- G404
70+
- G601
71+
govet:
72+
disable:
73+
- fieldalignment
74+
- shadow
75+
enable-all: true
76+
perfsprint:
77+
int-conversion: true
78+
err-error: true
79+
errorf: true
80+
sprintf1: true
81+
strconcat: true
82+
revive:
18683
severity: error
18784
enable-all-rules: true
188-
# See https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
18985
rules:
19086
# not a completely bad linter, but needs clean-up and sensible width (80 is too small)
19187
- name: line-length-limit
88+
arguments:
89+
- 80
19290
disabled: true
193-
arguments: [80]
19491
# would be ok if we could exclude the test files, but otherwise too noisy
19592
- name: add-constant
19693
disabled: true
@@ -245,9 +142,57 @@ linters-settings:
245142
# this rule conflicts with nolintlint which does insist on no-space in //nolint
246143
- name: comment-spacings
247144
disabled: true
248-
testifylint:
249-
enable-all: true
250-
251-
run:
252-
go: "1.23"
253-
timeout: 20m
145+
testifylint:
146+
enable-all: true
147+
exclusions:
148+
generated: lax
149+
presets:
150+
- comments
151+
- common-false-positives
152+
- legacy
153+
- std-error-handling
154+
rules:
155+
- linters:
156+
- bodyclose
157+
- gosec
158+
- noctx
159+
path: _test\.go
160+
- linters:
161+
- noctx
162+
path: crossdock
163+
- linters:
164+
- staticcheck
165+
path: internal/grpctest/
166+
- linters:
167+
- gocritic
168+
text: dupArg
169+
- linters:
170+
- gocritic
171+
text: exitAfterDefer
172+
- linters:
173+
- gocritic
174+
text: appendAssign
175+
paths:
176+
- .*.pb.go$
177+
- mocks
178+
- thrift-0.9.2
179+
- .*-gen
180+
issues:
181+
max-issues-per-linter: 0
182+
max-same-issues: 0
183+
formatters:
184+
enable:
185+
- gofmt
186+
- gofumpt
187+
- goimports
188+
settings:
189+
goimports:
190+
local-prefixes:
191+
- github.com/jaegertracing/jaeger
192+
exclusions:
193+
generated: lax
194+
paths:
195+
- .*.pb.go$
196+
- mocks
197+
- thrift-0.9.2
198+
- .*-gen

cmd/all-in-one/all_in_one_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func getSamplingStrategy(t *testing.T) {
174174

175175
r, body := httpGet(t, samplingAddr+getSamplingStrategyURL)
176176
t.Logf("Sampling strategy response: %s", string(body))
177-
require.EqualValues(t, http.StatusOK, r.StatusCode)
177+
require.Equal(t, http.StatusOK, r.StatusCode)
178178

179179
var queryResponse api_v2.SamplingStrategyResponse
180180
require.NoError(t, jsonpb.Unmarshal(bytes.NewReader(body), &queryResponse))

cmd/anonymizer/app/query/query_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func TestQueryTrace(t *testing.T) {
118118

119119
spans, err := q.QueryTrace(mockTraceID.String(), startTime, endTime)
120120
require.NoError(t, err)
121-
assert.Equal(t, len(spans), len(mockTraceGRPC.Spans))
121+
assert.Len(t, spans, len(mockTraceGRPC.Spans))
122122
})
123123

124124
t.Run("Invalid TraceID", func(t *testing.T) {

cmd/collector/app/handler/grpc_handler_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ func TestPostSpans(t *testing.T) {
145145
})
146146
require.NoError(t, err)
147147
got := proc.getSpans()
148-
require.Equal(t, len(test.batch.GetSpans()), len(got))
149148
assert.Equal(t, test.expected, got)
150149
proc.reset()
151150
}

0 commit comments

Comments
 (0)