nuts-foundation/nuts-node

View on GitHub

Showing 141 of 166 total issues

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

func keyAgreementSort(result *did.Document) less {
    return func(i, j int) bool {
        is := result.KeyAgreement[i].ID.String()
        js := result.KeyAgreement[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 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
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

Function NewOpenIDHandler has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

func NewOpenIDHandler(issuerDID did.DID, issuerIdentifierURL string, definitionsDIR string, httpClient core.HTTPRequestDoer, keyResolver resolver.KeyResolver, sessionDatabase storage.SessionDatabase) (OpenIDHandler, error) {
Severity: Minor
Found in vcr/issuer/openid.go - About 45 mins to fix

    Function NewOpenIDHandler has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func NewOpenIDHandler(did did.DID, identifier string, httpClient core.HTTPRequestDoer, credentialStore vcrTypes.Writer, signer crypto.JWTSigner, resolver resolver.KeyResolver) OpenIDHandler {
    Severity: Minor
    Found in vcr/holder/openid.go - About 45 mins to fix

      Method StatusList2021.Revoke has a Cognitive Complexity of 23 (exceeds 20 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 45 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

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

      func assertionSort(result *did.Document) less {
          return func(i, j int) bool {
              is := result.AssertionMethod[i].ID.String()
              js := result.AssertionMethod[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 179..185
      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

      Function NewClient has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func NewClient(wallet holder.Wallet, keyResolver resolver.KeyResolver, jwtSigner nutsCrypto.JWTSigner, ldDocumentLoader ld.DocumentLoader, strictMode bool, httpClientTimeout time.Duration) *OpenID4VPClient {
      Severity: Minor
      Found in auth/client/iam/openid4vp.go - About 45 mins to fix

        Method presenter.buildSubmission has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func (p presenter) buildSubmission(ctx context.Context, holderDID did.DID, credentials []vc.VerifiableCredential, presentationDefinition pe.PresentationDefinition,
            acceptedFormats map[string]map[string][]string, params BuildParams) (*vc.VerifiablePresentation, *pe.PresentationSubmission, error) {
        Severity: Minor
        Found in vcr/holder/presenter.go - About 45 mins to fix

          Method validator.sync has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
          Open

          func (v *validator) sync() {
              // Use a WaitGroup to track when background goroutines are complete
              wg := &sync.WaitGroup{}
          
              // maximum time between updates
          Severity: Minor
          Found in pki/validator.go - About 45 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

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

          func verificationMethodSort(result *did.Document) less {
              return func(i, j int) bool {
                  is := result.VerificationMethod[i].ID.String()
                  js := result.VerificationMethod[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 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
          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 2 locations. Consider refactoring.
          Open

          func (s *state) IsPayloadPresent(ctx context.Context, hash hash.SHA256Hash) (present bool, err error) {
              err = s.db.Read(ctx, func(tx stoabs.ReadTx) error {
                  present = s.payloadStore.isPayloadPresent(tx, hash)
                  return nil
              })
          Severity: Minor
          Found in network/dag/state.go and 1 other location - About 45 mins to fix
          network/dag/state.go on lines 287..293

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

          func (s *state) IsPresent(ctx context.Context, hash hash.SHA256Hash) (present bool, err error) {
              err = s.db.Read(ctx, func(tx stoabs.ReadTx) error {
                  present = s.graph.isPresent(tx, hash)
                  return nil
              })
          Severity: Minor
          Found in network/dag/state.go and 1 other location - About 45 mins to fix
          network/dag/state.go on lines 279..285

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

                          if iParts.Transformer != nil {
                              transformer := strings.ToLower(*iParts.Transformer)
                              switch transformer {
                              case "cologne":
                                  options = append(options, leia.TransformerOption(CologneTransformer))
          Severity: Minor
          Found in vcr/vcr.go and 1 other location - About 40 mins to fix
          vcr/vcr.go on lines 343..353

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

          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 iParts.Tokenizer != nil {
                              tokenizer := strings.ToLower(*iParts.Tokenizer)
                              switch tokenizer {
                              case "whitespaceorexact":
                                  options = append(options, leia.TokenizerOption(whitespaceOrExactTokenizer))
          Severity: Minor
          Found in vcr/vcr.go and 1 other location - About 40 mins to fix
          vcr/vcr.go on lines 354..364

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

          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 (s *memorySessionStore) Start(ctx context.Context) {
              done := ctx.Done()
          
              go func() {
                  timer := time.NewTicker(s.expiryInterval)
          Severity: Minor
          Found in auth/services/selfsigned/store.go and 1 other location - About 40 mins to fix
          network/transport/v2/conversation.go on lines 96..110

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

          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 (cMan *conversationManager) start(ctx context.Context) {
              done := ctx.Done()
          
              go func() {
                  timer := time.NewTicker(cMan.validity)
          Severity: Minor
          Found in network/transport/v2/conversation.go and 1 other location - About 40 mins to fix
          auth/services/selfsigned/store.go on lines 78..92

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

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

              keyResolver resolver.KeyResolver, keyStore crypto.KeyStore, verifier verifier.Verifier, jsonldManager jsonld.JSONLD,
              storageEngine storage.Engine) Wallet {
          Severity: Minor
          Found in vcr/holder/sql_wallet.go - About 35 mins to fix

            Method didman.addService has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (d *didman) addService(ctx context.Context, id did.DID, serviceType string, serviceEndpoint interface{}, preprocessor func(*did.Document)) (*did.Service, error) {
            Severity: Minor
            Found in didman/didman.go - About 35 mins to fix

              Method Wrapper.handleS2SAccessTokenRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (r Wrapper) handleS2SAccessTokenRequest(ctx context.Context, issuer did.DID, scope string, submissionJSON string, assertionJSON string) (HandleTokenRequestResponseObject, error) {
              Severity: Minor
              Found in auth/api/iam/s2s_vptoken.go - About 35 mins to fix

                Method presenter.buildJWTPresentation has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func (p presenter) buildJWTPresentation(ctx context.Context, subjectDID did.DID, credentials []vc.VerifiableCredential, options PresentationOptions, keyID string) (*vc.VerifiablePresentation, error) {
                Severity: Minor
                Found in vcr/holder/presenter.go - About 35 mins to fix

                  Method presenter.buildJSONLDPresentation has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (p presenter) buildJSONLDPresentation(ctx context.Context, subjectDID did.DID, credentials []vc.VerifiableCredential, options PresentationOptions, keyID string) (*vc.VerifiablePresentation, error) {
                  Severity: Minor
                  Found in vcr/holder/presenter.go - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language