ory-am/hydra

View on GitHub

Showing 849 of 849 total issues

Function TestKeyManagerStrategy has 164 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestKeyManagerStrategy(t *testing.T) {
    t.Parallel()
    ctrl := gomock.NewController(t)
    softwareKeyManager := NewMockManager(ctrl)
    hardwareKeyManager := NewMockManager(ctrl)
Severity: Major
Found in jwk/manager_strategy_test.go - About 5 hrs to fix

    File persister_consent.go has 646 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    // Copyright © 2022 Ory Corp
    // SPDX-License-Identifier: Apache-2.0
    
    package sql
    
    
    Severity: Minor
    Found in persistence/sql/persister_consent.go - About 5 hrs to fix

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

      func (s *PersisterTestSuite) TestGetRefreshTokenSession() {
          t := s.T()
          for k, r := range s.registries {
              t.Run(k, func(t *testing.T) {
                  client := &client.Client{ID: "client-id"}
      Severity: Major
      Found in persistence/sql/persister_nid_test.go and 2 other locations - About 5 hrs to fix
      persistence/sql/persister_nid_test.go on lines 1261..1283
      persistence/sql/persister_nid_test.go on lines 1285..1307

      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 394.

      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 3 locations. Consider refactoring.
      Open

      func (s *PersisterTestSuite) TestGetPKCERequestSession() {
          t := s.T()
          for k, r := range s.registries {
              t.Run(k, func(t *testing.T) {
                  client := &client.Client{ID: "client-id"}
      Severity: Major
      Found in persistence/sql/persister_nid_test.go and 2 other locations - About 5 hrs to fix
      persistence/sql/persister_nid_test.go on lines 1261..1283
      persistence/sql/persister_nid_test.go on lines 1382..1404

      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 394.

      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 3 locations. Consider refactoring.
      Open

      func (s *PersisterTestSuite) TestGetOpenIDConnectSession() {
          t := s.T()
          for k, r := range s.registries {
              t.Run(k, func(t *testing.T) {
                  client := &client.Client{ID: "client-id"}
      Severity: Major
      Found in persistence/sql/persister_nid_test.go and 2 other locations - About 5 hrs to fix
      persistence/sql/persister_nid_test.go on lines 1285..1307
      persistence/sql/persister_nid_test.go on lines 1382..1404

      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 394.

      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 2 locations. Consider refactoring.
      Open

          t.Run("case=should be able to retry accept login request", func(t *testing.T) {
              subject := "aeneas-rekkas"
              c := createDefaultClient(t)
              testhelpers.NewLoginConsentUI(t, reg.Config(),
                  checkAndDuplicateAcceptLoginHandler(t, adminClient, subject, func(*testing.T, *hydra.OAuth2LoginRequest, error) hydra.AcceptOAuth2LoginRequest {
      Severity: Major
      Found in consent/strategy_oauth_test.go and 1 other location - About 5 hrs to fix
      consent/strategy_oauth_test.go on lines 1067..1093

      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 389.

      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 2 locations. Consider refactoring.
      Open

          t.Run("case=should be able to retry both accept login and consent requests", func(t *testing.T) {
              subject := "aeneas-rekkas"
              c := createDefaultClient(t)
              testhelpers.NewLoginConsentUI(t, reg.Config(),
                  checkAndDuplicateAcceptLoginHandler(t, adminClient, subject, func(*testing.T, *hydra.OAuth2LoginRequest, error) hydra.AcceptOAuth2LoginRequest {
      Severity: Major
      Found in consent/strategy_oauth_test.go and 1 other location - About 5 hrs to fix
      consent/strategy_oauth_test.go on lines 1039..1065

      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 389.

      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 2 locations. Consider refactoring.
      Open

      func (s *PersisterTestSuite) TestCreateRefreshTokenSession() {
          t := s.T()
          for k, r := range s.registries {
              t.Run(k, func(t *testing.T) {
                  client := &client.Client{ID: "client-id"}
      Severity: Major
      Found in persistence/sql/persister_nid_test.go and 1 other location - About 5 hrs to fix
      persistence/sql/persister_nid_test.go on lines 500..520

      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 378.

      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 2 locations. Consider refactoring.
      Open

      func (s *PersisterTestSuite) TestCreatePKCERequestSession() {
          t := s.T()
          for k, r := range s.registries {
              t.Run(k, func(t *testing.T) {
                  client := &client.Client{ID: "client-id"}
      Severity: Major
      Found in persistence/sql/persister_nid_test.go and 1 other location - About 5 hrs to fix
      persistence/sql/persister_nid_test.go on lines 522..541

      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 378.

      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 2 locations. Consider refactoring.
      Open

      func (s *PersisterTestSuite) TestGetAuthorizeCodeSession() {
          t := s.T()
          for k, r := range s.registries {
              t.Run(k, func(t *testing.T) {
                  client := &client.Client{ID: "client-id"}
      Severity: Major
      Found in persistence/sql/persister_nid_test.go and 1 other location - About 5 hrs to fix
      persistence/sql/persister_nid_test.go on lines 948..968

      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 374.

      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 2 locations. Consider refactoring.
      Open

      func (s *PersisterTestSuite) TestGetAccessTokenSession() {
          t := s.T()
          for k, r := range s.registries {
              t.Run(k, func(t *testing.T) {
                  client := &client.Client{ID: "client-id"}
      Severity: Major
      Found in persistence/sql/persister_nid_test.go and 1 other location - About 5 hrs to fix
      persistence/sql/persister_nid_test.go on lines 970..990

      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 374.

      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 2 locations. Consider refactoring.
      Open

      func RunServePublic(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) func(cmd *cobra.Command, args []string) error {
          return func(cmd *cobra.Command, args []string) error {
              ctx := cmd.Context()
              sl := servicelocatorx.NewOptions(slOpts...)
      
      
      Severity: Major
      Found in cmd/server/handler.go and 1 other location - About 5 hrs to fix
      cmd/server/handler.go on lines 80..111

      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 373.

      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 2 locations. Consider refactoring.
      Open

      func RunServeAdmin(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) func(cmd *cobra.Command, args []string) error {
          return func(cmd *cobra.Command, args []string) error {
              ctx := cmd.Context()
              sl := servicelocatorx.NewOptions(slOpts...)
      
      
      Severity: Major
      Found in cmd/server/handler.go and 1 other location - About 5 hrs to fix
      cmd/server/handler.go on lines 113..144

      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 373.

      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

      Function TestCustomClaimsInSession has 151 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestCustomClaimsInSession(t *testing.T) {
          ctx := context.Background()
          c := internal.NewConfigurationWithDefaults()
      
          t.Run("no_custom_claims", func(t *testing.T) {
      Severity: Major
      Found in oauth2/session_custom_claims_test.go - About 5 hrs to fix

        OAuth2ConsentSession has 38 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type OAuth2ConsentSession struct {
            ConsentRequest           *OAuth2ConsentRequest          `json:"consent_request,omitempty"`
            Context                  interface{}                    `json:"context,omitempty"`
            ExpiresAt                *OAuth2ConsentSessionExpiresAt `json:"expires_at,omitempty"`
            GrantAccessTokenAudience []string                       `json:"grant_access_token_audience,omitempty"`
        Severity: Minor
        Found in internal/httpclient/model_o_auth2_consent_session.go - About 5 hrs to fix

          AcceptOAuth2LoginRequest has 38 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type AcceptOAuth2LoginRequest struct {
              // ACR sets the Authentication AuthorizationContext Class Reference value for this authentication session. You can use it to express that, for example, a user authenticated using two factor authentication.
              Acr     *string     `json:"acr,omitempty"`
              Amr     []string    `json:"amr,omitempty"`
              Context interface{} `json:"context,omitempty"`
          Severity: Minor
          Found in internal/httpclient/model_accept_o_auth2_login_request.go - About 5 hrs to fix

            Function TestCreateRefreshTokenSessionStress has 150 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestCreateRefreshTokenSessionStress(t *testing.T) {
                if testing.Short() {
                    return
                }
            
            
            Severity: Major
            Found in oauth2/oauth2_refresh_token_test.go - About 5 hrs to fix

              Function TestHandler has a Cognitive Complexity of 48 (exceeds 20 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: Minor
              Found in client/handler_test.go - About 4 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 OAuth2Client.ToMap has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
              Open

              func (o OAuth2Client) ToMap() (map[string]interface{}, error) {
                  toSerialize := map[string]interface{}{}
                  if !IsNil(o.AccessTokenStrategy) {
                      toSerialize["access_token_strategy"] = o.AccessTokenStrategy
                  }
              Severity: Minor
              Found in internal/httpclient/model_o_auth2_client.go - About 4 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

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

                      t.Run("case=flush-consent-request-rejection", func(t *testing.T) {
                          jt := NewConsentJanitorTestHelper(network + "loginRejection")
              
                          t.Run(fmt.Sprintf("case=%s", "loginRejection"), func(t *testing.T) {
                              // setup
              Severity: Major
              Found in internal/testhelpers/janitor_test_helper.go and 1 other location - About 4 hrs to fix
              internal/testhelpers/janitor_test_helper.go on lines 642..676

              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 365.

              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