ory-am/hydra

View on GitHub

Showing 853 of 853 total issues

Function TestGetLoginRequest has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    Function TestGetOrCreateTLSCertificate has 57 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestGetOrCreateTLSCertificate(t *testing.T) {
        certPath, keyPath, cert, priv := testhelpers.GenerateTLSCertificateFilesForTests(t)
        logger := logrusx.New("", "")
        logger.Logger.ExitFunc = func(code int) { t.Fatalf("Logger called os.Exit(%v)", code) }
        hook := test.NewLocal(logger.Logger)
    Severity: Minor
    Found in cmd/server/helper_cert_test.go - About 1 hr to fix

      Function TestImportClient has 57 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestImportClient(t *testing.T) {
          ctx := context.Background()
          c := cmd.NewImportClientCmd()
          reg := setup(t, c)
      
      
      Severity: Minor
      Found in cmd/cmd_import_client_test.go - About 1 hr to fix

        Function RegisterCommandRecursive has 57 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func RegisterCommandRecursive(parent *cobra.Command, slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) {
            createCmd := NewCreateCmd()
            createCmd.AddCommand(
                NewCreateClientsCommand(),
                NewCreateJWKSCmd(),
        Severity: Minor
        Found in cmd/root.go - About 1 hr to fix

          Function TestUnmarshalSession has 57 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func TestUnmarshalSession(t *testing.T) {
              expect := &Session{
                  DefaultSession: &openid.DefaultSession{
                      Claims: &jwt.IDTokenClaims{
                          JTI:                                 "",
          Severity: Minor
          Found in oauth2/session_test.go - About 1 hr to fix

            Function TestHelperManagerKey has 57 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestHelperManagerKey(m Manager, algo string, keys *jose.JSONWebKeySet, suffix string) func(t *testing.T) {
                priv := canonicalizeThumbprints(keys.Key(suffix))
                var pub []jose.JSONWebKey
                for _, k := range priv {
                    pub = append(pub, canonicalizeThumbprints([]jose.JSONWebKey{k.Public()})...)
            Severity: Minor
            Found in jwk/manager_test_helpers.go - About 1 hr to fix

              Function executeHookAndUpdateSession has 57 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func executeHookAndUpdateSession(ctx context.Context, reg x.HTTPClientProvider, hookConfig *config.HookConfig, reqBodyBytes []byte, session *Session) error {
                  req, err := retryablehttp.NewRequestWithContext(ctx, http.MethodPost, hookConfig.URL, bytes.NewReader(reqBodyBytes))
                  if err != nil {
                      return errorsx.WithStack(
                          fosite.ErrServerError.
              Severity: Minor
              Found in oauth2/token_hook.go - About 1 hr to fix

                Function TestPublicHealthHandler has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func TestPublicHealthHandler(t *testing.T) {
                    ctx := context.Background()
                
                    doCORSRequest := func(t *testing.T, endpoint string) *http.Response {
                        req, err := http.NewRequest(http.MethodGet, endpoint, nil)
                Severity: Minor
                Found in health/handler_test.go - About 1 hr to fix

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

                                  token, _, err := signer.Generate(ctx, jwt.MapClaims{
                                      "jti": uuid.NewString(),
                                      "iss": trustGrant.Issuer,
                                      "sub": trustGrant.Subject,
                                      "aud": audience,
                  Severity: Major
                  Found in oauth2/oauth2_jwt_bearer_test.go and 1 other location - About 1 hr to fix
                  oauth2/oauth2_jwt_bearer_test.go on lines 314..321

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

                  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

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

                                  token, _, err := signer.Generate(ctx, jwt.MapClaims{
                                      "jti": uuid.NewString(),
                                      "iss": trustGrant.Issuer,
                                      "sub": trustGrant.Subject,
                                      "aud": audience,
                  Severity: Major
                  Found in oauth2/oauth2_jwt_bearer_test.go and 1 other location - About 1 hr to fix
                  oauth2/oauth2_jwt_bearer_test.go on lines 385..392

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

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

                  func TestLogoutFlows(t *testing.T) {
                      ctx := context.Background()
                      fakeKratos := kratos.NewFake()
                      reg := internal.NewMockedRegistry(t, &contextx.Default{})
                      reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
                  Severity: Major
                  Found in consent/strategy_logout_test.go - About 1 hr to fix

                    Function TestStrategyLoginConsentNext has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func TestStrategyLoginConsentNext(t *testing.T) {
                        ctx := context.Background()
                        reg := internal.NewMockedRegistry(t, &contextx.Default{})
                        reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
                        reg.Config().MustSet(ctx, config.KeyConsentRequestMaxAge, time.Hour)
                    Severity: Minor
                    Found in consent/strategy_oauth_test.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

                    Method OAuth2APIService.SetOAuth2ClientExecute has 13 return statements (exceeds 4 allowed).
                    Open

                    func (a *OAuth2APIService) SetOAuth2ClientExecute(r ApiSetOAuth2ClientRequest) (*OAuth2Client, *http.Response, error) {
                        var (
                            localVarHTTPMethod  = http.MethodPut
                            localVarPostBody    interface{}
                            formFiles           []formFile
                    Severity: Major
                    Found in internal/httpclient/api_o_auth2.go - About 1 hr to fix

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

                          var newClient = func(t *testing.T) (*hc.Client, clientcredentials.Config) {
                              cc, config := newCustomClient(t, &hc.Client{
                                  Secret:        uuid.New().String(),
                                  RedirectURIs:  []string{public.URL + "/callback"},
                                  ResponseTypes: []string{"token"},
                      Severity: Major
                      Found in oauth2/oauth2_client_credentials_test.go and 1 other location - About 1 hr to fix
                      oauth2/oauth2_client_credentials_bench_test.go on lines 55..65

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

                      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 (r *OAuth2ConsentSession) MarshalJSON() ([]byte, error) {
                          type Alias OAuth2ConsentSession
                          alias := Alias(*r)
                      
                          if alias.Context == nil {
                      Severity: Major
                      Found in flow/consent_types.go and 1 other location - About 1 hr to fix
                      flow/consent_types.go on lines 191..208

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

                      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

                          var newClient = func(b *testing.B) (*hc.Client, clientcredentials.Config) {
                              cc, config := newCustomClient(b, &hc.Client{
                                  Secret:        uuid.New().String(),
                                  RedirectURIs:  []string{public.URL + "/callback"},
                                  ResponseTypes: []string{"token"},
                      Severity: Major
                      Found in oauth2/oauth2_client_credentials_bench_test.go and 1 other location - About 1 hr to fix
                      oauth2/oauth2_client_credentials_test.go on lines 54..64

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

                      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 (r *AcceptOAuth2ConsentRequest) MarshalJSON() ([]byte, error) {
                          type Alias AcceptOAuth2ConsentRequest
                          alias := Alias(*r)
                      
                          if alias.Context == nil {
                      Severity: Major
                      Found in flow/consent_types.go and 1 other location - About 1 hr to fix
                      flow/consent_types.go on lines 285..302

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

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

                      func getGrantRequests(uniqueName string, lifespan time.Duration) []*createGrantRequest {
                          return []*createGrantRequest{
                              {
                                  grant: trust.Grant{
                                      ID:      uuid.New().String(),
                      Severity: Minor
                      Found in internal/testhelpers/janitor_test_helper.go - About 1 hr to fix

                        Identical blocks of code found in 4 locations. Consider refactoring.
                        Open

                                    grant := trust.Grant{
                                        ID:              uuid.New(),
                                        Issuer:          issuer,
                                        Subject:         subject,
                                        AllowAnySubject: false,
                        Severity: Major
                        Found in oauth2/fosite_store_helpers.go and 3 other locations - About 1 hr to fix
                        oauth2/fosite_store_helpers.go on lines 1003..1012
                        oauth2/fosite_store_helpers.go on lines 1040..1049
                        oauth2/fosite_store_helpers.go on lines 1077..1086

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

                        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

                        Identical blocks of code found in 4 locations. Consider refactoring.
                        Open

                                    grant := trust.Grant{
                                        ID:              uuid.New(),
                                        Issuer:          issuer,
                                        Subject:         subject,
                                        AllowAnySubject: false,
                        Severity: Major
                        Found in oauth2/fosite_store_helpers.go and 3 other locations - About 1 hr to fix
                        oauth2/fosite_store_helpers.go on lines 894..903
                        oauth2/fosite_store_helpers.go on lines 1040..1049
                        oauth2/fosite_store_helpers.go on lines 1077..1086

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

                        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