ory-am/hydra

View on GitHub

Showing 402 of 849 total issues

Method APIClient.decode has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
    if len(b) == 0 {
        return nil
    }
    if s, ok := v.(*string); ok {
Severity: Minor
Found in internal/httpclient/client.go - About 1 hr to fix

    Function TestGetOrGenerateKeys has 52 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestGetOrGenerateKeys(t *testing.T) {
        t.Parallel()
        reg := internal.NewMockedRegistry(t, &contextx.Default{})
    
        setId := uuid.NewUUID().String()
    Severity: Minor
    Found in jwk/helper_test.go - About 1 hr to fix

      Method Handler.rejectOAuth2LoginRequest has 51 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (h *Handler) rejectOAuth2LoginRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
          ctx := r.Context()
      
          challenge := stringsx.Coalesce(
              r.URL.Query().Get("login_challenge"),
      Severity: Minor
      Found in consent/handler.go - About 1 hr to fix

        Function Test_toSDKFriendlyJSONWebKey has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func Test_toSDKFriendlyJSONWebKey(t *testing.T) {
            publicJWK := []byte(`{
                "kty": "RSA",
                "e": "AQAB",
                "use": "sig",
        Severity: Minor
        Found in cmd/cli/handler_jwk_test.go - About 1 hr to fix

          Function getRefreshRequests has 51 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func getRefreshRequests(uniqueName string, lifespan time.Duration) []*fosite.AccessRequest {
              var tokenSignature = "4c7c7e8b3a77ad0c3ec846a21653c48b45dbfa31" //nolint:gosec
              return []*fosite.AccessRequest{
                  {
                      GrantTypes: []string{
          Severity: Minor
          Found in internal/testhelpers/janitor_test_helper.go - About 1 hr to fix

            Function purge has 51 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func purge(cmd *cobra.Command, args []string, sl *servicelocatorx.Options, dOpts []driver.OptionsModifier) error {
                ctx := cmd.Context()
                var d driver.Registry
            
                co := []configx.OptionModifier{
            Severity: Minor
            Found in cmd/cli/handler_janitor.go - About 1 hr to fix

              Method Handler.acceptOAuth2LoginRequest has 10 return statements (exceeds 4 allowed).
              Open

              func (h *Handler) acceptOAuth2LoginRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
                  ctx := r.Context()
              
                  challenge := stringsx.Coalesce(
                      r.URL.Query().Get("login_challenge"),
              Severity: Major
              Found in consent/handler.go - About 1 hr to fix

                Function SaneMockHandleConsentRequest has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func SaneMockHandleConsentRequest(t *testing.T, m consent.Manager, f *flow.Flow, c *flow.OAuth2ConsentRequest, authAt time.Time, rememberFor int, remember bool, hasError bool) *flow.AcceptOAuth2ConsentRequest {
                Severity: Major
                Found in consent/test/manager_test_helpers.go - About 1 hr to fix

                  Method DefaultStrategy.requestAuthentication has 10 return statements (exceeds 4 allowed).
                  Open

                  func (s *DefaultStrategy) requestAuthentication(ctx context.Context, w http.ResponseWriter, r *http.Request, ar fosite.AuthorizeRequester) (err error) {
                      ctx, span := trace.SpanFromContext(ctx).TracerProvider().Tracer("").Start(ctx, "DefaultStrategy.requestAuthentication")
                      defer otelx.End(span, &err)
                  
                      prompt := stringsx.Splitx(ar.GetRequestForm().Get("prompt"), " ")
                  Severity: Major
                  Found in consent/strategy_default.go - About 1 hr to fix

                    Function MockConsentRequest has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func MockConsentRequest(key string, remember bool, rememberFor int, hasError bool, skip bool, authAt bool, loginChallengeBase string, network string) (c *flow.OAuth2ConsentRequest, h *flow.AcceptOAuth2ConsentRequest, f *flow.Flow) {
                    Severity: Major
                    Found in consent/test/manager_test_helpers.go - About 1 hr to fix

                      Method OidcApiService.CreateVerifiableCredentialExecute has 10 return statements (exceeds 4 allowed).
                      Open

                      func (a *OidcApiService) CreateVerifiableCredentialExecute(r ApiCreateVerifiableCredentialRequest) (*VerifiableCredentialResponse, *http.Response, error) {
                          var (
                              localVarHTTPMethod  = http.MethodPost
                              localVarPostBody    interface{}
                              formFiles           []formFile
                      Severity: Major
                      Found in internal/httpclient/api_oidc.go - About 1 hr to fix

                        Function GetOrCreateTLSCertificate has 10 return statements (exceeds 4 allowed).
                        Open

                        func GetOrCreateTLSCertificate(ctx context.Context, d driver.Registry, iface config.ServeInterface, stopReload <-chan struct{}) func(*tls.ClientHelloInfo) (*tls.Certificate, error) {
                            lock.Lock()
                            defer lock.Unlock()
                        
                            // check if certificates are configured
                        Severity: Major
                        Found in cmd/server/helper_cert.go - About 1 hr to fix

                          Method APIClient.prepareRequest has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              ctx context.Context,
                              path string, method string,
                              postBody interface{},
                              headerParams map[string]string,
                              queryParams url.Values,
                          Severity: Major
                          Found in internal/httpclient/client.go - About 1 hr to fix

                            Function NewKeysImportCmd has 10 return statements (exceeds 4 allowed).
                            Open

                            func NewKeysImportCmd() *cobra.Command {
                                cmd := &cobra.Command{
                                    Use:  "jwk set-id file-1 [file-2] [file-n]",
                                    Args: cobra.MinimumNArgs(1),
                                    Example: `{{ .CommandPath }} my-set ./path/to/jwk.json ./path/to/jwk-2.json --format json
                            Severity: Major
                            Found in cmd/cmd_import_jwk.go - About 1 hr to fix

                              Function serve has 8 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  ctx context.Context,
                                  d driver.Registry,
                                  cmd *cobra.Command,
                                  wg *sync.WaitGroup,
                                  iface config.ServeInterface,
                              Severity: Major
                              Found in cmd/server/handler.go - About 1 hr to fix

                                Method Handler.oAuth2Authorize has 10 return statements (exceeds 4 allowed).
                                Open

                                func (h *Handler) oAuth2Authorize(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
                                    ctx := r.Context()
                                
                                    authorizeRequest, err := h.r.OAuth2Provider().NewAuthorizeRequest(ctx, r)
                                    if err != nil {
                                Severity: Major
                                Found in oauth2/handler.go - About 1 hr to fix

                                  Method OAuth2ApiService.RejectOAuth2LoginRequestExecute has 9 return statements (exceeds 4 allowed).
                                  Open

                                  func (a *OAuth2ApiService) RejectOAuth2LoginRequestExecute(r ApiRejectOAuth2LoginRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
                                      var (
                                          localVarHTTPMethod  = http.MethodPut
                                          localVarPostBody    interface{}
                                          formFiles           []formFile
                                  Severity: Major
                                  Found in internal/httpclient/api_o_auth2.go - About 55 mins to fix

                                    Function TestLogoutFlows has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                                    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: Minor
                                    Found in consent/strategy_logout_test.go - About 55 mins 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.AcceptOAuth2ConsentRequestExecute has 9 return statements (exceeds 4 allowed).
                                    Open

                                    func (a *OAuth2ApiService) AcceptOAuth2ConsentRequestExecute(r ApiAcceptOAuth2ConsentRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
                                        var (
                                            localVarHTTPMethod  = http.MethodPut
                                            localVarPostBody    interface{}
                                            formFiles           []formFile
                                    Severity: Major
                                    Found in internal/httpclient/api_o_auth2.go - About 55 mins to fix

                                      Method OAuth2ApiService.AcceptOAuth2LogoutRequestExecute has 9 return statements (exceeds 4 allowed).
                                      Open

                                      func (a *OAuth2ApiService) AcceptOAuth2LogoutRequestExecute(r ApiAcceptOAuth2LogoutRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
                                          var (
                                              localVarHTTPMethod  = http.MethodPut
                                              localVarPostBody    interface{}
                                              formFiles           []formFile
                                      Severity: Major
                                      Found in internal/httpclient/api_o_auth2.go - About 55 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language