diff options
author | Wim <wim@42.be> | 2022-06-20 12:02:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-20 12:02:49 +0200 |
commit | cb50375e2b6abf0c79d4891e5e1ea775b9759cd2 (patch) | |
tree | 938af0f442baf79cebd114692aff5ad6af37f987 /models/auth | |
parent | 3289abcefc563d6ea16c1dbd19680b874a58a6d3 (diff) | |
download | gitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.tar.gz gitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.zip |
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)
Diffstat (limited to 'models/auth')
-rw-r--r-- | models/auth/oauth2.go | 8 |
1 files changed, 4 insertions, 4 deletions
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 |