From cb50375e2b6abf0c79d4891e5e1ea775b9759cd2 Mon Sep 17 00:00:00 2001 From: Wim Date: Mon, 20 Jun 2022 12:02:49 +0200 Subject: Add more linters to improve code readability (#19989) Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability - nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. - unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions - wastedassign - https://github.com/sanposhiho/wastedassign - wastedassign finds wasted assignment statements. - notlintlint - Reports ill-formed or insufficient nolint directives - stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005) --- models/auth/oauth2.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'models/auth') diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index c5c6e91120..5a58ec62b7 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -123,7 +123,7 @@ func GetOAuth2ApplicationByClientID(ctx context.Context, clientID string) (app * if !has { return nil, ErrOAuthClientIDInvalid{ClientID: clientID} } - return + return app, err } // GetOAuth2ApplicationByID returns the oauth2 application with the given id. Returns an error if not found. @@ -143,7 +143,7 @@ func GetOAuth2ApplicationByID(ctx context.Context, id int64) (app *OAuth2Applica func GetOAuth2ApplicationsByUserID(ctx context.Context, userID int64) (apps []*OAuth2Application, err error) { apps = make([]*OAuth2Application, 0) err = db.GetEngine(ctx).Where("uid = ?", userID).Find(&apps) - return + return apps, err } // CreateOAuth2ApplicationOptions holds options to create an oauth2 application @@ -300,7 +300,7 @@ func (code *OAuth2AuthorizationCode) GenerateRedirectURI(state string) (redirect } q.Set("code", code.Code) redirect.RawQuery = q.Encode() - return + return redirect, err } // Invalidate deletes the auth code from the database to invalidate this code @@ -430,7 +430,7 @@ func GetOAuth2GrantByID(ctx context.Context, id int64) (grant *OAuth2Grant, err } else if !has { return nil, nil } - return + return grant, err } // GetOAuth2GrantsByUserID lists all grants of a certain user -- cgit v1.2.3