ory-am/hydra

View on GitHub

Showing 402 of 849 total issues

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

    Method JwkApiService.DeleteJsonWebKeySetExecute has 7 return statements (exceeds 4 allowed).
    Open

    func (a *JwkApiService) DeleteJsonWebKeySetExecute(r ApiDeleteJsonWebKeySetRequest) (*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

      Avoid deeply nested control flow statements.
      Open

          } else if s, ok := body.(*string); ok {
              _, err = bodyBuf.WriteString(*s)
          } else if JsonCheck.MatchString(contentType) {
              err = json.NewEncoder(bodyBuf).Encode(body)
          } else if XmlCheck.MatchString(contentType) {
      Severity: Major
      Found in internal/httpclient/client.go - About 45 mins to fix

        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

                                      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

            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

            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

              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 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 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

                  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

                    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

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

                      func (s *DefaultStrategy) requestConsent(
                          ctx context.Context,
                          w http.ResponseWriter,
                          r *http.Request,
                          ar fosite.AuthorizeRequester,
                      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

                          Method OidcApiService.RevokeOidcSessionExecute has 6 return statements (exceeds 4 allowed).
                          Open

                          func (a *OidcApiService) RevokeOidcSessionExecute(r ApiRevokeOidcSessionRequest) (*http.Response, error) {
                              var (
                                  localVarHTTPMethod = http.MethodGet
                                  localVarPostBody   interface{}
                                  formFiles          []formFile
                          Severity: Major
                          Found in internal/httpclient/api_oidc.go - About 40 mins to fix

                            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

                              Function serve has 6 return statements (exceeds 4 allowed).
                              Open

                              func serve(
                                  ctx context.Context,
                                  d driver.Registry,
                                  cmd *cobra.Command,
                                  wg *sync.WaitGroup,
                              Severity: Major
                              Found in cmd/server/handler.go - About 40 mins to fix

                                Method MigrateHandler.MigrateStatus has 6 return statements (exceeds 4 allowed).
                                Open

                                func (h *MigrateHandler) MigrateStatus(cmd *cobra.Command, args []string) error {
                                    p, err := h.makePersister(cmd, args)
                                    if err != nil {
                                        return err
                                    }
                                Severity: Major
                                Found in cmd/cli/handler_migrate.go - About 40 mins to fix

                                  Function NewUpdateClientCmd has 6 return statements (exceeds 4 allowed).
                                  Open

                                  func NewUpdateClientCmd() *cobra.Command {
                                      cmd := &cobra.Command{
                                          Use:     "oauth2-client [id]",
                                          Aliases: []string{"client"},
                                          Short:   "Update an OAuth 2.0 Client",
                                  Severity: Major
                                  Found in cmd/cmd_update_client.go - About 40 mins to fix

                                    Method Persister.GetKeySet has 6 return statements (exceeds 4 allowed).
                                    Open

                                    func (p *Persister) GetKeySet(ctx context.Context, set string) (keys *jose.JSONWebKeySet, err error) {
                                        ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.GetKeySet")
                                        defer span.End()
                                    
                                        var js []jwk.SQLData
                                    Severity: Major
                                    Found in persistence/sql/persister_jwk.go - About 40 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language