ory-am/hydra

View on GitHub

Showing 853 of 853 total issues

File grant_jwtbearer.js has 500 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

import {
  createClient,
Severity: Minor
Found in cypress/integration/oauth2/grant_jwtbearer.js - About 1 day to fix

    Method APIClient.prepareRequest has a Cognitive Complexity of 66 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *APIClient) prepareRequest(
        ctx context.Context,
        path string, method string,
        postBody interface{},
        headerParams map[string]string,
    Severity: Minor
    Found in internal/httpclient/client.go - About 7 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 3 locations. Consider refactoring.
    Open

        t.Run("case=fail token exchange if hook denies the request", func(t *testing.T) {
            run := func(strategy string) func(t *testing.T) {
                return func(t *testing.T) {
                    hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                        w.WriteHeader(http.StatusForbidden)
    Severity: Major
    Found in oauth2/oauth2_auth_code_test.go and 2 other locations - About 7 hrs to fix
    oauth2/oauth2_auth_code_test.go on lines 1056..1094
    oauth2/oauth2_auth_code_test.go on lines 1136..1174

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

    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

        t.Run("case=fail token exchange if hook response is malformed", func(t *testing.T) {
            run := func(strategy string) func(t *testing.T) {
                return func(t *testing.T) {
                    hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                        w.WriteHeader(http.StatusOK)
    Severity: Major
    Found in oauth2/oauth2_auth_code_test.go and 2 other locations - About 7 hrs to fix
    oauth2/oauth2_auth_code_test.go on lines 1056..1094
    oauth2/oauth2_auth_code_test.go on lines 1096..1134

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

    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

        t.Run("case=fail token exchange if hook fails", func(t *testing.T) {
            run := func(strategy string) func(t *testing.T) {
                return func(t *testing.T) {
                    hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                        w.WriteHeader(http.StatusInternalServerError)
    Severity: Major
    Found in oauth2/oauth2_auth_code_test.go and 2 other locations - About 7 hrs to fix
    oauth2/oauth2_auth_code_test.go on lines 1096..1134
    oauth2/oauth2_auth_code_test.go on lines 1136..1174

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

    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

    OAuth2ConsentRequest has 54 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type OAuth2ConsentRequest struct {
        // ACR represents 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"`
        // ID is the identifier (\"authorization challenge\") of the consent authorization request. It is used to identify the session.
    Severity: Major
    Found in internal/httpclient/model_o_auth2_consent_request.go - About 7 hrs to fix

      File janitor_test_helper.go has 734 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      // Copyright © 2022 Ory Corp
      // SPDX-License-Identifier: Apache-2.0
      
      package testhelpers
      
      
      Severity: Minor
      Found in internal/testhelpers/janitor_test_helper.go - About 7 hrs to fix

        Function TestCreateRefreshTokenSessionStress has a Cognitive Complexity of 64 (exceeds 20 allowed). Consider refactoring.
        Open

        func TestCreateRefreshTokenSessionStress(t *testing.T) {
            if testing.Short() {
                return
            }
        
        
        Severity: Minor
        Found in oauth2/oauth2_refresh_token_test.go - About 7 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 3 locations. Consider refactoring.
        Open

            t.Run("should fail token if hook denied the request", func(t *testing.T) {
                run := func(strategy string) func(t *testing.T) {
                    return func(t *testing.T) {
                        hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                            w.WriteHeader(http.StatusForbidden)
        Severity: Major
        Found in oauth2/oauth2_jwt_bearer_test.go and 2 other locations - About 7 hrs to fix
        oauth2/oauth2_jwt_bearer_test.go on lines 460..493
        oauth2/oauth2_jwt_bearer_test.go on lines 530..563

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

        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

            t.Run("should fail token if hook fails", func(t *testing.T) {
                run := func(strategy string) func(t *testing.T) {
                    return func(t *testing.T) {
                        hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                            w.WriteHeader(http.StatusInternalServerError)
        Severity: Major
        Found in oauth2/oauth2_jwt_bearer_test.go and 2 other locations - About 7 hrs to fix
        oauth2/oauth2_jwt_bearer_test.go on lines 495..528
        oauth2/oauth2_jwt_bearer_test.go on lines 530..563

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

        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

            t.Run("should fail token if hook response is malformed", func(t *testing.T) {
                run := func(strategy string) func(t *testing.T) {
                    return func(t *testing.T) {
                        hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                            w.WriteHeader(http.StatusOK)
        Severity: Major
        Found in oauth2/oauth2_jwt_bearer_test.go and 2 other locations - About 7 hrs to fix
        oauth2/oauth2_jwt_bearer_test.go on lines 460..493
        oauth2/oauth2_jwt_bearer_test.go on lines 495..528

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

        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

                  cy.get("body")
                    .invoke("text")
                    .then((content) => {
                      const {
                        result,
        Severity: Major
        Found in cypress/integration/oauth2/authorize_error.js and 1 other location - About 7 hrs to fix
        cypress/integration/oauth2/authorize_error.js on lines 31..47

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

        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

                  cy.get("body")
                    .invoke("text")
                    .then((content) => {
                      const {
                        result,
        Severity: Major
        Found in cypress/integration/oauth2/authorize_error.js and 1 other location - About 7 hrs to fix
        cypress/integration/oauth2/authorize_error.js on lines 57..73

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

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

        func NewPerformAuthorizationCodeCmd() *cobra.Command {
            cmd := &cobra.Command{
                Use:     "authorization-code",
                Example: "{{ .CommandPath }} --client-id ... --client-secret ...",
                Short:   "An exemplary OAuth 2.0 Client performing the OAuth 2.0 Authorize Code Flow",
        Severity: Major
        Found in cmd/cmd_perform_authorization_code.go - About 7 hrs to fix

          Function TestMigrations has 202 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func TestMigrations(t *testing.T) {
              connections := make(map[string]*pop.Connection, 1)
          
              if testing.Short() {
                  reg := internal.NewMockedRegistry(t, &contextx.Default{})
          Severity: Major
          Found in persistence/sql/migratest/migration_test.go - About 7 hrs to fix

            Function BenchmarkAuthCode has 200 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func BenchmarkAuthCode(b *testing.B) {
                flag.Parse()
            
                ctx := context.Background()
            
            
            Severity: Major
            Found in oauth2/oauth2_auth_code_bench_test.go - About 7 hrs to fix

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

                    it("should require login with prompt=login even when session exists", function () {
                      createClient(nc()).then((client) => {
                        cy.authCodeFlow(
                          client,
                          {
              Severity: Major
              Found in cypress/integration/openid/prompt.js and 1 other location - About 6 hrs to fix
              cypress/integration/openid/prompt.js on lines 96..125

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

              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

                    it("should require consent with prompt=consent even when session exists", function () {
                      createClient(nc()).then((client) => {
                        cy.authCodeFlow(
                          client,
                          {
              Severity: Major
              Found in cypress/integration/openid/prompt.js and 1 other location - About 6 hrs to fix
              cypress/integration/openid/prompt.js on lines 69..94

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

              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) TestRevokeAccessToken() {
                  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 6 hrs to fix
              persistence/sql/persister_nid_test.go on lines 584..605

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

              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) TestDeleteAccessTokens() {
                  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 6 hrs to fix
              persistence/sql/persister_nid_test.go on lines 1745..1766

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

              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