Skip to content

Commit 05af7bb

Browse files
committed
*: Upgrade golangci-lint
1 parent bd5d3b2 commit 05af7bb

File tree

3 files changed

+156
-62
lines changed

3 files changed

+156
-62
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ jobs:
6363
run: make vet
6464

6565
- name: Lint
66-
uses: golangci/golangci-lint-action@v6
66+
uses: golangci/golangci-lint-action@v9

.golangci.yml

Lines changed: 136 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,87 @@
1-
run:
2-
deadline: 5m
3-
1+
version: "2"
42
linters:
5-
presets:
6-
- bugs
7-
- comment
8-
- error
9-
- format
10-
- import
11-
- metalinter
12-
- performance
13-
- style
14-
- unused
3+
enable:
4+
- asasalint
5+
- asciicheck
6+
- bidichk
7+
- bodyclose
8+
- canonicalheader
9+
- containedctx
10+
- contextcheck
11+
- copyloopvar
12+
- decorder
13+
- depguard
14+
- dogsled
15+
- dupl
16+
- dupword
17+
- durationcheck
18+
- errchkjson
19+
- errname
20+
- errorlint
21+
- exhaustive
22+
- exptostd
23+
- fatcontext
24+
- forbidigo
25+
- forcetypeassert
26+
- ginkgolinter
27+
- gocheckcompilerdirectives
28+
- gochecknoinits
29+
- gochecksumtype
30+
- goconst
31+
- gocritic
32+
- godot
33+
- goheader
34+
- gomodguard
35+
- goprintffuncname
36+
- gosec
37+
- gosmopolitan
38+
- grouper
39+
- iface
40+
- importas
41+
- inamedparam
42+
- interfacebloat
43+
- intrange
44+
- loggercheck
45+
- makezero
46+
- mirror
47+
- misspell
48+
- mnd
49+
- musttag
50+
- nakedret
51+
- nilerr
52+
- nilnesserr
53+
- nilnil
54+
- noctx
55+
- nolintlint
56+
- nonamedreturns
57+
- nosprintfhostport
58+
- perfsprint
59+
- prealloc
60+
- predeclared
61+
- promlinter
62+
- protogetter
63+
- reassign
64+
- recvcheck
65+
- revive
66+
- rowserrcheck
67+
- sloglint
68+
- spancheck
69+
- sqlclosecheck
70+
- staticcheck
71+
- tagalign
72+
- tagliatelle
73+
- testifylint
74+
- tparallel
75+
- unconvert
76+
- unparam
77+
- usestdlibvars
78+
- wastedassign
79+
- whitespace
80+
- zerologlint
1581
disable:
82+
- err113
1683
- exhaustruct
1784
- funlen
18-
- gci
1985
- gochecknoglobals
2086
- godox
2187
- gomoddirectives
@@ -27,41 +93,60 @@ linters:
2793
- varnamelen
2894
- wrapcheck
2995
- wsl
30-
- err113
31-
32-
issues:
33-
exclude-rules:
34-
- path: _test.go
35-
linters:
36-
- errcheck
37-
38-
linters-settings:
39-
depguard:
40-
rules:
41-
Main:
42-
deny:
43-
- pkg: sync/atomic
44-
desc: Use go.uber.org/atomic instead of sync/atomic
45-
- pkg: github.com/stretchr/testify/assert
46-
desc: Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert
47-
- pkg: github.com/go-kit/kit/log
48-
desc: Use github.com/go-kit/log instead of github.com/go-kit/kit/log
49-
- pkg: github.com/pkg/errors
50-
desc: Use fmt.Errorf instead
51-
errcheck:
52-
exclude-functions: ./.errcheck_excludes.txt
53-
goimports:
54-
local-prefixes: github.com/parca-dev/parca-debuginfo
55-
gofumpt:
56-
extra-rules: true
57-
misspell:
58-
locale: US
59-
revive:
96+
settings:
97+
cyclop:
98+
max-complexity: 15
99+
depguard:
100+
rules:
101+
Main:
102+
deny:
103+
- pkg: sync/atomic
104+
desc: Use go.uber.org/atomic instead of sync/atomic
105+
- pkg: github.com/stretchr/testify/assert
106+
desc: Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert
107+
- pkg: github.com/go-kit/kit/log
108+
desc: Use github.com/go-kit/log instead of github.com/go-kit/kit/log
109+
- pkg: github.com/pkg/errors
110+
desc: Use fmt.Errorf instead
111+
errcheck:
112+
exclude-functions:
113+
- (github.com/go-kit/log.Logger).Log
114+
misspell:
115+
locale: US
116+
revive:
117+
rules:
118+
- name: unexported-return
119+
severity: warning
120+
disabled: true
121+
exclusions:
122+
generated: lax
123+
presets:
124+
- comments
125+
- common-false-positives
126+
- legacy
127+
- std-error-handling
60128
rules:
61-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
62-
- name: unexported-return
63-
severity: warning
64-
disabled: true
65-
cyclop:
66-
# The maximal code complexity to report.
67-
max-complexity: 15
129+
- linters:
130+
- errcheck
131+
path: _test.go
132+
paths:
133+
- third_party$
134+
- builtin$
135+
- examples$
136+
formatters:
137+
enable:
138+
- gofmt
139+
- gofumpt
140+
- goimports
141+
settings:
142+
gofumpt:
143+
extra-rules: true
144+
goimports:
145+
local-prefixes:
146+
- github.com/parca-dev/parca-debuginfo
147+
exclusions:
148+
generated: lax
149+
paths:
150+
- third_party$
151+
- builtin$
152+
- examples$

cmd/parca-debuginfo/main.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ import (
4747
)
4848

4949
const (
50-
LogLevelDebug = "debug"
50+
LogLevelDebug = "debug"
51+
headerKeyValuePairElements = 2
5152
)
5253

5354
type flags struct {
@@ -437,10 +438,14 @@ func grpcConn(reg prometheus.Registerer, flags flags) (*grpc.ClientConn, error)
437438
streamInterceptors := []grpc.StreamClientInterceptor{}
438439

439440
if len(flags.Upload.GRPCHeaders) > 0 {
440-
unaryInterceptors = append([]grpc.UnaryClientInterceptor{
441-
customHeadersUnaryInterceptor(flags.Upload.GRPCHeaders)}, unaryInterceptors...)
442-
streamInterceptors = append([]grpc.StreamClientInterceptor{
443-
customHeadersStreamInterceptor(flags.Upload.GRPCHeaders)}, streamInterceptors...)
441+
unaryInterceptors = append(
442+
[]grpc.UnaryClientInterceptor{customHeadersUnaryInterceptor(flags.Upload.GRPCHeaders)},
443+
unaryInterceptors...,
444+
)
445+
streamInterceptors = append(
446+
[]grpc.StreamClientInterceptor{customHeadersStreamInterceptor(flags.Upload.GRPCHeaders)},
447+
streamInterceptors...,
448+
)
444449
}
445450

446451
opts := []grpc.DialOption{
@@ -495,19 +500,23 @@ func (t *perRequestBearerToken) RequireTransportSecurity() bool {
495500

496501
func customHeadersUnaryInterceptor(headers map[string]string) grpc.UnaryClientInterceptor {
497502
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
503+
kvPairs := make([]string, 0, len(headers)*headerKeyValuePairElements)
498504
for key, value := range headers {
499-
ctx = metadata.AppendToOutgoingContext(ctx, key, value)
505+
kvPairs = append(kvPairs, key, value)
500506
}
501-
return invoker(ctx, method, req, reply, cc, opts...)
507+
newCtx := metadata.AppendToOutgoingContext(ctx, kvPairs...)
508+
return invoker(newCtx, method, req, reply, cc, opts...)
502509
}
503510
}
504511

505512
func customHeadersStreamInterceptor(headers map[string]string) grpc.StreamClientInterceptor {
506513
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
514+
kvPairs := make([]string, 0, len(headers)*headerKeyValuePairElements)
507515
for key, value := range headers {
508-
ctx = metadata.AppendToOutgoingContext(ctx, key, value)
516+
kvPairs = append(kvPairs, key, value)
509517
}
510-
return streamer(ctx, desc, cc, method, opts...)
518+
newCtx := metadata.AppendToOutgoingContext(ctx, kvPairs...)
519+
return streamer(newCtx, desc, cc, method, opts...)
511520
}
512521
}
513522

@@ -618,7 +627,7 @@ func getNoteHexString(sectionBytes []byte, name string, noteType uint32) (string
618627

619628
// read descsz and compute the last index of the note data
620629
dataSize := binary.LittleEndian.Uint32(sectionBytes[idx-4 : idx])
621-
idxDataEnd := uint64(idxDataStart) + uint64(dataSize) //nolint:gosec
630+
idxDataEnd := uint64(idxDataStart) + uint64(dataSize)
622631

623632
// Check sanity (64 is totally arbitrary, as we only use it for Linux ID and Build ID)
624633
if idxDataEnd > uint64(len(sectionBytes)) || dataSize > 64 {

0 commit comments

Comments
 (0)