ory-am/hydra

View on GitHub

Showing 403 of 850 total issues

File api_o_auth2.go has 2579 lines of code (exceeds 500 allowed). Consider refactoring.
Open

/*
Ory Hydra API

Documentation for all of Ory Hydra's APIs.

Severity: Major
Found in internal/httpclient/api_o_auth2.go - About 6 days to fix

    Function TestAuthCodeWithDefaultStrategy has 945 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestAuthCodeWithDefaultStrategy(t *testing.T) {
        ctx := context.Background()
        reg := internal.NewMockedRegistry(t, &contextx.Default{})
        reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
        reg.Config().MustSet(ctx, config.KeyRefreshTokenHook, "")
    Severity: Major
    Found in oauth2/oauth2_auth_code_test.go - About 4 days to fix

      File persister_nid_test.go has 1893 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      // Copyright © 2022 Ory Corp
      // SPDX-License-Identifier: Apache-2.0
      
      package sql_test
      
      
      Severity: Major
      Found in persistence/sql/persister_nid_test.go - About 4 days to fix

        Function TestStrategyLoginConsentNext has 850 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestStrategyLoginConsentNext(t *testing.T) {
            ctx := context.Background()
            reg := internal.NewMockedRegistry(t, &contextx.Default{})
            reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
            reg.Config().MustSet(ctx, config.KeyConsentRequestMaxAge, time.Hour)
        Severity: Major
        Found in consent/strategy_oauth_test.go - About 4 days to fix

          OAuth2Client has 194 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type OAuth2Client struct {
              // OAuth 2.0 Access Token Strategy  AccessTokenStrategy is the strategy used to generate access tokens. Valid options are `jwt` and `opaque`. `jwt` is a bad idea, see https://www.ory.sh/docs/hydra/advanced#json-web-tokens Setting the stragegy here overrides the global setting in `strategies.access_token`.
              AccessTokenStrategy *string  `json:"access_token_strategy,omitempty"`
              AllowedCorsOrigins  []string `json:"allowed_cors_origins,omitempty"`
              Audience            []string `json:"audience,omitempty"`
          Severity: Major
          Found in internal/httpclient/model_o_auth2_client.go - About 3 days to fix

            File oauth2_auth_code_test.go has 1659 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            // Copyright © 2022 Ory Corp
            // SPDX-License-Identifier: Apache-2.0
            
            package oauth2_test
            
            
            Severity: Major
            Found in oauth2/oauth2_auth_code_test.go - About 3 days to fix

              Function ManagerTests has 658 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func ManagerTests(deps Deps, m consent.Manager, clientManager client.Manager, fositeManager x.FositeStorer, network string, parallel bool) func(t *testing.T) {
                  lr := make(map[string]*flow.LoginRequest)
              
                  return func(t *testing.T) {
                      if parallel {
              Severity: Major
              Found in consent/test/manager_test_helpers.go - About 3 days to fix

                File model_o_auth2_client.go has 1307 lines of code (exceeds 500 allowed). Consider refactoring.
                Open

                /*
                Ory Hydra API
                
                Documentation for all of Ory Hydra's APIs.
                
                
                Severity: Major
                Found in internal/httpclient/model_o_auth2_client.go - About 2 days to fix

                  Function ManagerTests has a Cognitive Complexity of 145 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func ManagerTests(deps Deps, m consent.Manager, clientManager client.Manager, fositeManager x.FositeStorer, network string, parallel bool) func(t *testing.T) {
                      lr := make(map[string]*flow.LoginRequest)
                  
                      return func(t *testing.T) {
                          if parallel {
                  Severity: Minor
                  Found in consent/test/manager_test_helpers.go - About 2 days 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 TestHandler has 500 lines of code (exceeds 50 allowed). Consider refactoring.
                  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 2 days to fix

                    Function TestAuthCodeWithMockStrategy has 492 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestAuthCodeWithMockStrategy(t *testing.T) {
                        ctx := context.Background()
                        for _, strat := range []struct{ d string }{{d: "opaque"}, {d: "jwt"}} {
                            t.Run("strategy="+strat.d, func(t *testing.T) {
                                conf := internal.NewConfigurationWithDefaults()
                    Severity: Major
                    Found in oauth2/oauth2_auth_code_test.go - About 2 days to fix

                      OidcConfiguration has 118 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      type OidcConfiguration struct {
                          // OAuth 2.0 Authorization Endpoint URL
                          AuthorizationEndpoint string `json:"authorization_endpoint"`
                          // OpenID Connect Back-Channel Logout Session Required  Boolean value specifying whether the OP can pass a sid (session ID) Claim in the Logout Token to identify the RP session with the OP. If supported, the sid Claim is also included in ID Tokens issued by the OP
                          BackchannelLogoutSessionSupported *bool `json:"backchannel_logout_session_supported,omitempty"`
                      Severity: Major
                      Found in internal/httpclient/model_oidc_configuration.go - About 2 days to fix

                        Function TestLogoutFlows has 473 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func TestLogoutFlows(t *testing.T) {
                            ctx := context.Background()
                            fakeKratos := kratos.NewFake()
                            reg := internal.NewMockedRegistry(t, &contextx.Default{})
                            reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
                        Severity: Major
                        Found in consent/strategy_logout_test.go - About 2 days to fix

                          Function TestJWTBearer has 432 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func TestJWTBearer(t *testing.T) {
                              ctx := context.Background()
                              reg := internal.NewMockedRegistry(t, &contextx.Default{})
                              reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
                              _, admin := testhelpers.NewOAuth2Server(ctx, t, reg)
                          Severity: Major
                          Found in oauth2/oauth2_jwt_bearer_test.go - About 2 days to fix

                            Function TestAuthCodeWithMockStrategy has a Cognitive Complexity of 106 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func TestAuthCodeWithMockStrategy(t *testing.T) {
                                ctx := context.Background()
                                for _, strat := range []struct{ d string }{{d: "opaque"}, {d: "jwt"}} {
                                    t.Run("strategy="+strat.d, func(t *testing.T) {
                                        conf := internal.NewConfigurationWithDefaults()
                            Severity: Minor
                            Found in oauth2/oauth2_auth_code_test.go - About 1 day 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

                            File fosite_store_helpers.go has 1000 lines of code (exceeds 500 allowed). Consider refactoring.
                            Open

                            // Copyright © 2022 Ory Corp
                            // SPDX-License-Identifier: Apache-2.0
                            
                            package oauth2
                            
                            
                            Severity: Major
                            Found in oauth2/fosite_store_helpers.go - About 1 day to fix

                              File manager_test_helpers.go has 998 lines of code (exceeds 500 allowed). Consider refactoring.
                              Open

                              // Copyright © 2022 Ory Corp
                              // SPDX-License-Identifier: Apache-2.0
                              
                              package test
                              
                              
                              Severity: Major
                              Found in consent/test/manager_test_helpers.go - About 1 day to fix

                                PersisterTestSuite has 84 methods (exceeds 20 allowed). Consider refactoring.
                                Open

                                type PersisterTestSuite struct {
                                    suite.Suite
                                    registries map[string]driver.Registry
                                    t1         context.Context
                                    t2         context.Context
                                Severity: Major
                                Found in persistence/sql/persister_nid_test.go - About 1 day to fix

                                  File strategy_oauth_test.go has 905 lines of code (exceeds 500 allowed). Consider refactoring.
                                  Open

                                  // Copyright © 2022 Ory Corp
                                  // SPDX-License-Identifier: Apache-2.0
                                  
                                  package consent_test
                                  
                                  
                                  Severity: Major
                                  Found in consent/strategy_oauth_test.go - About 1 day to fix

                                    OidcUserInfo has 78 methods (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    type OidcUserInfo struct {
                                        // End-User's birthday, represented as an ISO 8601:2004 [ISO8601‑2004] YYYY-MM-DD format. The year MAY be 0000, indicating that it is omitted. To represent only the year, YYYY format is allowed. Note that depending on the underlying platform's date related function, providing just year can result in varying month and day, so the implementers need to take this factor into account to correctly process the dates.
                                        Birthdate *string `json:"birthdate,omitempty"`
                                        // End-User's preferred e-mail address. Its value MUST conform to the RFC 5322 [RFC5322] addr-spec syntax. The RP MUST NOT rely upon this value being unique, as discussed in Section 5.7.
                                        Email *string `json:"email,omitempty"`
                                    Severity: Major
                                    Found in internal/httpclient/model_oidc_user_info.go - About 1 day to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language