Skip to content

Commit

Permalink
fix golangci-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed Mar 22, 2024
1 parent 45111d8 commit 35ea494
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ issues:
- text: 'Deferring unsafe method "Close" on type "io.ReadCloser"'
linters:
- gosec
- linters:
- unparam
- unused
- revive
path: _test\.go$
text: "unused-parameter"
exclude-use-default: false
2 changes: 1 addition & 1 deletion _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func initGoauth2Srv() *goauth2.Server {

srv := goauth2.NewServer(goauth2.NewConfig(), manager)

srv.SetUserAuthorizationHandler(func(w http.ResponseWriter, r *http.Request) (string, error) {
srv.SetUserAuthorizationHandler(func(_ http.ResponseWriter, r *http.Request) (string, error) {
if r.Form.Get("username") != "admin" || r.Form.Get("password") != "admin" {
return "", fmt.Errorf("wrong creds. Use: admin admin")
}
Expand Down
2 changes: 1 addition & 1 deletion avatar/localfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (fs *LocalFS) Remove(avatar string) error {
// note: id includes .image suffix
func (fs *LocalFS) List() (ids []string, err error) {
err = filepath.Walk(fs.storePath,
func(path string, info os.FileInfo, err error) error {
func(_ string, info os.FileInfo, err error) error {
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion logger/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Func func(format string, args ...interface{})
func (f Func) Logf(format string, args ...interface{}) { f(format, args...) }

// NoOp logger
var NoOp = Func(func(format string, args ...interface{}) {})
var NoOp = Func(func(string, ...interface{}) {})

// Std logger sends to std default logger directly
var Std = Func(func(format string, args ...interface{}) { log.Printf(format, args...) })
4 changes: 2 additions & 2 deletions provider/apple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func prepareAppleOauthTest(t *testing.T, loginPort, authPort int, testToken *str
ts := &http.Server{Addr: fmt.Sprintf(":%d", loginPort), Handler: http.HandlerFunc(svc.Handler)} //nolint:gosec

count := 0
useIds := []string{"myuser1", "myuser2"} // user for first ans second calls
useIDs := []string{"myuser1", "myuser2"} // user for first ans second calls

oauth := &http.Server{ //nolint:gosec
Addr: fmt.Sprintf(":%d", authPort),
Expand Down Expand Up @@ -542,7 +542,7 @@ func prepareAppleOauthTest(t *testing.T, loginPort, authPort int, testToken *str
"id": "%s",
"name":"blah",
"picture":"http://exmple.com/pic1.png"
}`, useIds[count])
}`, useIDs[count])
count++
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
Expand Down
4 changes: 2 additions & 2 deletions provider/oauth1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func prepOauth1Test(t *testing.T, loginPort, authPort int) func() { //nolint
ts := &http.Server{Addr: fmt.Sprintf(":%d", loginPort), Handler: http.HandlerFunc(svc.Handler)} //nolint:gosec

count := 0
useIds := []string{"myuser1", "myuser2"} // user for first ans second calls
useIDs := []string{"myuser1", "myuser2"} // user for first ans second calls

//nolint
var (
Expand Down Expand Up @@ -270,7 +270,7 @@ func prepOauth1Test(t *testing.T, loginPort, authPort int) func() { //nolint
"id": "%s",
"name":"blah",
"picture":"http://exmple.com/pic1.png"
}`, useIds[count])
}`, useIDs[count])
count++
w.Header().Set("Content-Type", "application/json; charset=utf-8")
_, err := w.Write([]byte(res))
Expand Down
4 changes: 2 additions & 2 deletions provider/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func prepOauth2Test(t *testing.T, loginPort, authPort int, btHook BearerTokenHoo
ts := &http.Server{Addr: fmt.Sprintf(":%d", loginPort), Handler: http.HandlerFunc(svc.Handler)} //nolint:gosec

count := 0
useIds := []string{"myuser1", "myuser2"} // user for first ans second calls
useIDs := []string{"myuser1", "myuser2"} // user for first ans second calls

oauth := &http.Server{ //nolint:gosec
Addr: fmt.Sprintf(":%d", authPort),
Expand Down Expand Up @@ -335,7 +335,7 @@ func prepOauth2Test(t *testing.T, loginPort, authPort int, btHook BearerTokenHoo
"id": "%s",
"name":"blah",
"picture":"http://exmple.com/pic1.png"
}`, useIds[count])
}`, useIDs[count])
count++
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
Expand Down
2 changes: 1 addition & 1 deletion provider/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func NewMicrosoft(p Params) Oauth2Handler {
infoURL: "https://graph.microsoft.com/v1.0/me",
// non-beta doesn't provide photo for consumers yet
// see https://github.com/microsoftgraph/microsoft-graph-docs/issues/3990
mapUser: func(data UserData, b []byte) token.User {
mapUser: func(data UserData, _ []byte) token.User {
userInfo := token.User{
ID: "microsoft_" + token.HashID(sha1.New(), data.Value("id")),
Name: data.Value("displayName"),
Expand Down

0 comments on commit 35ea494

Please sign in to comment.