diff --git a/.golangci.yml b/.golangci.yml index 192d484a..eab781a1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 diff --git a/_example/main.go b/_example/main.go index de0b9e82..2a2e42dc 100644 --- a/_example/main.go +++ b/_example/main.go @@ -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") } diff --git a/avatar/localfs.go b/avatar/localfs.go index f387d2f7..ee4828c0 100644 --- a/avatar/localfs.go +++ b/avatar/localfs.go @@ -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 } diff --git a/logger/interface.go b/logger/interface.go index ac43b009..85724318 100644 --- a/logger/interface.go +++ b/logger/interface.go @@ -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...) }) diff --git a/provider/apple_test.go b/provider/apple_test.go index 3ed103b5..f448ae77 100644 --- a/provider/apple_test.go +++ b/provider/apple_test.go @@ -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), @@ -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) diff --git a/provider/oauth1_test.go b/provider/oauth1_test.go index 4089803d..7a8d1182 100644 --- a/provider/oauth1_test.go +++ b/provider/oauth1_test.go @@ -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 ( @@ -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)) diff --git a/provider/oauth2_test.go b/provider/oauth2_test.go index d510123b..26a51a8d 100644 --- a/provider/oauth2_test.go +++ b/provider/oauth2_test.go @@ -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), @@ -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) diff --git a/provider/providers.go b/provider/providers.go index 186f498f..4487b4cb 100644 --- a/provider/providers.go +++ b/provider/providers.go @@ -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"),