Showing 412 of 865 total issues
Method Handler.introspectOAuth2Token
has 5 return statements (exceeds 4 allowed). Open
Open
func (h *Handler) introspectOAuth2Token(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := r.Context()
session := NewSessionWithCustomClaims(ctx, h.c, "")
if r.Method != "POST" {
Method Persister.mySQLConfirmLoginSession
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Persister) mySQLConfirmLoginSession(ctx context.Context, session *flow.LoginSession) error {
err := sqlcon.HandleError(p.Connection(ctx).Create(session))
if err == nil {
return nil
}
Method NullDuration.UnmarshalJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func (ns *NullDuration) UnmarshalJSON(data []byte) error {
if ns == nil {
return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
}
Method Persister.GetAccessTokenSession
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Persister) GetAccessTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error) {
ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.GetAccessTokenSession")
defer otelx.End(span, &err)
r := OAuth2RequestSQL{Table: sqlTableAccess}
Method SQLDataRows.ToJWK
has 5 return statements (exceeds 4 allowed). Open
Open
func (d SQLDataRows) ToJWK(ctx context.Context, r interface {
KeyCipher() *aead.AESGCM
}) (keys *jose.JSONWebKeySet, err error) {
if len(d) == 0 {
return nil, errors.Wrap(x.ErrNotFound, "")
Function checkStatus
has 5 return statements (exceeds 4 allowed). Open
Open
func checkStatus(t *testing.T, testID string) (string, status) {
res, err := httpClient.Get(urlx.AppendPaths(server, "/api/info", testID).String())
require.NoError(t, err)
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
Function executeHookAndUpdateSession
has 5 return statements (exceeds 4 allowed). Open
Open
func executeHookAndUpdateSession(ctx context.Context, reg x.HTTPClientProvider, hookConfig *config.HookConfig, reqBodyBytes []byte, session *Session) error {
req, err := retryablehttp.NewRequestWithContext(ctx, http.MethodPost, hookConfig.URL, bytes.NewReader(reqBodyBytes))
if err != nil {
return errorsx.WithStack(
fosite.ErrServerError.
Function BenchmarkAuthCode
has 5 return statements (exceeds 4 allowed). Open
Open
func BenchmarkAuthCode(b *testing.B) {
flag.Parse()
ctx := context.Background()
Method Session.UnmarshalJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *Session) UnmarshalJSON(original []byte) (err error) {
transformed := original
originalParsed := gjson.ParseBytes(original)
for oldKey, newKey := range keyRewrites {
Method Persister.VerifyAndInvalidateLoginRequest
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Persister) VerifyAndInvalidateLoginRequest(ctx context.Context, verifier string) (_ *flow.HandledLoginRequest, err error) {
ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.VerifyAndInvalidateLoginRequest")
defer otelx.End(span, &err)
f, err := flowctx.Decode[flow.Flow](ctx, p.r.FlowCipher(), verifier, flowctx.AsLoginVerifier)
Method Duration.UnmarshalJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func (ns *Duration) UnmarshalJSON(data []byte) error {
if ns == nil {
return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
}
Method Handler.createVerifiableCredential
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func (h *Handler) createVerifiableCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
session := NewSessionWithCustomClaims(ctx, h.c, "")
accessToken := fosite.AccessTokenFromRequest(r)
tokenType, _, err := h.r.OAuth2Provider().IntrospectToken(ctx, accessToken, fosite.AccessToken, session)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"