ory-am/hydra

View on GitHub

Showing 412 of 865 total issues

Method JwkAPIService.DeleteJsonWebKeyExecute has 7 return statements (exceeds 4 allowed).
Open

func (a *JwkAPIService) DeleteJsonWebKeyExecute(r ApiDeleteJsonWebKeyRequest) (*http.Response, error) {
    var (
        localVarHTTPMethod = http.MethodDelete
        localVarPostBody   interface{}
        formFiles          []formFile
Severity: Major
Found in internal/httpclient/api_jwk.go - About 45 mins to fix

    Function NewPersister has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func NewPersister(ctx context.Context, c *pop.Connection, r Dependencies, config *config.DefaultProvider, extraMigrations []fs.FS, goMigrations []popx.Migration) (*Persister, error) {
    Severity: Minor
    Found in persistence/sql/persister.go - About 45 mins to fix

      Method RegistrySQL.Init has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          ctx context.Context,
          skipNetworkInit bool,
          migrate bool,
          ctxer contextx.Contextualizer,
          extraMigrations []fs.FS,
      Severity: Minor
      Found in driver/registry_sql.go - About 45 mins to fix

        Method Handler.CreateClient has 7 return statements (exceeds 4 allowed).
        Open

        func (h *Handler) CreateClient(r *http.Request, validator func(context.Context, *Client) error, isDynamic bool) (*Client, error) {
            var c Client
            if err := json.NewDecoder(r.Body).Decode(&c); err != nil {
                return nil, errorsx.WithStack(herodot.ErrBadRequest.WithReasonf("Unable to decode the request body: %s", err))
            }
        Severity: Major
        Found in client/handler.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

              } else if gt == fosite.GrantTypePassword {
                  if tt == fosite.AccessToken && c.PasswordGrantAccessTokenLifespan.Valid {
                      cl = &c.PasswordGrantAccessTokenLifespan.Duration
                  } else if tt == fosite.RefreshToken && c.PasswordGrantRefreshTokenLifespan.Valid {
                      cl = &c.PasswordGrantRefreshTokenLifespan.Duration
          Severity: Major
          Found in client/client.go - About 45 mins to fix

            Function TestHandler has 7 return statements (exceeds 4 allowed).
            Open

            func TestHandler(t *testing.T) {
                ctx := context.Background()
                reg := internal.NewMockedRegistry(t, &contextx.Default{})
                h := client.NewHandler(reg)
                reg.WithContextualizer(&contextx.TestContextualizer{})
            Severity: Major
            Found in client/handler_test.go - About 45 mins to fix

              Method MetadataAPIService.GetVersionExecute has 7 return statements (exceeds 4 allowed).
              Open

              func (a *MetadataAPIService) GetVersionExecute(r ApiGetVersionRequest) (*GetVersion200Response, *http.Response, error) {
                  var (
                      localVarHTTPMethod  = http.MethodGet
                      localVarPostBody    interface{}
                      formFiles           []formFile
              Severity: Major
              Found in internal/httpclient/api_metadata.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        if tt == fosite.AccessToken && c.JwtBearerGrantAccessTokenLifespan.Valid {
                            cl = &c.JwtBearerGrantAccessTokenLifespan.Duration
                        }
                Severity: Major
                Found in client/client.go - About 45 mins to fix

                  Method Persister.flushInactiveTokens has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (p *Persister) flushInactiveTokens(ctx context.Context, notAfter time.Time, limit int, batchSize int, table tableName, lifespan time.Duration) (err error) {
                  Severity: Minor
                  Found in persistence/sql/persister_oauth2.go - About 45 mins to fix

                    Function BenchmarkClientCredentials has 7 return statements (exceeds 4 allowed).
                    Open

                    func BenchmarkClientCredentials(b *testing.B) {
                        ctx := context.Background()
                    
                        spans := tracetest.NewSpanRecorder()
                        tracer := trace.NewTracerProvider(trace.WithSpanProcessor(spans)).Tracer("")
                    Severity: Major
                    Found in oauth2/oauth2_client_credentials_bench_test.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  for {
                                                      bo := conf.NextBackOff()
                                                      require.NotEqual(t, backoff.Stop, bo, "%+v", err)
                      
                                                      _, _, err = hydra.JwkAPI.CreateJsonWebKeySet(context.Background(), "hydra.openid.id-token").CreateJsonWebKeySet(hydrac.CreateJsonWebKeySet{
                      Severity: Major
                      Found in test/conformance/run_test.go - About 45 mins to fix

                        Method Handler.getOidcUserInfo has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (h *Handler) getOidcUserInfo(w http.ResponseWriter, r *http.Request) {
                            ctx := r.Context()
                            session := NewSessionWithCustomClaims(ctx, h.c, "")
                            tokenType, ar, err := h.r.OAuth2Provider().IntrospectToken(ctx, fosite.AccessTokenFromRequest(r), fosite.AccessToken, session)
                            if err != nil {
                        Severity: Minor
                        Found in oauth2/handler.go - About 45 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

                        Function createAccessTokenSessionPairwise has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func createAccessTokenSessionPairwise(subject, client string, token string, expiresAt time.Time, fs x.FositeStorer, scopes fosite.Arguments, obfuscated string) {
                        Severity: Minor
                        Found in oauth2/revocator_test.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if dbName != dbal.DriverMySQL {
                                                          t.Errorf("an unexpected RFC6749 error with the name %q was returned.\n"+
                                                              "Hint: has the refresh token error handling changed in fosite? If so, you need to add further "+
                                                              "assertions here to cover the additional errors that are being returned by the handler.\n"+
                                                              "DB version: %s\n"+
                          Severity: Major
                          Found in oauth2/oauth2_refresh_token_test.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                        switch dbName {
                                                        case dbal.DriverMySQL:
                                                        case dbal.DriverPostgreSQL, dbal.DriverCockroachDB:
                                                            var matched bool
                                                            for _, errSubstr := range []string{
                            Severity: Major
                            Found in oauth2/oauth2_refresh_token_test.go - About 45 mins to fix

                              Function TestUserinfo has 7 return statements (exceeds 4 allowed).
                              Open

                              func TestUserinfo(t *testing.T) {
                                  ctx := context.Background()
                                  conf := internal.NewConfigurationWithDefaults()
                                  conf.MustSet(ctx, config.KeyScopeStrategy, "")
                                  conf.MustSet(ctx, config.KeyAuthCodeLifespan, lifespan)
                              Severity: Major
                              Found in oauth2/handler_test.go - About 45 mins to fix

                                Method Persister.ConfirmLoginSession has 7 return statements (exceeds 4 allowed).
                                Open

                                func (p *Persister) ConfirmLoginSession(ctx context.Context, loginSession *flow.LoginSession) (err error) {
                                    ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.ConfirmLoginSession")
                                    defer otelx.End(span, &err)
                                
                                    loginSession.NID = p.NetworkID(ctx)
                                Severity: Major
                                Found in persistence/sql/persister_consent.go - About 45 mins to fix

                                  Function checkTokenResponse has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func checkTokenResponse(token oauth2token) {
                                      if token.RefreshToken == "" {
                                          log.Fatalf("Expected a refresh token but none received: %+v", token)
                                      }
                                  
                                  
                                  Severity: Minor
                                  Found in test/mock-client/main.go - About 45 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

                                  Method DefaultStrategy.authenticationSession has 6 return statements (exceeds 4 allowed).
                                  Open

                                  func (s *DefaultStrategy) authenticationSession(ctx context.Context, _ http.ResponseWriter, r *http.Request) (*flow.LoginSession, error) {
                                      store, err := s.r.CookieStore(ctx)
                                      if err != nil {
                                          return nil, err
                                      }
                                  Severity: Major
                                  Found in consent/strategy_default.go - About 40 mins to fix

                                    Method Flow.HandleLoginRequest has 6 return statements (exceeds 4 allowed).
                                    Open

                                    func (f *Flow) HandleLoginRequest(h *HandledLoginRequest) error {
                                        if f.LoginWasUsed {
                                            return errors.WithStack(x.ErrConflict.WithHint("The login request was already used and can no longer be changed."))
                                        }
                                    
                                    
                                    Severity: Major
                                    Found in flow/flow.go - About 40 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language