nuts-foundation/nuts-node

View on GitHub

Showing 141 of 166 total issues

Function resolveControllers has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func resolveControllers(didResolver resolver.DIDResolver, doc did.Document, metadata *resolver.ResolveMetadata, depth int) ([]did.Document, error) {
    var leaves []did.Document
    var refsToResolve []did.DID

    if len(doc.Controller) == 0 && len(doc.CapabilityInvocation) > 0 {
Severity: Minor
Found in vdr/didnuts/resolver.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 OpenID4VPClient.AccessToken has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

func (c *OpenID4VPClient) AccessToken(ctx context.Context, code string, tokenEndpoint string, callbackURI string, clientID did.DID, codeVerifier string, useDPoP bool) (*oauth.TokenResponse, error) {
Severity: Major
Found in auth/client/iam/openid4vp.go - About 50 mins to fix

    Function New has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        config Config,
        nodeDID did.DID,
        state dag.State,
        didResolver resolver.DIDResolver,
        decrypter crypto.Decrypter,
    Severity: Major
    Found in network/transport/v2/protocol.go - About 50 mins to fix

      Method OpenID4VPClient.RequestRFC021AccessToken has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (c *OpenID4VPClient) RequestRFC021AccessToken(ctx context.Context, requester did.DID, verifier did.DID, oauthIssuer *url.URL, scopes string,
          useDPoP bool, credentials []vc.VerifiableCredential) (*oauth.TokenResponse, error) {
      Severity: Major
      Found in auth/client/iam/openid4vp.go - About 50 mins to fix

        Function New has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            authInstance auth.AuthenticationServices, vcrInstance vcr.VCR, vdrInstance vdr.VDR, storageEngine storage.Engine,
            policyBackend policy.PDPBackend, jwtSigner nutsCrypto.JWTSigner, jsonldManager jsonld.JSONLD) *Wrapper {
        Severity: Major
        Found in auth/api/iam/api.go - About 50 mins to fix

          Function NewRelyingParty has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              didResolver resolver.DIDResolver, serviceResolver didman.CompoundServiceResolver, privateKeyStore nutsCrypto.KeyStore,
              wallet holder.Wallet, httpClientTimeout time.Duration, httpClientTLS *tls.Config, strictMode bool) RelyingParty {
          Severity: Major
          Found in auth/services/oauth/relying_party.go - About 50 mins to fix

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

                        if types := strings.Split(args[1], ","); len(types) != 1 {
                            if err := request.Type.FromIssueVCRequestType1(types); err != nil {
                                return fmt.Errorf("invalid credential type: %w", err)
                            }
                        } else {
            Severity: Minor
            Found in vcr/cmd/cmd.go and 1 other location - About 50 mins to fix
            vcr/cmd/cmd.go on lines 172..180

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

            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

                            if contexts := strings.Split(args[0], ","); len(contexts) != 1 {
                                if err := request.Context.FromIssueVCRequestContext1(contexts); err != nil {
                                    return fmt.Errorf("invalid @context: %w", err)
                                }
                            } else {
            Severity: Minor
            Found in vcr/cmd/cmd.go and 1 other location - About 50 mins to fix
            vcr/cmd/cmd.go on lines 183..191

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

            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 (c *vcr) Trust(credentialType ssi.URI, issuer ssi.URI) error {
                err := c.trustConfig.AddTrust(credentialType, issuer)
                if err != nil {
                    log.Logger().
                        WithField(core.LogFieldCredentialType, credentialType).
            Severity: Minor
            Found in vcr/vcr.go and 1 other location - About 50 mins to fix
            vcr/vcr.go on lines 449..458

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

            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 (c *vcr) Untrust(credentialType ssi.URI, issuer ssi.URI) error {
                err := c.trustConfig.RemoveTrust(credentialType, issuer)
                if err != nil {
                    log.Logger().
                        WithField(core.LogFieldCredentialType, credentialType).
            Severity: Minor
            Found in vcr/vcr.go and 1 other location - About 50 mins to fix
            vcr/vcr.go on lines 438..447

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

            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 (hb HTTPClient) Trust(credentialType string, issuer string) error {
                ctx := context.Background()
            
                body := TrustIssuerJSONRequestBody{
                    CredentialType: credentialType,
            Severity: Minor
            Found in vcr/api/vcr/v2/client.go and 1 other location - About 50 mins to fix
            vcr/api/vcr/v2/client.go on lines 65..79

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

            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 (hb HTTPClient) Untrust(credentialType string, issuer string) error {
                ctx := context.Background()
            
                body := UntrustIssuerJSONRequestBody{
                    CredentialType: credentialType,
            Severity: Minor
            Found in vcr/api/vcr/v2/client.go and 1 other location - About 50 mins to fix
            vcr/api/vcr/v2/client.go on lines 48..62

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

            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 NewVerifier has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func NewVerifier(store Store, didResolver resolver.DIDResolver, keyResolver resolver.KeyResolver, jsonldManager jsonld.JSONLD, trustConfig *trust.Config, credentialStatus *revocation.StatusList2021) Verifier {
            Severity: Minor
            Found in vcr/verifier/verifier.go - About 45 mins to fix

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

              func authenticationSort(result *did.Document) less {
                  return func(i, j int) bool {
                      is := result.Authentication[i].ID.String()
                      js := result.Authentication[j].ID.String()
                      return strings.Compare(is, js) == -1
              Severity: Major
              Found in vdr/didnuts/didstore/merge.go and 6 other locations - About 45 mins to fix
              vdr/didnuts/didstore/merge.go on lines 155..161
              vdr/didnuts/didstore/merge.go on lines 163..169
              vdr/didnuts/didstore/merge.go on lines 171..177
              vdr/didnuts/didstore/merge.go on lines 187..193
              vdr/didnuts/didstore/merge.go on lines 195..201
              vdr/didnuts/didstore/merge.go on lines 203..209

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

              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 7 locations. Consider refactoring.
              Open

              func capabilityInvocationSort(result *did.Document) less {
                  return func(i, j int) bool {
                      is := result.CapabilityInvocation[i].ID.String()
                      js := result.CapabilityInvocation[j].ID.String()
                      return strings.Compare(is, js) == -1
              Severity: Major
              Found in vdr/didnuts/didstore/merge.go and 6 other locations - About 45 mins to fix
              vdr/didnuts/didstore/merge.go on lines 155..161
              vdr/didnuts/didstore/merge.go on lines 163..169
              vdr/didnuts/didstore/merge.go on lines 171..177
              vdr/didnuts/didstore/merge.go on lines 179..185
              vdr/didnuts/didstore/merge.go on lines 195..201
              vdr/didnuts/didstore/merge.go on lines 203..209

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

              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

              Method authzServer.buildAccessToken has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (s *authzServer) buildAccessToken(ctx context.Context, requester did.DID, authorizer did.DID, purposeOfUse string, userIdentity contract.VPVerificationResult, credentialIDs []string) (string, services.NutsAccessToken, error) {
              Severity: Minor
              Found in auth/services/oauth/authz_server.go - About 45 mins to fix

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

                func capabilityDelegationSort(result *did.Document) less {
                    return func(i, j int) bool {
                        is := result.CapabilityDelegation[i].ID.String()
                        js := result.CapabilityDelegation[j].ID.String()
                        return strings.Compare(is, js) == -1
                Severity: Major
                Found in vdr/didnuts/didstore/merge.go and 6 other locations - About 45 mins to fix
                vdr/didnuts/didstore/merge.go on lines 155..161
                vdr/didnuts/didstore/merge.go on lines 163..169
                vdr/didnuts/didstore/merge.go on lines 171..177
                vdr/didnuts/didstore/merge.go on lines 179..185
                vdr/didnuts/didstore/merge.go on lines 187..193
                vdr/didnuts/didstore/merge.go on lines 203..209

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

                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

                Method Wrapper.sendAndHandleDirectPost has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func (r Wrapper) sendAndHandleDirectPost(ctx context.Context, userWalletDID did.DID, vp vc.VerifiablePresentation, presentationSubmission pe.PresentationSubmission, verifierResponseURI string, state string) (HandleAuthorizeRequestResponseObject, error) {
                Severity: Minor
                Found in auth/api/iam/openid4vp.go - About 45 mins to fix

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

                  func serviceSort(result *did.Document) less {
                      return func(i, j int) bool {
                          is := result.Service[i].ID.String()
                          js := result.Service[j].ID.String()
                          return strings.Compare(is, js) == -1
                  Severity: Major
                  Found in vdr/didnuts/didstore/merge.go and 6 other locations - About 45 mins to fix
                  vdr/didnuts/didstore/merge.go on lines 155..161
                  vdr/didnuts/didstore/merge.go on lines 163..169
                  vdr/didnuts/didstore/merge.go on lines 171..177
                  vdr/didnuts/didstore/merge.go on lines 179..185
                  vdr/didnuts/didstore/merge.go on lines 187..193
                  vdr/didnuts/didstore/merge.go on lines 195..201

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

                  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

                  Method Wrapper.createAccessToken has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (r Wrapper) createAccessToken(issuer did.DID, walletDID did.DID, issueTime time.Time, scope string, pexState PEXConsumer, dpopToken *dpop.DPoP) (*oauth.TokenResponse, error) {
                  Severity: Minor
                  Found in auth/api/iam/access_token.go - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language