ory-am/hydra

View on GitHub

Showing 412 of 865 total issues

Function NewPerformAuthorizationCodeCmd has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

func NewPerformAuthorizationCodeCmd() *cobra.Command {
    cmd := &cobra.Command{
        Use:     "authorization-code",
        Example: "{{ .CommandPath }} --client-id ... --client-secret ...",
        Short:   "Example OAuth 2.0 Client performing the OAuth 2.0 Authorize Code Flow",
Severity: Minor
Found in cmd/cmd_perform_authorization_code.go - About 3 hrs 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 Validator.Validate has 117 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (v *Validator) Validate(ctx context.Context, c *Client) error {
    if c.TokenEndpointAuthMethod == "" {
        c.TokenEndpointAuthMethod = "client_secret_basic"
    } else if c.TokenEndpointAuthMethod == "private_key_jwt" {
        if len(c.JSONWebKeysURI) == 0 && c.JSONWebKeys == nil {
Severity: Major
Found in client/validator.go - About 3 hrs to fix

    AcceptOAuth2ConsentRequest has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type AcceptOAuth2ConsentRequest struct {
        Context                  interface{} `json:"context,omitempty"`
        GrantAccessTokenAudience []string    `json:"grant_access_token_audience,omitempty"`
        GrantScope               []string    `json:"grant_scope,omitempty"`
        HandledAt                *time.Time  `json:"handled_at,omitempty"`
    Severity: Minor
    Found in internal/httpclient/model_accept_o_auth2_consent_request.go - About 3 hrs to fix

      Function TestIntrospectorSDK has 114 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestIntrospectorSDK(t *testing.T) {
          ctx := context.Background()
          conf := internal.NewConfigurationWithDefaults()
          conf.MustSet(ctx, config.KeyScopeStrategy, "wildcard")
          conf.MustSet(ctx, config.KeyIssuerURL, "https://foobariss")
      Severity: Major
      Found in oauth2/introspector_test.go - About 3 hrs to fix

        Function TestHelperGrantManagerCreateGetDeleteGrant has 113 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestHelperGrantManagerCreateGetDeleteGrant(t1 GrantManager, km jwk.Manager, parallel bool) func(t *testing.T) {
            tokenServicePubKey1 := jose.JSONWebKey{}
            tokenServicePubKey2 := jose.JSONWebKey{}
            mikePubKey := jose.JSONWebKey{}
        
        
        Severity: Major
        Found in oauth2/trust/manager_test_helpers.go - About 3 hrs to fix

          Config has 29 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type Config struct {
              deps configDependencies
          
              authorizeEndpointHandlers  fosite.AuthorizeEndpointHandlers
              tokenEndpointHandlers      fosite.TokenEndpointHandlers
          Severity: Minor
          Found in fositex/config.go - About 3 hrs to fix

            Method APIClient.prepareRequest has 112 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *APIClient) prepareRequest(
                ctx context.Context,
                path string, method string,
                postBody interface{},
                headerParams map[string]string,
            Severity: Major
            Found in internal/httpclient/client.go - About 3 hrs to fix

              Function TestJWKSDK has 111 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func TestJWKSDK(t *testing.T) {
                  t.Parallel()
                  ctx := context.Background()
                  conf := internal.NewConfigurationWithDefaults()
                  reg := internal.NewRegistryMemory(t, conf, &contextx.Default{})
              Severity: Major
              Found in jwk/sdk_test.go - About 3 hrs to fix

                Method DefaultStrategy.verifyAuthentication has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
                Open

                func (s *DefaultStrategy) verifyAuthentication(
                    ctx context.Context,
                    w http.ResponseWriter,
                    r *http.Request,
                    req fosite.AuthorizeRequester,
                Severity: Minor
                Found in consent/strategy_default.go - About 3 hrs 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 provider.go has 558 lines of code (exceeds 500 allowed). Consider refactoring.
                Open

                // Copyright © 2022 Ory Corp
                // SPDX-License-Identifier: Apache-2.0
                
                package config
                
                
                Severity: Minor
                Found in driver/config/provider.go - About 3 hrs to fix

                  Method DefaultStrategy.issueLogoutVerifier has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (s *DefaultStrategy) issueLogoutVerifier(ctx context.Context, w http.ResponseWriter, r *http.Request) (*flow.LogoutResult, error) {
                      // There are two types of log out flows:
                      //
                      // - RP initiated logout
                      // - OP initiated logout
                  Severity: Minor
                  Found in consent/strategy_default.go - About 3 hrs 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 model_oidc_user_info.go has 548 lines of code (exceeds 500 allowed). Consider refactoring.
                  Open

                  /*
                  Ory Hydra API
                  
                  Documentation for all of Ory Hydra's APIs.
                  
                  
                  Severity: Minor
                  Found in internal/httpclient/model_oidc_user_info.go - About 3 hrs to fix

                    Function TestHelperCreateGetUpdateDeleteClient has 103 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestHelperCreateGetUpdateDeleteClient(k string, connection *pop.Connection, t1 Storage, t2 Storage) func(t *testing.T) {
                        return func(t *testing.T) {
                            ctx := context.Background()
                            _, err := t1.GetClient(ctx, "1234")
                            require.Error(t, err)
                    Severity: Major
                    Found in client/manager_test_helpers.go - About 3 hrs to fix

                      Function TestViperProviderValidates has 103 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func TestViperProviderValidates(t *testing.T) {
                          ctx := context.Background()
                          l := logrusx.New("", "")
                          c := MustNew(context.Background(), l, configx.WithConfigFiles("../../internal/.hydra.yaml"))
                      
                      
                      Severity: Major
                      Found in driver/config/provider_test.go - About 3 hrs to fix

                        File client.go has 546 lines of code (exceeds 500 allowed). Consider refactoring.
                        Open

                        /*
                        Ory Hydra API
                        
                        Documentation for all of Ory Hydra's APIs.
                        
                        
                        Severity: Minor
                        Found in internal/httpclient/client.go - About 3 hrs to fix

                          Function parameterAddToHeaderOrQuery has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
                              var v = reflect.ValueOf(obj)
                              var value = ""
                              if v == reflect.ValueOf(nil) {
                                  value = "null"
                          Severity: Minor
                          Found in internal/httpclient/client.go - About 3 hrs 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 Client.GetEffectiveLifespan has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (c *Client) GetEffectiveLifespan(gt fosite.GrantType, tt fosite.TokenType, fallback time.Duration) time.Duration {
                              var cl *time.Duration
                              if gt == fosite.GrantTypeAuthorizationCode {
                                  if tt == fosite.AccessToken && c.AuthorizationCodeGrantAccessTokenLifespan.Valid {
                                      cl = &c.AuthorizationCodeGrantAccessTokenLifespan.Duration
                          Severity: Minor
                          Found in client/client.go - About 3 hrs 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 TestAEAD has 100 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func TestAEAD(t *testing.T) {
                              t.Parallel()
                              for _, tc := range []struct {
                                  name string
                                  new  func(aead.Dependencies) aead.Cipher
                          Severity: Major
                          Found in aead/aead_test.go - About 3 hrs to fix

                            OAuth2TokenExchange has 26 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            type OAuth2TokenExchange struct {
                                // The access token issued by the authorization server.
                                AccessToken *string `json:"access_token,omitempty"`
                                // The lifetime in seconds of the access token. For example, the value \"3600\" denotes that the access token will expire in one hour from the time the response was generated.
                                ExpiresIn *int64 `json:"expires_in,omitempty"`
                            Severity: Minor
                            Found in internal/httpclient/model_o_auth2_token_exchange.go - About 3 hrs to fix

                              OAuth2LogoutRequest has 26 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                              type OAuth2LogoutRequest struct {
                                  // Challenge is the identifier (\"logout challenge\") of the logout authentication request. It is used to identify the session.
                                  Challenge *string       `json:"challenge,omitempty"`
                                  Client    *OAuth2Client `json:"client,omitempty"`
                                  // RequestURL is the original Logout URL requested.
                              Severity: Minor
                              Found in internal/httpclient/model_o_auth2_logout_request.go - About 3 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language