ory-am/hydra

View on GitHub

Showing 412 of 865 total issues

Method Handler.introspectOAuth2Token has 5 return statements (exceeds 4 allowed).
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" {
Severity: Major
Found in oauth2/handler.go - About 35 mins to fix

    Method Persister.mySQLConfirmLoginSession has 5 return statements (exceeds 4 allowed).
    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
        }
    Severity: Major
    Found in persistence/sql/persister_consent.go - About 35 mins to fix

      Method NullDuration.UnmarshalJSON has 5 return statements (exceeds 4 allowed).
      Open

      func (ns *NullDuration) UnmarshalJSON(data []byte) error {
          if ns == nil {
              return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
          }
      
      
      Severity: Major
      Found in x/sqlx.go - About 35 mins to fix

        Method Persister.GetAccessTokenSession has 5 return statements (exceeds 4 allowed).
        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}
        Severity: Major
        Found in persistence/sql/persister_oauth2.go - About 35 mins to fix

          Method SQLDataRows.ToJWK has 5 return statements (exceeds 4 allowed).
          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, "")
          Severity: Major
          Found in jwk/manager.go - About 35 mins to fix

            Function checkStatus has 5 return statements (exceeds 4 allowed).
            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)
            Severity: Major
            Found in test/conformance/run_test.go - About 35 mins to fix

              Function executeHookAndUpdateSession has 5 return statements (exceeds 4 allowed).
              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.
              Severity: Major
              Found in oauth2/token_hook.go - About 35 mins to fix

                Function BenchmarkAuthCode has 5 return statements (exceeds 4 allowed).
                Open

                func BenchmarkAuthCode(b *testing.B) {
                    flag.Parse()
                
                    ctx := context.Background()
                
                
                Severity: Major
                Found in oauth2/oauth2_auth_code_bench_test.go - About 35 mins to fix

                  Method Session.UnmarshalJSON has 5 return statements (exceeds 4 allowed).
                  Open

                  func (s *Session) UnmarshalJSON(original []byte) (err error) {
                      transformed := original
                      originalParsed := gjson.ParseBytes(original)
                  
                      for oldKey, newKey := range keyRewrites {
                  Severity: Major
                  Found in oauth2/session.go - About 35 mins to fix

                    Method Persister.VerifyAndInvalidateLoginRequest has 5 return statements (exceeds 4 allowed).
                    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)
                    Severity: Major
                    Found in persistence/sql/persister_consent.go - About 35 mins to fix

                      Method Duration.UnmarshalJSON has 5 return statements (exceeds 4 allowed).
                      Open

                      func (ns *Duration) UnmarshalJSON(data []byte) error {
                          if ns == nil {
                              return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
                          }
                      
                      
                      Severity: Major
                      Found in x/sqlx.go - About 35 mins to fix

                        Method Handler.createVerifiableCredential has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                        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)
                        Severity: Minor
                        Found in oauth2/handler.go - About 25 mins to fix

                        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"

                        Further reading

                        Severity
                        Category
                        Status
                        Source
                        Language