Skip to content

Commit 07691e7

Browse files
committed
Merge remote-tracking branch 'origin/main' into arve/revive-rules
Signed-off-by: Arve Knudsen <[email protected]>
2 parents a0e0d32 + 7937ffb commit 07691e7

File tree

10 files changed

+28
-26
lines changed

10 files changed

+28
-26
lines changed

.golangci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ linters:
6666
rules:
6767
main:
6868
deny:
69-
#- pkg: "sync/atomic"
70-
#desc: "Use go.uber.org/atomic instead of sync/atomic"
69+
- pkg: "sync/atomic"
70+
desc: "Use go.uber.org/atomic instead of sync/atomic"
7171
- pkg: "github.com/go-kit/kit/log"
7272
desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
7373
- pkg: "io/ioutil"
@@ -151,8 +151,6 @@ linters:
151151
- name: unexported-return
152152
- name: unreachable-code
153153
- name: unused-parameter
154-
severity: warning
155-
disabled: true
156154
- name: unused-receiver
157155
- name: var-declaration
158156
- name: var-naming

config/http_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ func NewFileSecret(file string) *FileSecret {
748748
return &FileSecret{file: file}
749749
}
750750

751-
func (s *FileSecret) Fetch(ctx context.Context) (string, error) {
751+
func (s *FileSecret) Fetch(context.Context) (string, error) {
752752
fileBytes, err := os.ReadFile(s.file)
753753
if err != nil {
754754
return "", fmt.Errorf("unable to read file %s: %w", s.file, err)

config/http_config_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ import (
3131
"strconv"
3232
"strings"
3333
"sync"
34-
"sync/atomic"
3534
"testing"
3635
"time"
3736

3837
"github.com/stretchr/testify/require"
38+
"go.uber.org/atomic"
3939
"gopkg.in/yaml.v2"
4040
)
4141

@@ -181,7 +181,7 @@ func TestNewClientFromConfig(t *testing.T) {
181181
InsecureSkipVerify: true,
182182
},
183183
},
184-
handler: func(w http.ResponseWriter, r *http.Request) {
184+
handler: func(w http.ResponseWriter, _ *http.Request) {
185185
fmt.Fprint(w, ExpectedMessage)
186186
},
187187
},
@@ -195,7 +195,7 @@ func TestNewClientFromConfig(t *testing.T) {
195195
InsecureSkipVerify: false,
196196
},
197197
},
198-
handler: func(w http.ResponseWriter, r *http.Request) {
198+
handler: func(w http.ResponseWriter, _ *http.Request) {
199199
fmt.Fprint(w, ExpectedMessage)
200200
},
201201
},
@@ -933,7 +933,7 @@ type secretManager struct {
933933
data map[string]string
934934
}
935935

936-
func (m *secretManager) Fetch(ctx context.Context, secretRef string) (string, error) {
936+
func (m *secretManager) Fetch(_ context.Context, secretRef string) (string, error) {
937937
secretData, ok := m.data[secretRef]
938938
if !ok {
939939
return "", fmt.Errorf("unknown secret %s", secretRef)
@@ -1044,7 +1044,7 @@ func TestTLSRoundTripper(t *testing.T) {
10441044

10451045
ca, cert, key := filepath.Join(tmpDir, "ca"), filepath.Join(tmpDir, "cert"), filepath.Join(tmpDir, "key")
10461046

1047-
handler := func(w http.ResponseWriter, r *http.Request) {
1047+
handler := func(w http.ResponseWriter, _ *http.Request) {
10481048
fmt.Fprint(w, ExpectedMessage)
10491049
}
10501050
testServer, err := newTestServer(handler)
@@ -1162,7 +1162,7 @@ func TestTLSRoundTripper(t *testing.T) {
11621162
}
11631163

11641164
func TestTLSRoundTripper_Inline(t *testing.T) {
1165-
handler := func(w http.ResponseWriter, r *http.Request) {
1165+
handler := func(w http.ResponseWriter, _ *http.Request) {
11661166
fmt.Fprint(w, ExpectedMessage)
11671167
}
11681168
testServer, err := newTestServer(handler)
@@ -1284,7 +1284,7 @@ func TestTLSRoundTripperRaces(t *testing.T) {
12841284

12851285
ca, cert, key := filepath.Join(tmpDir, "ca"), filepath.Join(tmpDir, "cert"), filepath.Join(tmpDir, "key")
12861286

1287-
handler := func(w http.ResponseWriter, r *http.Request) {
1287+
handler := func(w http.ResponseWriter, _ *http.Request) {
12881288
fmt.Fprint(w, ExpectedMessage)
12891289
}
12901290
testServer, err := newTestServer(handler)
@@ -1309,7 +1309,8 @@ func TestTLSRoundTripperRaces(t *testing.T) {
13091309

13101310
var wg sync.WaitGroup
13111311
ch := make(chan struct{})
1312-
var total, ok int64
1312+
total := atomic.NewInt64(0)
1313+
ok := atomic.NewInt64(0)
13131314
// Spawn 10 Go routines polling the server concurrently.
13141315
for i := 0; i < 10; i++ {
13151316
wg.Add(1)
@@ -1320,11 +1321,11 @@ func TestTLSRoundTripperRaces(t *testing.T) {
13201321
case <-ch:
13211322
return
13221323
default:
1323-
atomic.AddInt64(&total, 1)
1324+
total.Add(1)
13241325
r, err := c.Get(testServer.URL)
13251326
if err == nil {
13261327
r.Body.Close()
1327-
atomic.AddInt64(&ok, 1)
1328+
ok.Add(1)
13281329
}
13291330
}
13301331
}
@@ -1402,7 +1403,7 @@ type roundTrip struct {
14021403
theError error
14031404
}
14041405

1405-
func (rt *roundTrip) RoundTrip(r *http.Request) (*http.Response, error) {
1406+
func (rt *roundTrip) RoundTrip(*http.Request) (*http.Response, error) {
14061407
return rt.theResponse, rt.theError
14071408
}
14081409

@@ -1875,7 +1876,7 @@ func TestModifyTLSCertificates(t *testing.T) {
18751876
defer os.RemoveAll(tmpDir)
18761877
ca, cert, key := filepath.Join(tmpDir, "ca"), filepath.Join(tmpDir, "cert"), filepath.Join(tmpDir, "key")
18771878

1878-
handler := func(w http.ResponseWriter, r *http.Request) {
1879+
handler := func(w http.ResponseWriter, _ *http.Request) {
18791880
fmt.Fprint(w, ExpectedMessage)
18801881
}
18811882
testServer, err := newTestServer(handler)

expfmt/decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ type errDecoder struct {
135135
err error
136136
}
137137

138-
func (d *errDecoder) Decode(v *dto.MetricFamily) error {
138+
func (d *errDecoder) Decode(*dto.MetricFamily) error {
139139
return d.err
140140
}
141141

expfmt/text_parse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,6 @@ type errReader struct {
10481048
err error
10491049
}
10501050

1051-
func (r *errReader) Read(p []byte) (int, error) {
1051+
func (r *errReader) Read([]byte) (int, error) {
10521052
return 0, r.err
10531053
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
1414
github.com/prometheus/client_model v0.6.2
1515
github.com/stretchr/testify v1.10.0
16+
go.uber.org/atomic v1.11.0
1617
golang.org/x/net v0.42.0
1718
golang.org/x/oauth2 v0.30.0
1819
google.golang.org/protobuf v1.36.6

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
4545
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4646
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
4747
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
48+
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
49+
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
4850
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
4951
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
5052
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=

promslog/slog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ type Config struct {
147147
}
148148

149149
func newGoKitStyleReplaceAttrFunc(lvl *Level) func(groups []string, a slog.Attr) slog.Attr {
150-
return func(groups []string, a slog.Attr) slog.Attr {
150+
return func(_ []string, a slog.Attr) slog.Attr {
151151
key := a.Key
152152
switch key {
153153
case slog.TimeKey, "ts":

route/route_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestRedirect(t *testing.T) {
3737

3838
func TestContext(t *testing.T) {
3939
router := New()
40-
router.Get("/test/:foo/", func(w http.ResponseWriter, r *http.Request) {
40+
router.Get("/test/:foo/", func(_ http.ResponseWriter, r *http.Request) {
4141
want := "bar"
4242
got := Param(r.Context(), "foo")
4343
require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got)
@@ -50,7 +50,7 @@ func TestContext(t *testing.T) {
5050

5151
func TestContextWithValue(t *testing.T) {
5252
router := New()
53-
router.Get("/test/:foo/", func(w http.ResponseWriter, r *http.Request) {
53+
router.Get("/test/:foo/", func(_ http.ResponseWriter, r *http.Request) {
5454
want := "bar"
5555
got := Param(r.Context(), "foo")
5656
require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got)
@@ -79,7 +79,7 @@ func TestContextWithValue(t *testing.T) {
7979

8080
func TestContextWithoutValue(t *testing.T) {
8181
router := New()
82-
router.Get("/test", func(w http.ResponseWriter, r *http.Request) {
82+
router.Get("/test", func(_ http.ResponseWriter, r *http.Request) {
8383
want := ""
8484
got := Param(r.Context(), "foo")
8585
require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got)
@@ -109,7 +109,7 @@ func TestInstrumentation(t *testing.T) {
109109
}
110110

111111
for _, c := range cases {
112-
c.router.Get("/foo", func(w http.ResponseWriter, r *http.Request) {})
112+
c.router.Get("/foo", func(_ http.ResponseWriter, _ *http.Request) {})
113113

114114
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/foo", nil)
115115
require.NoErrorf(t, err, "Error building test request: %s", err)
@@ -149,7 +149,7 @@ func TestInstrumentations(t *testing.T) {
149149
}
150150

151151
for _, c := range cases {
152-
c.router.Get("/foo", func(w http.ResponseWriter, r *http.Request) {})
152+
c.router.Get("/foo", func(_ http.ResponseWriter, _ *http.Request) {})
153153

154154
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/foo", nil)
155155
require.NoErrorf(t, err, "Error building test request: %s", err)

server/static_file_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
type dummyFileSystem struct{}
2525

26-
func (dummyFileSystem) Open(path string) (http.File, error) {
26+
func (dummyFileSystem) Open(string) (http.File, error) {
2727
return http.Dir(".").Open(".")
2828
}
2929

0 commit comments

Comments
 (0)