diff --git a/.golangci.yml b/.golangci.yml index 7fb514f9b..d636dcd36 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -151,8 +151,6 @@ linters: #- name: unexported-return - name: unreachable-code - name: unused-parameter - severity: warning - disabled: true #- name: unused-receiver #- name: var-declaration #- name: var-naming diff --git a/config/http_config.go b/config/http_config.go index 2e605ffde..eb4f22015 100644 --- a/config/http_config.go +++ b/config/http_config.go @@ -742,7 +742,7 @@ func NewFileSecret(file string) *FileSecret { return &FileSecret{file: file} } -func (s *FileSecret) Fetch(ctx context.Context) (string, error) { +func (s *FileSecret) Fetch(context.Context) (string, error) { fileBytes, err := os.ReadFile(s.file) if err != nil { return "", fmt.Errorf("unable to read file %s: %w", s.file, err) diff --git a/config/http_config_test.go b/config/http_config_test.go index bd9e7dcf7..0287f4eb7 100644 --- a/config/http_config_test.go +++ b/config/http_config_test.go @@ -181,7 +181,7 @@ func TestNewClientFromConfig(t *testing.T) { InsecureSkipVerify: true, }, }, - handler: func(w http.ResponseWriter, r *http.Request) { + handler: func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, ExpectedMessage) }, }, @@ -195,7 +195,7 @@ func TestNewClientFromConfig(t *testing.T) { InsecureSkipVerify: false, }, }, - handler: func(w http.ResponseWriter, r *http.Request) { + handler: func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, ExpectedMessage) }, }, @@ -933,7 +933,7 @@ type secretManager struct { data map[string]string } -func (m *secretManager) Fetch(ctx context.Context, secretRef string) (string, error) { +func (m *secretManager) Fetch(_ context.Context, secretRef string) (string, error) { secretData, ok := m.data[secretRef] if !ok { return "", fmt.Errorf("unknown secret %s", secretRef) @@ -1044,7 +1044,7 @@ func TestTLSRoundTripper(t *testing.T) { ca, cert, key := filepath.Join(tmpDir, "ca"), filepath.Join(tmpDir, "cert"), filepath.Join(tmpDir, "key") - handler := func(w http.ResponseWriter, r *http.Request) { + handler := func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, ExpectedMessage) } testServer, err := newTestServer(handler) @@ -1162,7 +1162,7 @@ func TestTLSRoundTripper(t *testing.T) { } func TestTLSRoundTripper_Inline(t *testing.T) { - handler := func(w http.ResponseWriter, r *http.Request) { + handler := func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, ExpectedMessage) } testServer, err := newTestServer(handler) @@ -1284,7 +1284,7 @@ func TestTLSRoundTripperRaces(t *testing.T) { ca, cert, key := filepath.Join(tmpDir, "ca"), filepath.Join(tmpDir, "cert"), filepath.Join(tmpDir, "key") - handler := func(w http.ResponseWriter, r *http.Request) { + handler := func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, ExpectedMessage) } testServer, err := newTestServer(handler) @@ -1402,7 +1402,7 @@ type roundTrip struct { theError error } -func (rt *roundTrip) RoundTrip(r *http.Request) (*http.Response, error) { +func (rt *roundTrip) RoundTrip(*http.Request) (*http.Response, error) { return rt.theResponse, rt.theError } @@ -1875,7 +1875,7 @@ func TestModifyTLSCertificates(t *testing.T) { defer os.RemoveAll(tmpDir) ca, cert, key := filepath.Join(tmpDir, "ca"), filepath.Join(tmpDir, "cert"), filepath.Join(tmpDir, "key") - handler := func(w http.ResponseWriter, r *http.Request) { + handler := func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, ExpectedMessage) } testServer, err := newTestServer(handler) diff --git a/expfmt/decode.go b/expfmt/decode.go index 98d278c13..7b762370e 100644 --- a/expfmt/decode.go +++ b/expfmt/decode.go @@ -135,7 +135,7 @@ type errDecoder struct { err error } -func (d *errDecoder) Decode(v *dto.MetricFamily) error { +func (d *errDecoder) Decode(*dto.MetricFamily) error { return d.err } diff --git a/expfmt/text_parse_test.go b/expfmt/text_parse_test.go index 5b848c4a1..f9c6d4cd7 100644 --- a/expfmt/text_parse_test.go +++ b/expfmt/text_parse_test.go @@ -1048,6 +1048,6 @@ type errReader struct { err error } -func (r *errReader) Read(p []byte) (int, error) { +func (r *errReader) Read([]byte) (int, error) { return 0, r.err } diff --git a/promslog/slog.go b/promslog/slog.go index 33da53f82..f5b9e98ba 100644 --- a/promslog/slog.go +++ b/promslog/slog.go @@ -147,7 +147,7 @@ type Config struct { } func newGoKitStyleReplaceAttrFunc(lvl *Level) func(groups []string, a slog.Attr) slog.Attr { - return func(groups []string, a slog.Attr) slog.Attr { + return func(_ []string, a slog.Attr) slog.Attr { key := a.Key switch key { case slog.TimeKey, "ts": diff --git a/route/route_test.go b/route/route_test.go index 773be4891..e20e1db17 100644 --- a/route/route_test.go +++ b/route/route_test.go @@ -37,7 +37,7 @@ func TestRedirect(t *testing.T) { func TestContext(t *testing.T) { router := New() - router.Get("/test/:foo/", func(w http.ResponseWriter, r *http.Request) { + router.Get("/test/:foo/", func(_ http.ResponseWriter, r *http.Request) { want := "bar" got := Param(r.Context(), "foo") require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got) @@ -50,7 +50,7 @@ func TestContext(t *testing.T) { func TestContextWithValue(t *testing.T) { router := New() - router.Get("/test/:foo/", func(w http.ResponseWriter, r *http.Request) { + router.Get("/test/:foo/", func(_ http.ResponseWriter, r *http.Request) { want := "bar" got := Param(r.Context(), "foo") require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got) @@ -79,7 +79,7 @@ func TestContextWithValue(t *testing.T) { func TestContextWithoutValue(t *testing.T) { router := New() - router.Get("/test", func(w http.ResponseWriter, r *http.Request) { + router.Get("/test", func(_ http.ResponseWriter, r *http.Request) { want := "" got := Param(r.Context(), "foo") require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got) @@ -109,7 +109,7 @@ func TestInstrumentation(t *testing.T) { } for _, c := range cases { - c.router.Get("/foo", func(w http.ResponseWriter, r *http.Request) {}) + c.router.Get("/foo", func(_ http.ResponseWriter, _ *http.Request) {}) r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/foo", nil) require.NoErrorf(t, err, "Error building test request: %s", err) @@ -149,7 +149,7 @@ func TestInstrumentations(t *testing.T) { } for _, c := range cases { - c.router.Get("/foo", func(w http.ResponseWriter, r *http.Request) {}) + c.router.Get("/foo", func(_ http.ResponseWriter, _ *http.Request) {}) r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/foo", nil) require.NoErrorf(t, err, "Error building test request: %s", err) diff --git a/server/static_file_server_test.go b/server/static_file_server_test.go index 254ca1c59..9a1bf5e49 100644 --- a/server/static_file_server_test.go +++ b/server/static_file_server_test.go @@ -23,7 +23,7 @@ import ( type dummyFileSystem struct{} -func (fs dummyFileSystem) Open(path string) (http.File, error) { +func (fs dummyFileSystem) Open(string) (http.File, error) { return http.Dir(".").Open(".") }