ory-am/hydra

View on GitHub

Showing 402 of 849 total issues

File strategy_logout_test.go has 502 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Copyright © 2022 Ory Corp
// SPDX-License-Identifier: Apache-2.0

package consent_test

Severity: Minor
Found in consent/strategy_logout_test.go - About 2 hrs to fix

    Function TestGetConsentRequest has 75 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestGetConsentRequest(t *testing.T) {
        for k, tc := range []struct {
            exists  bool
            handled bool
            status  int
    Severity: Minor
    Found in consent/handler_test.go - About 2 hrs to fix

      Method DefaultStrategy.verifyAuthentication has 22 return statements (exceeds 4 allowed).
      Open

      func (s *DefaultStrategy) verifyAuthentication(
          ctx context.Context,
          w http.ResponseWriter,
          r *http.Request,
          req fosite.AuthorizeRequester,
      Severity: Major
      Found in consent/strategy_default.go - About 2 hrs to fix

        Method OidcApiService.CreateVerifiableCredentialExecute has 74 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (a *OidcApiService) CreateVerifiableCredentialExecute(r ApiCreateVerifiableCredentialRequest) (*VerifiableCredentialResponse, *http.Response, error) {
            var (
                localVarHTTPMethod  = http.MethodPost
                localVarPostBody    interface{}
                formFiles           []formFile
        Severity: Minor
        Found in internal/httpclient/api_oidc.go - About 1 hr to fix

          Method RegistrySQL.Init has 74 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (m *RegistrySQL) Init(
              ctx context.Context,
              skipNetworkInit bool,
              migrate bool,
              ctxer contextx.Contextualizer,
          Severity: Minor
          Found in driver/registry_sql.go - About 1 hr to fix

            Function TestKeyManager_DeleteKeySet has 74 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestKeyManager_DeleteKeySet(t *testing.T) {
                ctrl := gomock.NewController(t)
                hsmContext := NewMockContext(ctrl)
                defer ctrl.Finish()
                l := logrusx.New("", "")
            Severity: Minor
            Found in hsm/manager_hsm_test.go - About 1 hr to fix

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

              func (h *Handler) oauth2TokenExchange(w http.ResponseWriter, r *http.Request) {
                  ctx := r.Context()
                  session := NewSessionWithCustomClaims(ctx, h.c, "")
              
                  accessRequest, err := h.r.OAuth2Provider().NewAccessRequest(ctx, r, session)
              Severity: Minor
              Found in oauth2/handler.go - About 1 hr 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 JanitorTests has 72 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func JanitorTests(
                  reg interface {
                      ConsentManager() consent.Manager
                      OAuth2Storage() x.FositeStorer
                      config.Provider
              Severity: Minor
              Found in internal/testhelpers/janitor_test_helper.go - About 1 hr to fix

                Function TestRevoke has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func TestRevoke(t *testing.T) {
                    conf := internal.NewConfigurationWithDefaults()
                    reg := internal.NewRegistryMemory(t, conf, &contextx.Default{})
                
                    internal.MustEnsureRegistryKeys(context.Background(), reg, x.OpenIDConnectKeyName)
                Severity: Minor
                Found in oauth2/revocator_test.go - About 1 hr to fix

                  Method OAuth2ApiService.ListTrustedOAuth2JwtGrantIssuersExecute has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (a *OAuth2ApiService) ListTrustedOAuth2JwtGrantIssuersExecute(r ApiListTrustedOAuth2JwtGrantIssuersRequest) ([]TrustedOAuth2JwtGrantIssuer, *http.Response, error) {
                      var (
                          localVarHTTPMethod  = http.MethodGet
                          localVarPostBody    interface{}
                          formFiles           []formFile
                  Severity: Minor
                  Found in internal/httpclient/api_o_auth2.go - About 1 hr to fix

                    Method PersisterTestSuite.TestListUserAuthenticatedClientsWithBackChannelLogout has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (s *PersisterTestSuite) TestListUserAuthenticatedClientsWithBackChannelLogout() {
                        t := s.T()
                        for k, r := range s.registries {
                            t.Run(k, func(t *testing.T) {
                                c1 := &client.Client{ID: "client-1", BackChannelLogoutURI: "not-null"}
                    Severity: Minor
                    Found in persistence/sql/persister_nid_test.go - About 1 hr to fix

                      Method PersisterTestSuite.TestListUserAuthenticatedClientsWithFrontChannelLogout has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (s *PersisterTestSuite) TestListUserAuthenticatedClientsWithFrontChannelLogout() {
                          t := s.T()
                          for k, r := range s.registries {
                              t.Run(k, func(t *testing.T) {
                                  c1 := &client.Client{ID: "client-1", FrontChannelLogoutURI: "not-null"}
                      Severity: Minor
                      Found in persistence/sql/persister_nid_test.go - About 1 hr to fix

                        Method DefaultStrategy.issueLogoutVerifier has 20 return statements (exceeds 4 allowed).
                        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: Major
                        Found in consent/strategy_default.go - About 1 hr to fix

                          Method OAuth2ApiService.IntrospectOAuth2TokenExecute has 69 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (a *OAuth2ApiService) IntrospectOAuth2TokenExecute(r ApiIntrospectOAuth2TokenRequest) (*IntrospectedOAuth2Token, *http.Response, error) {
                              var (
                                  localVarHTTPMethod  = http.MethodPost
                                  localVarPostBody    interface{}
                                  formFiles           []formFile
                          Severity: Minor
                          Found in internal/httpclient/api_o_auth2.go - About 1 hr to fix

                            Method Handler.acceptOAuth2LoginRequest has 69 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (h *Handler) acceptOAuth2LoginRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
                                ctx := r.Context()
                            
                                challenge := stringsx.Coalesce(
                                    r.URL.Query().Get("login_challenge"),
                            Severity: Minor
                            Found in consent/handler.go - About 1 hr to fix

                              Method Validator.Validate has 19 return statements (exceeds 4 allowed).
                              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 1 hr to fix

                                Function MockConsentRequest has 68 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func MockConsentRequest(key string, remember bool, rememberFor int, hasError bool, skip bool, authAt bool, loginChallengeBase string, network string) (c *flow.OAuth2ConsentRequest, h *flow.AcceptOAuth2ConsentRequest, f *flow.Flow) {
                                    c = &flow.OAuth2ConsentRequest{
                                        ID:                makeID("challenge", network, key),
                                        RequestedScope:    []string{"scopea" + key, "scopeb" + key},
                                        RequestedAudience: []string{"auda" + key, "audb" + key},
                                Severity: Minor
                                Found in consent/test/manager_test_helpers.go - About 1 hr to fix

                                  Method Handler.getOidcUserInfo has 68 lines of code (exceeds 50 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 1 hr to fix

                                    Method OAuth2ApiService.AcceptOAuth2LoginRequestExecute has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func (a *OAuth2ApiService) AcceptOAuth2LoginRequestExecute(r ApiAcceptOAuth2LoginRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
                                        var (
                                            localVarHTTPMethod  = http.MethodPut
                                            localVarPostBody    interface{}
                                            formFiles           []formFile
                                    Severity: Minor
                                    Found in internal/httpclient/api_o_auth2.go - About 1 hr to fix

                                      Method OAuth2ApiService.RejectOAuth2ConsentRequestExecute has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                                      Open

                                      func (a *OAuth2ApiService) RejectOAuth2ConsentRequestExecute(r ApiRejectOAuth2ConsentRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
                                          var (
                                              localVarHTTPMethod  = http.MethodPut
                                              localVarPostBody    interface{}
                                              formFiles           []formFile
                                      Severity: Minor
                                      Found in internal/httpclient/api_o_auth2.go - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language