ory-am/hydra

View on GitHub

Showing 853 of 853 total issues

Method DefaultStrategy.executeBackChannelLogout has 7 return statements (exceeds 4 allowed).
Open

func (s *DefaultStrategy) executeBackChannelLogout(r *http.Request, subject, sid string) error {
    ctx := r.Context()
    clients, err := s.r.ConsentManager().ListUserAuthenticatedClientsWithBackChannelLogout(ctx, subject, sid)
    if err != nil {
        return err
Severity: Major
Found in consent/strategy_default.go - About 45 mins to fix

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

    func (h *Handler) rejectOAuth2ConsentRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
        ctx := r.Context()
    
        challenge := stringsx.Coalesce(
            r.URL.Query().Get("consent_challenge"),
    Severity: Major
    Found in consent/handler.go - About 45 mins to fix

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

      func NewRegistryFromDSN(ctx context.Context, c *config.DefaultProvider, l *logrusx.Logger, skipNetworkInit bool, migrate bool, ctxer contextx.Contextualizer) (Registry, error) {
      Severity: Minor
      Found in driver/registry.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

          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

            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

              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

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

                func New(ctx context.Context, sl *servicelocatorx.Options, opts []OptionsModifier) (Registry, error) {
                    o := NewOptions(opts)
                
                    l := sl.Logger()
                    if l == nil {
                Severity: Major
                Found in driver/factory.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

                      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

                        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

                          Avoid deeply nested control flow statements.
                          Open

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

                            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

                              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 Persister.migrateOldMigrationTables has 7 return statements (exceeds 4 allowed).
                                Open

                                func (p *Persister) migrateOldMigrationTables() error {
                                    if err := p.conn.RawQuery(fmt.Sprintf("SELECT * FROM %s", clientMigrationTableName)).Exec(); err != nil {
                                        // assume there are no old migration tables => done
                                        return nil
                                    }
                                Severity: Major
                                Found in persistence/sql/persister_migration.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

                                                                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

                                      Similar blocks of code found in 17 locations. Consider refactoring.
                                      Open

                                      func (mr *MockManagerMockRecorder) AddKey(ctx, set, key interface{}) *gomock.Call {
                                          mr.mock.ctrl.T.Helper()
                                          return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddKey", reflect.TypeOf((*MockManager)(nil).AddKey), ctx, set, key)
                                      }
                                      Severity: Major
                                      Found in jwk/manager_mock_test.go and 16 other locations - About 45 mins to fix
                                      hsm/crypto11_mock_test.go on lines 54..57
                                      hsm/crypto11_mock_test.go on lines 97..100
                                      hsm/hsm_mock_test.go on lines 84..87
                                      hsm/hsm_mock_test.go on lines 99..102
                                      jwk/manager_mock_test.go on lines 64..67
                                      jwk/manager_mock_test.go on lines 78..81
                                      jwk/manager_mock_test.go on lines 122..125
                                      jwk/manager_mock_test.go on lines 151..154
                                      jwk/manager_mock_test.go on lines 165..168
                                      oauth2/oauth2_provider_mock_test.go on lines 74..77
                                      oauth2/oauth2_provider_mock_test.go on lines 119..122
                                      oauth2/oauth2_provider_mock_test.go on lines 134..137
                                      oauth2/oauth2_provider_mock_test.go on lines 164..167
                                      oauth2/oauth2_provider_mock_test.go on lines 238..241
                                      oauth2/oauth2_provider_mock_test.go on lines 250..253
                                      oauth2/oauth2_provider_mock_test.go on lines 286..289

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 115.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 17 locations. Consider refactoring.
                                      Open

                                      func (mr *MockManagerMockRecorder) UpdateKeySet(ctx, set, keys interface{}) *gomock.Call {
                                          mr.mock.ctrl.T.Helper()
                                          return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateKeySet", reflect.TypeOf((*MockManager)(nil).UpdateKeySet), ctx, set, keys)
                                      }
                                      Severity: Major
                                      Found in jwk/manager_mock_test.go and 16 other locations - About 45 mins to fix
                                      hsm/crypto11_mock_test.go on lines 54..57
                                      hsm/crypto11_mock_test.go on lines 97..100
                                      hsm/hsm_mock_test.go on lines 84..87
                                      hsm/hsm_mock_test.go on lines 99..102
                                      jwk/manager_mock_test.go on lines 50..53
                                      jwk/manager_mock_test.go on lines 64..67
                                      jwk/manager_mock_test.go on lines 78..81
                                      jwk/manager_mock_test.go on lines 122..125
                                      jwk/manager_mock_test.go on lines 151..154
                                      oauth2/oauth2_provider_mock_test.go on lines 74..77
                                      oauth2/oauth2_provider_mock_test.go on lines 119..122
                                      oauth2/oauth2_provider_mock_test.go on lines 134..137
                                      oauth2/oauth2_provider_mock_test.go on lines 164..167
                                      oauth2/oauth2_provider_mock_test.go on lines 238..241
                                      oauth2/oauth2_provider_mock_test.go on lines 250..253
                                      oauth2/oauth2_provider_mock_test.go on lines 286..289

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 115.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language