ory-am/hydra

View on GitHub

Showing 412 of 865 total issues

Method OidcConfiguration.ToMap has 77 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (o OidcConfiguration) ToMap() (map[string]interface{}, error) {
    toSerialize := map[string]interface{}{}
    toSerialize["authorization_endpoint"] = o.AuthorizationEndpoint
    if !IsNil(o.BackchannelLogoutSessionSupported) {
        toSerialize["backchannel_logout_session_supported"] = o.BackchannelLogoutSessionSupported
Severity: Major
Found in internal/httpclient/model_oidc_configuration.go - About 2 hrs to fix

    Function parameterAddToHeaderOrQuery has 77 lines of code (exceeds 50 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: Major
    Found in internal/httpclient/client.go - About 2 hrs to fix

      Function TestKeyManager_DeleteKey has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

        Function TestKeyManager_HsmKeySetPrefix has 77 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          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 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 router.consentGET has 69 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func (rt *router) consentGET(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
                                        req, raw, err := rt.cl.OAuth2API.GetOAuth2ConsentRequest(r.Context()).
                                            ConsentChallenge(r.URL.Query().Get("consent_challenge")).
                                            Execute()
                                        if err != nil {
                                    Severity: Minor
                                    Found in cmd/cmd_perform_authorization_code.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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language