Skip to content

Commit f881b6f

Browse files
committed
major lint fixes
1 parent d5f0e72 commit f881b6f

13 files changed

Lines changed: 175 additions & 170 deletions

examples/routes-cli/main.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,24 @@ func setupRoutes() *teapot.Router {
9191
}
9292

9393
// Mock handlers
94-
func homeHandler(w http.ResponseWriter, r *http.Request) {}
95-
func aboutHandler(w http.ResponseWriter, r *http.Request) {}
96-
func listUsers(w http.ResponseWriter, r *http.Request) {}
97-
func createUser(w http.ResponseWriter, r *http.Request) {}
98-
func showUser(w http.ResponseWriter, r *http.Request) {}
99-
func updateUser(w http.ResponseWriter, r *http.Request) {}
100-
func deleteUser(w http.ResponseWriter, r *http.Request) {}
101-
func listPosts(w http.ResponseWriter, r *http.Request) {}
102-
func createPost(w http.ResponseWriter, r *http.Request) {}
103-
func showPost(w http.ResponseWriter, r *http.Request) {}
104-
func updatePost(w http.ResponseWriter, r *http.Request) {}
105-
func listBuckets(w http.ResponseWriter, r *http.Request) {}
106-
func createBucket(w http.ResponseWriter, r *http.Request) {}
107-
func deleteBucket(w http.ResponseWriter, r *http.Request) {}
108-
func listObjects(w http.ResponseWriter, r *http.Request) {}
109-
func getObject(w http.ResponseWriter, r *http.Request) {}
110-
func putObject(w http.ResponseWriter, r *http.Request) {}
111-
func deleteObject(w http.ResponseWriter, r *http.Request) {}
112-
func adminDashboard(w http.ResponseWriter, r *http.Request) {}
113-
func adminUsers(w http.ResponseWriter, r *http.Request) {}
94+
func homeHandler(_ http.ResponseWriter, _ *http.Request) {}
95+
func aboutHandler(_ http.ResponseWriter, _ *http.Request) {}
96+
func listUsers(_ http.ResponseWriter, _ *http.Request) {}
97+
func createUser(_ http.ResponseWriter, _ *http.Request) {}
98+
func showUser(_ http.ResponseWriter, _ *http.Request) {}
99+
func updateUser(_ http.ResponseWriter, _ *http.Request) {}
100+
func deleteUser(_ http.ResponseWriter, _ *http.Request) {}
101+
func listPosts(_ http.ResponseWriter, _ *http.Request) {}
102+
func createPost(_ http.ResponseWriter, _ *http.Request) {}
103+
func showPost(_ http.ResponseWriter, _ *http.Request) {}
104+
func updatePost(_ http.ResponseWriter, _ *http.Request) {}
105+
func listBuckets(_ http.ResponseWriter, _ *http.Request) {}
106+
func createBucket(_ http.ResponseWriter, _ *http.Request) {}
107+
func deleteBucket(_ http.ResponseWriter, _ *http.Request) {}
108+
func listObjects(_ http.ResponseWriter, _ *http.Request) {}
109+
func getObject(_ http.ResponseWriter, _ *http.Request) {}
110+
func putObject(_ http.ResponseWriter, _ *http.Request) {}
111+
func deleteObject(_ http.ResponseWriter, _ *http.Request) {}
112+
func adminDashboard(_ http.ResponseWriter, _ *http.Request) {}
113+
func adminUsers(_ http.ResponseWriter, _ *http.Request) {}
114114
func isDebug() bool { return os.Getenv("DEBUG") == "true" }

internal/core/dispatcher_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
func TestDispatcherSingleRoute(t *testing.T) {
1313
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
14-
w.Write([]byte("OK"))
14+
_, _ = w.Write([]byte("OK"))
1515
})
1616

1717
route := &Route{
@@ -39,10 +39,10 @@ func TestDispatcherSingleRoute(t *testing.T) {
3939

4040
func TestDispatcherQueryMatching(t *testing.T) {
4141
handler1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
42-
w.Write([]byte("HANDLER1"))
42+
_, _ = w.Write([]byte("HANDLER1"))
4343
})
4444
handler2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
45-
w.Write([]byte("HANDLER2"))
45+
_, _ = w.Write([]byte("HANDLER2"))
4646
})
4747

4848
route1 := &Route{
@@ -82,7 +82,7 @@ func TestDispatcherQueryMatching(t *testing.T) {
8282

8383
func TestDispatcherNoMatch(t *testing.T) {
8484
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
85-
w.Write([]byte("OK"))
85+
_, _ = w.Write([]byte("OK"))
8686
})
8787

8888
route := &Route{
@@ -113,7 +113,7 @@ func TestDispatcherContextInjection(t *testing.T) {
113113
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
114114
capturedAction = GetAction(r.Context())
115115
capturedName = GetRouteName(r.Context())
116-
w.Write([]byte("OK"))
116+
_, _ = w.Write([]byte("OK"))
117117
})
118118

119119
route := &Route{
@@ -146,7 +146,7 @@ func TestDispatcherWildcardParams(t *testing.T) {
146146

147147
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
148148
capturedKey = chi.URLParam(r, "key")
149-
w.Write([]byte("OK"))
149+
_, _ = w.Write([]byte("OK"))
150150
})
151151

152152
route := &Route{
@@ -187,7 +187,7 @@ func TestDispatcherMiddleware(t *testing.T) {
187187
}
188188

189189
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
190-
w.Write([]byte("OK"))
190+
_, _ = w.Write([]byte("OK"))
191191
})
192192

193193
route := &Route{

pkg/teapot/additional_methods_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ func TestPatchAndOptions(t *testing.T) {
1212
r := teapot.New()
1313

1414
r.PATCH("/resource", func(w http.ResponseWriter, r *http.Request) {
15-
w.Write([]byte("PATCH"))
15+
_, _ = w.Write([]byte("PATCH"))
1616
})
1717
r.OPTIONS("/resource", func(w http.ResponseWriter, r *http.Request) {
18-
w.Write([]byte("OPTIONS"))
18+
_, _ = w.Write([]byte("OPTIONS"))
1919
})
2020

2121
assertEqual(t, request(t, r, "PATCH", "/resource").Body.String(), "PATCH")
@@ -27,11 +27,11 @@ func TestQueryPOST(t *testing.T) {
2727
r := teapot.New()
2828

2929
r.QueryPOST("/upload", func(w http.ResponseWriter, r *http.Request) {
30-
w.Write([]byte("UPLOAD"))
30+
_, _ = w.Write([]byte("UPLOAD"))
3131
}).Query("uploads")
3232

3333
r.QueryPOST("/upload", func(w http.ResponseWriter, r *http.Request) {
34-
w.Write([]byte("CREATE"))
34+
_, _ = w.Write([]byte("CREATE"))
3535
})
3636

3737
assertEqual(t, request(t, r, "POST", "/upload?uploads").Body.String(), "UPLOAD")
@@ -43,11 +43,11 @@ func TestQueryPUT(t *testing.T) {
4343
r := teapot.New()
4444

4545
r.QueryPUT("/object", func(w http.ResponseWriter, r *http.Request) {
46-
w.Write([]byte("ACL"))
46+
_, _ = w.Write([]byte("ACL"))
4747
}).Query("acl")
4848

4949
r.QueryPUT("/object", func(w http.ResponseWriter, r *http.Request) {
50-
w.Write([]byte("PUT"))
50+
_, _ = w.Write([]byte("PUT"))
5151
})
5252

5353
assertEqual(t, request(t, r, "PUT", "/object?acl").Body.String(), "ACL")
@@ -59,11 +59,11 @@ func TestQueryDELETE(t *testing.T) {
5959
r := teapot.New()
6060

6161
r.QueryDELETE("/object", func(w http.ResponseWriter, r *http.Request) {
62-
w.Write([]byte("DELETE_ALL"))
62+
_, _ = w.Write([]byte("DELETE_ALL"))
6363
}).Query("deleteAll")
6464

6565
r.QueryDELETE("/object", func(w http.ResponseWriter, r *http.Request) {
66-
w.Write([]byte("DELETE"))
66+
_, _ = w.Write([]byte("DELETE"))
6767
})
6868

6969
assertEqual(t, request(t, r, "DELETE", "/object?deleteAll").Body.String(), "DELETE_ALL")
@@ -96,11 +96,11 @@ func TestQueryPATCH(t *testing.T) {
9696
r := teapot.New()
9797

9898
r.QueryPATCH("/resource", func(w http.ResponseWriter, r *http.Request) {
99-
w.Write([]byte("PARTIAL"))
99+
_, _ = w.Write([]byte("PARTIAL"))
100100
}).Query("partial")
101101

102102
r.QueryPATCH("/resource", func(w http.ResponseWriter, r *http.Request) {
103-
w.Write([]byte("PATCH"))
103+
_, _ = w.Write([]byte("PATCH"))
104104
})
105105

106106
assertEqual(t, request(t, r, "PATCH", "/resource?partial").Body.String(), "PARTIAL")
@@ -133,7 +133,7 @@ func TestFinalizeAndIsFinalized(t *testing.T) {
133133
r := teapot.New()
134134

135135
r.GET("/test", func(w http.ResponseWriter, r *http.Request) {
136-
w.Write([]byte("OK"))
136+
_, _ = w.Write([]byte("OK"))
137137
})
138138

139139
// Initially not finalized
@@ -198,19 +198,19 @@ func TestQueryChaining(t *testing.T) {
198198
r := teapot.New()
199199

200200
r.QueryGET("/search", func(w http.ResponseWriter, r *http.Request) {
201-
w.Write([]byte("FULL_ADMIN"))
201+
_, _ = w.Write([]byte("FULL_ADMIN"))
202202
}).Query("admin").QueryValue("type", "full")
203203

204204
r.QueryGET("/search", func(w http.ResponseWriter, r *http.Request) {
205-
w.Write([]byte("ADMIN"))
205+
_, _ = w.Write([]byte("ADMIN"))
206206
}).Query("admin")
207207

208208
r.QueryGET("/search", func(w http.ResponseWriter, r *http.Request) {
209-
w.Write([]byte("FULL"))
209+
_, _ = w.Write([]byte("FULL"))
210210
}).QueryValue("type", "full")
211211

212212
r.QueryGET("/search", func(w http.ResponseWriter, r *http.Request) {
213-
w.Write([]byte("DEFAULT"))
213+
_, _ = w.Write([]byte("DEFAULT"))
214214
})
215215

216216
assertEqual(t, request(t, r, "GET", "/search?admin&type=full").Body.String(), "FULL_ADMIN")

pkg/teapot/helpers_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestChiAccessor(t *testing.T) {
6868
r.Chi().NotFound(func(w http.ResponseWriter, r *http.Request) {
6969
notFoundCalled = true
7070
w.WriteHeader(404)
71-
w.Write([]byte("Custom 404"))
71+
_, _ = w.Write([]byte("Custom 404"))
7272
})
7373

7474
r.GET("/exists", func(w http.ResponseWriter, r *http.Request) {
@@ -119,17 +119,17 @@ func TestRouterWith(t *testing.T) {
119119

120120
// Route without middleware
121121
r.GET("/public", func(w http.ResponseWriter, r *http.Request) {
122-
w.Write([]byte("PUBLIC"))
122+
_, _ = w.Write([]byte("PUBLIC"))
123123
})
124124

125125
// Route with mw1
126126
r.With(mw1).GET("/protected", func(w http.ResponseWriter, r *http.Request) {
127-
w.Write([]byte("PROTECTED"))
127+
_, _ = w.Write([]byte("PROTECTED"))
128128
})
129129

130130
// Route with mw1 and mw2
131131
r.With(mw1, mw2).GET("/admin", func(w http.ResponseWriter, r *http.Request) {
132-
w.Write([]byte("ADMIN"))
132+
_, _ = w.Write([]byte("ADMIN"))
133133
})
134134

135135
// Test public route
@@ -224,17 +224,17 @@ func TestMiddlewareGroup(t *testing.T) {
224224

225225
// Public routes (no middleware)
226226
r.GET("/public", func(w http.ResponseWriter, r *http.Request) {
227-
w.Write([]byte("PUBLIC"))
227+
_, _ = w.Write([]byte("PUBLIC"))
228228
}).Name("public")
229229

230230
// Protected routes (with auth + logging middleware)
231231
r.MiddlewareGroup(func(r *teapot.Router) {
232232
r.GET("/admin", func(w http.ResponseWriter, r *http.Request) {
233-
w.Write([]byte("ADMIN"))
233+
_, _ = w.Write([]byte("ADMIN"))
234234
}).Name("admin")
235235

236236
r.GET("/dashboard", func(w http.ResponseWriter, r *http.Request) {
237-
w.Write([]byte("DASHBOARD"))
237+
_, _ = w.Write([]byte("DASHBOARD"))
238238
}).Name("dashboard")
239239
}, auth, logging)
240240

@@ -344,7 +344,7 @@ func TestMiddlewareGroupWithNamedGroup(t *testing.T) {
344344
r.MiddlewareGroup(func(r *teapot.Router) {
345345
r.NamedGroup("/api", "api", func(r *teapot.Router) {
346346
r.GET("/users", func(w http.ResponseWriter, r *http.Request) {
347-
w.Write([]byte("USERS"))
347+
_, _ = w.Write([]byte("USERS"))
348348
}).Name("users")
349349
})
350350
}, auth)

pkg/teapot/optimized_handler_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func TestFinalizeMinimalRoute(t *testing.T) {
1212
r := teapot.New()
1313

1414
r.GET("/test", func(w http.ResponseWriter, r *http.Request) {
15-
w.Write([]byte("OK"))
15+
_, _ = w.Write([]byte("OK"))
1616
})
1717

1818
// Finalize to trigger optimization
@@ -30,7 +30,7 @@ func TestFinalizeWithActionAndName(t *testing.T) {
3030
r.GET("/bucket", func(w http.ResponseWriter, r *http.Request) {
3131
capturedAction = teapot.GetAction(r)
3232
capturedName = teapot.GetRouteName(r)
33-
w.Write([]byte("OK"))
33+
_, _ = w.Write([]byte("OK"))
3434
}).Name("bucket.list").Action("s3:ListBucket")
3535

3636
// Finalize to trigger optimization
@@ -55,7 +55,7 @@ func TestFinalizeWithMiddleware(t *testing.T) {
5555
}
5656

5757
r.GET("/protected", func(w http.ResponseWriter, r *http.Request) {
58-
w.Write([]byte("OK"))
58+
_, _ = w.Write([]byte("OK"))
5959
}).With(mw)
6060

6161
// Finalize to trigger optimization
@@ -76,7 +76,7 @@ func TestFinalizeWithWildcardParams(t *testing.T) {
7676
var capturedKey string
7777
r.GET("/{bucket}/{key:.*}", func(w http.ResponseWriter, r *http.Request) {
7878
capturedKey = teapot.URLParam(r, "key")
79-
w.Write([]byte("OK"))
79+
_, _ = w.Write([]byte("OK"))
8080
})
8181

8282
// Finalize to trigger optimization
@@ -105,7 +105,7 @@ func TestFinalizeWithEverything(t *testing.T) {
105105
capturedAction = teapot.GetAction(r)
106106
capturedName = teapot.GetRouteName(r)
107107
capturedKey = teapot.URLParam(r, "key")
108-
w.Write([]byte("OK"))
108+
_, _ = w.Write([]byte("OK"))
109109
}).Name("object.get").Action("s3:GetObject").With(mw)
110110

111111
// Finalize to trigger optimization
@@ -130,7 +130,7 @@ func TestRouteBeforeAndAfterFinalize(t *testing.T) {
130130
var capturedAction string
131131
r.GET("/test", func(w http.ResponseWriter, r *http.Request) {
132132
capturedAction = teapot.GetAction(r)
133-
w.Write([]byte("OK"))
133+
_, _ = w.Write([]byte("OK"))
134134
}).Action("test:Action")
135135

136136
// Test before finalization (slow path)
@@ -155,12 +155,12 @@ func TestFinalizeQueryRoutes(t *testing.T) {
155155

156156
r.QueryGET("/bucket", func(w http.ResponseWriter, r *http.Request) {
157157
capturedAction = teapot.GetAction(r)
158-
w.Write([]byte("LIST"))
158+
_, _ = w.Write([]byte("LIST"))
159159
}).Name("bucket.list").Action("s3:ListBucket")
160160

161161
r.QueryGET("/bucket", func(w http.ResponseWriter, r *http.Request) {
162162
capturedAction = teapot.GetAction(r)
163-
w.Write([]byte("ACL"))
163+
_, _ = w.Write([]byte("ACL"))
164164
}).Name("bucket.acl").Action("s3:GetBucketAcl").Query("acl")
165165

166166
// Finalize
@@ -181,7 +181,7 @@ func TestMultipleFinalize(t *testing.T) {
181181
r := teapot.New()
182182

183183
r.GET("/test", func(w http.ResponseWriter, r *http.Request) {
184-
w.Write([]byte("OK"))
184+
_, _ = w.Write([]byte("OK"))
185185
})
186186

187187
// Multiple calls to Finalize should be safe
@@ -199,7 +199,7 @@ func TestFinalizeWithGroups(t *testing.T) {
199199

200200
r.Group("/api", func(r *teapot.Router) {
201201
r.GET("/users", func(w http.ResponseWriter, r *http.Request) {
202-
w.Write([]byte("USERS"))
202+
_, _ = w.Write([]byte("USERS"))
203203
}).Name("api.users")
204204
})
205205

@@ -227,7 +227,7 @@ func TestFinalizeMiddlewareOnly(t *testing.T) {
227227
}
228228

229229
r.GET("/test", func(w http.ResponseWriter, r *http.Request) {
230-
w.Write([]byte("OK"))
230+
_, _ = w.Write([]byte("OK"))
231231
}).With(mw)
232232

233233
// Finalize
@@ -246,7 +246,7 @@ func TestFinalizeActionOnly(t *testing.T) {
246246
var capturedAction string
247247
r.GET("/test", func(w http.ResponseWriter, r *http.Request) {
248248
capturedAction = teapot.GetAction(r)
249-
w.Write([]byte("OK"))
249+
_, _ = w.Write([]byte("OK"))
250250
}).Action("test:Action")
251251

252252
// Finalize
@@ -265,7 +265,7 @@ func TestFinalizeNameOnly(t *testing.T) {
265265
var capturedName string
266266
r.GET("/test", func(w http.ResponseWriter, r *http.Request) {
267267
capturedName = teapot.GetRouteName(r)
268-
w.Write([]byte("OK"))
268+
_, _ = w.Write([]byte("OK"))
269269
}).Name("test.route")
270270

271271
// Finalize

0 commit comments

Comments
 (0)