nuts-foundation/nuts-node

View on GitHub

Showing 140 of 165 total issues

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

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

func (tl *store) DocumentCount() (uint, error) {
    var count uint32

    err := tl.db.ReadShelf(context.Background(), statsShelf, func(reader stoabs.Reader) error {
        cBytes, err := reader.Get(stoabs.BytesKey(documentCountKey))
Severity: Major
Found in vdr/didnuts/didstore/store.go and 1 other location - About 1 hr to fix
vdr/didnuts/didstore/store.go on lines 259..274

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

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 (tl *store) ConflictedCount() (uint, error) {
    var count uint32

    err := tl.db.ReadShelf(context.Background(), statsShelf, func(reader stoabs.Reader) error {
        cBytes, err := reader.Get(stoabs.BytesKey(conflictedCountKey))
Severity: Major
Found in vdr/didnuts/didstore/store.go and 1 other location - About 1 hr to fix
vdr/didnuts/didstore/store.go on lines 276..291

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

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

    func (c *OpenID4VPClient) RequestRFC021AccessToken(ctx context.Context, requester did.DID, verifier did.DID, scopes string,
        useDPoP bool, credentials []vc.VerifiableCredential) (*oauth.TokenResponse, error) {
        iamClient := c.httpClient
        oauthIssuer, err := didweb.DIDToURL(verifier)
        if err != nil {
    Severity: Minor
    Found in auth/client/iam/openid4vp.go - About 1 hr to fix

      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

          Method Wrapper.handleAuthorizeRequestFromVerifier has 65 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (r Wrapper) handleAuthorizeRequestFromVerifier(ctx context.Context, tenantDID did.DID, params oauthParameters, walletOwnerType WalletOwnerType) (HandleAuthorizeRequestResponseObject, error) {
              responseMode := params.get(oauth.ResponseModeParam)
              if responseMode != responseModeDirectPost {
                  return nil, oauth.OAuth2Error{Code: oauth.InvalidRequest, Description: "invalid response_mode parameter"}
              }
          Severity: Minor
          Found in auth/api/iam/openid4vp.go - About 1 hr to fix

            Function issueVC has 64 lines of code (exceeds 50 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 1 hr to fix

              Method Wrapper.RequestOpenid4VCICredentialIssuance has 64 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (r Wrapper) RequestOpenid4VCICredentialIssuance(ctx context.Context, request RequestOpenid4VCICredentialIssuanceRequestObject) (RequestOpenid4VCICredentialIssuanceResponseObject, error) {
                  if request.Body == nil {
                      // why did oapi-codegen generate a pointer for the body??
                      return nil, core.InvalidInputError("missing request body")
                  }
              Severity: Minor
              Found in auth/api/iam/openid4vci.go - About 1 hr to fix

                Method Wrapper.handleAuthorizeRequestFromHolder has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (r Wrapper) handleAuthorizeRequestFromHolder(ctx context.Context, verifier did.DID, params oauthParameters) (HandleAuthorizeRequestResponseObject, error) {
                    // first we check the redirect URL because later errors will redirect to this URL
                    // from RFC6749:
                    // If the request fails due to a missing, invalid, or mismatching
                    //   redirection URI, or if the client identifier is missing or invalid,
                Severity: Minor
                Found in auth/api/iam/openid4vp.go - About 1 hr to fix

                  Method StatusList2021.Revoke has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (cs *StatusList2021) Revoke(ctx context.Context, credentialID ssi.URI, entry StatusList2021Entry) error {
                      // parse StatusListIndex
                      statusListIndex, err := strconv.Atoi(entry.StatusListIndex)
                      if err != nil {
                          return err
                  Severity: Minor
                  Found in vcr/revocation/statuslist2021_issuer.go - About 1 hr to fix

                    Method protocol.handleTransactionSet has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (p *protocol) handleTransactionSet(_ context.Context, connection grpc.Connection, envelope *Envelope) error {
                        subEnvelope := envelope.Message.(*Envelope_TransactionSet)
                        msg := envelope.GetTransactionSet()
                        cid := conversationID(msg.ConversationID)
                        data := handlerData{}
                    Severity: Minor
                    Found in network/transport/v2/handlers.go - About 1 hr to fix

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

                      func (w *Wrapper) ActivateServiceForDID(ctx context.Context, request ActivateServiceForDIDRequestObject) (ActivateServiceForDIDResponseObject, error) {
                          subjectDID, err := did.ParseDID(request.Did)
                          if err != nil {
                              return nil, err
                          }
                      Severity: Major
                      Found in discovery/api/v1/api.go and 1 other location - About 1 hr to fix
                      discovery/api/v1/api.go on lines 109..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 158.

                      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 (w *Wrapper) DeactivateServiceForDID(ctx context.Context, request DeactivateServiceForDIDRequestObject) (DeactivateServiceForDIDResponseObject, error) {
                          subjectDID, err := did.ParseDID(request.Did)
                          if err != nil {
                              return nil, err
                          }
                      Severity: Major
                      Found in discovery/api/v1/api.go and 1 other location - About 1 hr to fix
                      discovery/api/v1/api.go on lines 90..107

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

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

                      func (r Wrapper) handleS2SAccessTokenRequest(ctx context.Context, issuer did.DID, scope string, submissionJSON string, assertionJSON string) (HandleTokenRequestResponseObject, error) {
                          pexEnvelope, err := pe.ParseEnvelope([]byte(assertionJSON))
                          if err != nil {
                              return nil, oauth.OAuth2Error{
                                  Code:        oauth.InvalidRequest,
                      Severity: Minor
                      Found in auth/api/iam/s2s_vptoken.go - About 1 hr to fix

                        Method Wrapper.CreateVP has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (w *Wrapper) CreateVP(ctx context.Context, request CreateVPRequestObject) (CreateVPResponseObject, error) {
                            if len(request.Body.VerifiableCredentials) == 0 {
                                return nil, core.InvalidInputError("verifiableCredentials needs at least 1 item")
                            }
                        
                        
                        Severity: Minor
                        Found in vcr/api/vcr/v2/api.go - About 1 hr to fix

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

                          func (system *System) Migrate() error {
                              var err error
                              return system.VisitEnginesE(func(engine Engine) error {
                                  // only if Engine is migratable
                                  if m, ok := engine.(Migratable); ok {
                          Severity: Major
                          Found in core/engine.go and 1 other location - About 1 hr to fix
                          core/engine.go on lines 81..95

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

                          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