nuts-foundation/go-did

View on GitHub

Showing 13 of 13 total issues

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

func (vp *VerifiablePresentation) UnmarshalJSON(b []byte) error {
    var str string
    if len(b) > 0 && b[0] == '"' {
        if err := json.Unmarshal(b, &str); err != nil {
            return err
Severity: Major
Found in vc/vp.go and 1 other location - About 1 hr to fix
vc/vc.go on lines 273..287

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

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 (vc *VerifiableCredential) UnmarshalJSON(b []byte) error {
    var str string
    if len(b) > 0 && b[0] == '"' {
        if err := json.Unmarshal(b, &str); err != nil {
            return err
Severity: Major
Found in vc/vc.go and 1 other location - About 1 hr to fix
vc/vp.go on lines 176..190

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

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 VerificationMethod.PublicKey has 9 return statements (exceeds 4 allowed).
Open

func (v VerificationMethod) PublicKey() (crypto.PublicKey, error) {
    var pubKey crypto.PublicKey
    switch v.Type {
    case ssi.ED25519VerificationKey2018, ssi.ED25519VerificationKey2020:
        var keyBytes []byte
Severity: Major
Found in did/document.go - About 55 mins to fix

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

    func (d *DIDURL) UnmarshalJSON(bytes []byte) error {
        var didString string
        err := json.Unmarshal(bytes, &didString)
        if err != nil {
            return ErrInvalidDID.wrap(err)
    Severity: Minor
    Found in did/didurl.go and 1 other location - About 50 mins to fix
    did/did.go on lines 65..77

    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 (d *DID) UnmarshalJSON(bytes []byte) error {
        var didString string
        err := json.Unmarshal(bytes, &didString)
        if err != nil {
            return ErrInvalidDID.wrap(err)
    Severity: Minor
    Found in did/did.go and 1 other location - About 50 mins to fix
    did/didurl.go on lines 44..56

    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

    Function ParseDocument has 8 return statements (exceeds 4 allowed).
    Open

    func ParseDocument(raw string) (*Document, error) {
        type Alias Document
        normalizedDoc, err := marshal.NormalizeDocument([]byte(raw), pluralContext, marshal.Plural(controllerKey))
        if err != nil {
            return nil, err
    Severity: Major
    Found in did/document.go - About 50 mins to fix

      Function NewVerificationMethod has 7 return statements (exceeds 4 allowed).
      Open

      func NewVerificationMethod(id DIDURL, keyType ssi.KeyType, controller DID, key crypto.PublicKey) (*VerificationMethod, error) {
          vm := &VerificationMethod{
              ID:         id,
              Type:       keyType,
              Controller: controller,
      Severity: Major
      Found in did/document.go - About 45 mins to fix

        Function ParseDIDURL has 6 return statements (exceeds 4 allowed).
        Open

        func ParseDIDURL(input string) (*DIDURL, error) {
            // There are 6 submatches (base 0)
            // 0. DID + path + query + fragment
            // 1. DID
            // 2. method
        Severity: Major
        Found in did/didurl.go - About 40 mins to fix

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

          func (vp VerifiablePresentation) Proofs() ([]Proof, error) {
              var (
                  target []Proof
                  err    error
                  asJSON []byte
          Severity: Minor
          Found in vc/vp.go and 1 other location - About 40 mins to fix
          vc/vc.go on lines 243..256

          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 (vc VerifiableCredential) Proofs() ([]Proof, error) {
              var (
                  target []Proof
                  err    error
                  asJSON []byte
          Severity: Minor
          Found in vc/vc.go and 1 other location - About 40 mins to fix
          vc/vp.go on lines 142..155

          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 parseJTWPresentation has 5 return statements (exceeds 4 allowed).
          Open

          func parseJTWPresentation(raw string) (*VerifiablePresentation, error) {
              token, err := jwt.Parse([]byte(raw), jwt.WithVerify(false), jwt.WithValidate(false))
              if err != nil {
                  return nil, err
              }
          Severity: Major
          Found in vc/vp.go - About 35 mins to fix

            Method VerifiableCredential.SubjectDID has 5 return statements (exceeds 4 allowed).
            Open

            func (vc VerifiableCredential) SubjectDID() (*did.DID, error) {
                if len(vc.CredentialSubject) < 1 {
                    return nil, errors.New("unable to get subject DID from VC: there must be at least 1 credentialSubject")
                }
                type credentialSubject struct {
            Severity: Major
            Found in vc/vc.go - About 35 mins to fix

              Function parseJWTCredential has 5 return statements (exceeds 4 allowed).
              Open

              func parseJWTCredential(raw string) (*VerifiableCredential, error) {
                  token, err := jwt.Parse([]byte(raw), jwt.WithVerify(false), jwt.WithValidate(false))
                  if err != nil {
                      return nil, err
                  }
              Severity: Major
              Found in vc/vc.go - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language