Skip to content

Commit 9bcfcda

Browse files
authored
chore: update and appease linters (#205)
1 parent 683e4eb commit 9bcfcda

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ COVERAGE_ARGS ?= -covermode=atomic -coverprofile=$(COVERAGE_PATH)
1212
TEST_ARGS ?= -race
1313

1414
# 3rd party tools
15-
LINT := go run github.com/mgechev/[email protected]
15+
FMT := go run mvdan.cc/[email protected]
16+
LINT := go run github.com/mgechev/[email protected]
1617
REFLEX := go run github.com/cespare/[email protected]
17-
STATICCHECK := go run honnef.co/go/tools/cmd/staticcheck@2023.1.3
18+
STATICCHECK := go run honnef.co/go/tools/cmd/staticcheck@2025.1.1
1819

1920
# Host and port to use when running locally via `make run` or `make watch`
2021
HOST ?= 127.0.0.1
@@ -66,7 +67,7 @@ testautobahn:
6667
.PHONY: autobahntests
6768

6869
lint:
69-
test -z "$$(gofmt -d -s -e .)" || (echo "Error: gofmt failed"; gofmt -d -s -e . ; exit 1)
70+
test -z "$$($(FMT) -d -e .)" || (echo "Error: $(FMT) failed"; $(FMT) -d -e . ; exit 1)
7071
go vet ./...
7172
$(LINT) -set_exit_status ./...
7273
$(STATICCHECK) ./...

httpbin/handlers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3555,7 +3555,7 @@ func newTestServer(handler http.Handler) (*httptest.Server, *http.Client) {
35553555
srv := httptest.NewServer(handler)
35563556
client := srv.Client()
35573557
client.Timeout = 5 * time.Second
3558-
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
3558+
client.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
35593559
return http.ErrUseLastResponse
35603560
}
35613561
return srv, client

httpbin/helpers.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ func parseStatusCode(input string) (int, error) {
248248
return parseBoundedStatusCode(input, 100, 599)
249249
}
250250

251-
func parseBoundedStatusCode(input string, min, max int) (int, error) {
251+
func parseBoundedStatusCode(input string, minVal, maxVal int) (int, error) {
252252
code, err := strconv.Atoi(input)
253253
if err != nil {
254254
return 0, fmt.Errorf("invalid status code: %q: %w", input, err)
255255
}
256-
if code < min || code > max {
257-
return 0, fmt.Errorf("invalid status code: %d not in range [%d, %d]", code, min, max)
256+
if code < minVal || code > maxVal {
257+
return 0, fmt.Errorf("invalid status code: %d not in range [%d, %d]", code, minVal, maxVal)
258258
}
259259
return code, nil
260260
}
@@ -276,16 +276,16 @@ func parseDuration(input string) (time.Duration, error) {
276276

277277
// parseBoundedDuration parses a time.Duration from user input and ensures that
278278
// it is within a given maximum and minimum time
279-
func parseBoundedDuration(input string, min, max time.Duration) (time.Duration, error) {
279+
func parseBoundedDuration(input string, minVal, maxVal time.Duration) (time.Duration, error) {
280280
d, err := parseDuration(input)
281281
if err != nil {
282282
return 0, err
283283
}
284284

285-
if d > max {
286-
err = fmt.Errorf("duration %s longer than %s", d, max)
287-
} else if d < min {
288-
err = fmt.Errorf("duration %s shorter than %s", d, min)
285+
if d > maxVal {
286+
err = fmt.Errorf("duration %s longer than %s", d, maxVal)
287+
} else if d < minVal {
288+
err = fmt.Errorf("duration %s shorter than %s", d, minVal)
289289
}
290290
return d, err
291291
}

httpbin/middleware_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func TestTestMode(t *testing.T) {
1717
// will cause a panic. This happens most often when we forget to return
1818
// early after writing an error response, and has helped identify and fix
1919
// some subtly broken error handling.
20-
observer := func(r Result) {}
21-
handler := observe(observer, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
20+
observer := func(_ Result) {}
21+
handler := observe(observer, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
2222
w.WriteHeader(http.StatusBadRequest)
2323
w.WriteHeader(http.StatusOK)
2424
}))

httpbin/websocket/websocket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type Handler func(ctx context.Context, msg *Message) (*Message, error)
7575

7676
// EchoHandler is a Handler that echoes each incoming message back to the
7777
// client.
78-
var EchoHandler Handler = func(ctx context.Context, msg *Message) (*Message, error) {
78+
var EchoHandler Handler = func(_ context.Context, msg *Message) (*Message, error) {
7979
return msg, nil
8080
}
8181

internal/testing/assert/assert.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,19 @@ func BodySize(t *testing.T, resp *http.Response, want int) {
122122
}
123123

124124
// DurationRange asserts that a duration is within a specific range.
125-
func DurationRange(t *testing.T, got, min, max time.Duration) {
125+
func DurationRange(t *testing.T, got, minVal, maxVal time.Duration) {
126126
t.Helper()
127-
if got < min || got > max {
128-
t.Fatalf("expected duration between %s and %s, got %s", min, max, got)
127+
if got < minVal || got > maxVal {
128+
t.Fatalf("expected duration between %s and %s, got %s", minVal, maxVal, got)
129129
}
130130
}
131131

132-
type Number interface {
132+
type number interface {
133133
~int64 | ~float64
134134
}
135135

136136
// RoughlyEqual asserts that a numeric value is within a certain tolerance.
137-
func RoughlyEqual[T Number](t *testing.T, got, want T, epsilon T) {
137+
func RoughlyEqual[T number](t *testing.T, got, want T, epsilon T) {
138138
t.Helper()
139139
if got < want-epsilon || got > want+epsilon {
140140
t.Fatalf("expected value between %v and %v, got %v", want-epsilon, want+epsilon, got)

0 commit comments

Comments
 (0)