nuts-foundation/nuts-node

View on GitHub

Showing 90 of 163 total issues

File api.go has 701 lines of code (exceeds 500 allowed). Consider refactoring.
Open

/*
 * Copyright (C) 2023 Nuts community
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
Severity: Minor
Found in auth/api/iam/api.go - About 6 hrs to fix

    Wrapper has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Wrapper struct {
        auth          auth.AuthenticationServices
        policyBackend policy.PDPBackend
        storageEngine storage.Engine
        jsonldManager jsonld.JSONLD
    Severity: Minor
    Found in auth/api/iam/api.go - About 3 hrs to fix

      Method openidHandler.validateProof has 108 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (i *openidHandler) validateProof(ctx context.Context, flow *Flow, request openid4vci.CredentialRequest) error {
          credential := flow.Credentials[0] // there's always just one (at least for now)
          wallet, _ := credential.SubjectDID()
      
          // augment invalid_proof errors according to §7.3.2 of openid4vci spec
      Severity: Major
      Found in vcr/issuer/openid.go - About 3 hrs to fix

        File openid4vp.go has 543 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        /*
         * Copyright (C) 2023 Nuts community
         *
         * This program is free software: you can redistribute it and/or modify
         * it under the terms of the GNU General Public License as published by
        Severity: Minor
        Found in auth/api/iam/openid4vp.go - About 3 hrs to fix

          state has 26 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type state struct {
              db                  stoabs.KVStore
              graph               *dag
              payloadStore        PayloadStore
              txVerifiers         []Verifier
          Severity: Minor
          Found in network/dag/state.go - About 3 hrs to fix

            Method dag.Migrate has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
            Open

            func (d *dag) Migrate() error {
                return d.db.Write(context.Background(), func(tx stoabs.WriteTx) error {
                    writer := tx.GetShelfWriter(metadataShelf)
                    // Migrate highest LC value
                    // Todo: remove after V5 release
            Severity: Minor
            Found in network/dag/dag.go - About 2 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 openidHandler.HandleCredentialOffer has 86 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (h *openidHandler) HandleCredentialOffer(ctx context.Context, offer openid4vci.CredentialOffer) error {
                // TODO: This check is too simplistic, there can be multiple credential offers,
                //       but the issuer should only request the one it's interested in.
                //       See https://github.com/nuts-foundation/nuts-node/issues/2049
                if len(offer.Credentials) != 1 {
            Severity: Major
            Found in vcr/holder/openid.go - About 2 hrs to fix

              Function matchFilter has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
              Open

              func matchFilter(filter Filter, value interface{}) (bool, error) {
                  // first we check if it's an enum, so we can recursively call matchFilter for each value
                  if filter.Enum != nil {
                      for _, enum := range filter.Enum {
                          f := Filter{
              Severity: Minor
              Found in vcr/pe/presentation_definition.go - About 2 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 Wrapper.handleAuthorizeResponseSubmission has 81 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (r Wrapper) handleAuthorizeResponseSubmission(ctx context.Context, request HandleAuthorizeResponseRequestObject) (HandleAuthorizeResponseResponseObject, error) {
                  verifier, err := r.toOwnedDIDForOAuth2(ctx, request.Did)
                  if err != nil {
                      return nil, oauthError(oauth.InvalidRequest, "unknown verifier id")
                  }
              Severity: Major
              Found in auth/api/iam/openid4vp.go - About 2 hrs to fix

                Function issueVC has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
                Open

                func issueVC() *cobra.Command {
                    var publish bool
                    var visibilityStr string
                    var expirationDate string
                    result := &cobra.Command{
                Severity: Minor
                Found in vcr/cmd/cmd.go - About 2 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

                Function matchFormat has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
                Open

                func matchFormat(format *PresentationDefinitionClaimFormatDesignations, credential vc.VerifiableCredential) bool {
                    if format == nil || len(*format) == 0 {
                        return true
                    }
                
                
                Severity: Minor
                Found in vcr/pe/presentation_definition.go - About 2 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

                File didman.go has 503 lines of code (exceeds 500 allowed). Consider refactoring.
                Open

                /*
                 * Nuts node
                 * Copyright (C) 2021 Nuts community
                 *
                 * This program is free software: you can redistribute it and/or modify
                Severity: Minor
                Found in didman/didman.go - About 2 hrs to fix

                  Method Resolver.Resolve has 75 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (r Resolver) Resolve(id did.DID, _ *resolver.ResolveMetadata) (*did.Document, *resolver.DocumentMetadata, error) {
                      if id.Method != MethodName {
                          return nil, nil, fmt.Errorf("unsupported DID method: %s", id.Method)
                      }
                      encodedKey := id.ID
                  Severity: Minor
                  Found in vdr/didkey/resolver.go - About 2 hrs to fix

                    Method Wrapper.handleUserLanding has 73 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (r Wrapper) handleUserLanding(echoCtx echo.Context) error {
                        // todo: user authentication is currently not implemented, user consent is not implemented
                        // This means that this handler succeeds if the token is valid
                        // It only checks for an existing RequestAccessTokenRequestObject in the store
                        // It does not (yet) check for user consent or the existence of a user wallet
                    Severity: Minor
                    Found in auth/api/iam/user.go - About 1 hr to fix

                      Method StatusList2021.Entry has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (cs *StatusList2021) Entry(ctx context.Context, issuer did.DID, purpose StatusPurpose) (*StatusList2021Entry, error) {
                          if purpose != StatusPurposeRevocation {
                              return nil, errUnsupportedPurpose
                          }
                      
                      
                      Severity: Minor
                      Found in vcr/revocation/statuslist2021_issuer.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 parseCredentialOptions has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func parseCredentialOptions(request IssueVCRequestObject) (*issuer.CredentialOptions, error) {
                          issuerDID, err := did.ParseDID(request.Body.Issuer)
                          if err != nil {
                              return nil, err
                          }
                      Severity: Minor
                      Found in vcr/api/vcr/v2/api.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 engine.initSQLDatabase has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (e *engine) initSQLDatabase() error {
                          connectionString := e.config.SQL.ConnectionString
                          if len(connectionString) == 0 {
                              connectionString = sqliteConnectionString(e.datadir)
                          }
                      Severity: Minor
                      Found in storage/engine.go - About 1 hr to fix

                        Method PresentationSubmissionBuilder.Build has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (b *PresentationSubmissionBuilder) Build(format string) (PresentationSubmission, SignInstructions, error) {
                            presentationSubmission := PresentationSubmission{
                                Id:           uuid.New().String(),
                                DefinitionId: b.presentationDefinition.Id,
                            }
                        Severity: Minor
                        Found in vcr/pe/presentation_submission.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 store.applyFrom has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (tl *store) applyFrom(tx stoabs.WriteTx, base *event, applyList []event) error {
                            var document *did.Document
                            var metadata *documentMetadata
                            var err error
                        
                        
                        Severity: Minor
                        Found in vdr/didnuts/didstore/writer.go - About 1 hr to fix

                          Method ambassador.handleUpdateDIDDocument has 66 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (n *ambassador) handleUpdateDIDDocument(transaction dag.Transaction, proposedDIDDocument did.Document) error {
                              log.Logger().
                                  WithField(core.LogFieldTransactionRef, transaction.Ref()).
                                  WithField(core.LogFieldDID, proposedDIDDocument.ID).
                                  Debug("Handling DID document update")
                          Severity: Minor
                          Found in vdr/didnuts/ambassador.go - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language