ory-am/hydra

View on GitHub

Showing 402 of 849 total issues

Function main has 58 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {
    flag.Parse()
    conf := oauth2.Config{
        ClientID:     os.Getenv("OAUTH2_CLIENT_ID"),
        ClientSecret: os.Getenv("OAUTH2_CLIENT_SECRET"),
Severity: Minor
Found in test/mock-client/main.go - About 1 hr to fix

    Function run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const run = (client) => {
          cy.visit(
            `${Cypress.env("client_url")}/${path}/code?client_id=${
              client_id || client.client_id
            }&client_secret=${client_secret || client.client_secret}&scope=${(
    Severity: Minor
    Found in cypress/support/commands.js - About 1 hr to fix

      Method OAuth2ApiService.DeleteOAuth2TokenExecute has 57 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

        Method OAuth2ApiService.RejectOAuth2LogoutRequestExecute has 57 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

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

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

                          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

                            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

                              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

                                Method JwkApiService.DeleteJsonWebKeyExecute has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (a *JwkApiService) DeleteJsonWebKeyExecute(r ApiDeleteJsonWebKeyRequest) (*http.Response, error) {
                                    var (
                                        localVarHTTPMethod = http.MethodDelete
                                        localVarPostBody   interface{}
                                        formFiles          []formFile
                                Severity: Minor
                                Found in internal/httpclient/api_jwk.go - About 1 hr to fix

                                  Function TestJWTBearer has 12 return statements (exceeds 4 allowed).
                                  Open

                                  func TestJWTBearer(t *testing.T) {
                                      ctx := context.Background()
                                      reg := internal.NewMockedRegistry(t, &contextx.Default{})
                                      reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
                                      _, admin := testhelpers.NewOAuth2Server(ctx, t, reg)
                                  Severity: Major
                                  Found in oauth2/oauth2_jwt_bearer_test.go - About 1 hr to fix

                                    Method OAuth2ApiService.DeleteTrustedOAuth2JwtGrantIssuerExecute has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

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

                                      Method OidcApiService.DeleteOidcDynamicClientExecute has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                                      Open

                                      func (a *OidcApiService) DeleteOidcDynamicClientExecute(r ApiDeleteOidcDynamicClientRequest) (*http.Response, error) {
                                          var (
                                              localVarHTTPMethod = http.MethodDelete
                                              localVarPostBody   interface{}
                                              formFiles          []formFile
                                      Severity: Minor
                                      Found in internal/httpclient/api_oidc.go - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language