1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-07-15 01:44:22 +02:00

chore(lint): fix staticcheck issues (#3061)

* chores: fix staticcheck QF1012

Fix use of fmt.Sprintf when writing to a writer.
https://staticcheck.dev/docs/checks/#QF1012
https://github.com/oauth2-proxy/oauth2-proxy/issues/3060

* chores: fix staticcheck QF1003

Use switch instead of multiple if/else.
https://staticcheck.dev/docs/checks/#QF1003
https://github.com/oauth2-proxy/oauth2-proxy/issues/3060

* chores: exclude staticcheck QF1008 for now

We aim to migrate golangci-lint to v2
Let's disable QF1008 (Omit embedded fields from selector expression)
for now.
https://staticcheck.dev/docs/checks/#QF1008

* chores: fix golangci config: run.deadline -> timeout

Rename config option to match v1 documentation: deadline -> timeout.
https://golangci.github.io/legacy-v1-doc/usage/configuration/#run-configuration

This error has been spotted by golangci-lint v2 migration tool.

* chores: fix staticcheck QF1012
This commit is contained in:
Olivier Mengué
2025-05-26 12:29:34 +02:00
committed by GitHub
parent 09f6252ebf
commit 1225d611e9
4 changed files with 17 additions and 12 deletions

View File

@ -167,7 +167,7 @@ var _ = Describe("Writer", func() {
writer: &WriterFuncs{
SignInPageFunc: func(rw http.ResponseWriter, req *http.Request, redirectURL string, statusCode int) {
rw.WriteHeader(202)
rw.Write([]byte(fmt.Sprintf("%s %s", req.URL.Path, redirectURL)))
fmt.Fprintf(rw, "%s %s", req.URL.Path, redirectURL)
},
},
expectedStatus: 202,
@ -200,7 +200,7 @@ var _ = Describe("Writer", func() {
writer: &WriterFuncs{
ErrorPageFunc: func(rw http.ResponseWriter, opts ErrorPageOpts) {
rw.WriteHeader(503)
rw.Write([]byte(fmt.Sprintf("%s %s", opts.RequestID, opts.RedirectURL)))
fmt.Fprintf(rw, "%s %s", opts.RequestID, opts.RedirectURL)
},
},
expectedStatus: 503,
@ -230,7 +230,7 @@ var _ = Describe("Writer", func() {
writer: &WriterFuncs{
ProxyErrorFunc: func(rw http.ResponseWriter, req *http.Request, proxyErr error) {
rw.WriteHeader(503)
rw.Write([]byte(fmt.Sprintf("%s %v", req.URL.Path, proxyErr)))
fmt.Fprintf(rw, "%s %v", req.URL.Path, proxyErr)
},
},
expectedStatus: 503,