nuts-foundation/nuts-node

View on GitHub
vcr/pe/presentation_definition.go

Summary

Maintainability
C
1 day
Test Coverage
A
93%

Function matchFormat has a Cognitive Complexity of 38 (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 3 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 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

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

    Method PresentationDefinition.matchSubmissionRequirements has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (presentationDefinition PresentationDefinition) matchSubmissionRequirements(vcs []vc.VerifiableCredential) ([]InputDescriptorMappingObject, []vc.VerifiableCredential, error) {
        // first we use the constraint matching algorithm to get the matching credentials
        candidates, err := presentationDefinition.matchConstraints(vcs)
        if err != nil {
            return nil, nil, err
    Severity: Minor
    Found in vcr/pe/presentation_definition.go - About 1 hr to fix

      Method PresentationDefinition.matchSubmissionRequirements has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
      Open

      func (presentationDefinition PresentationDefinition) matchSubmissionRequirements(vcs []vc.VerifiableCredential) ([]InputDescriptorMappingObject, []vc.VerifiableCredential, error) {
          // first we use the constraint matching algorithm to get the matching credentials
          candidates, err := presentationDefinition.matchConstraints(vcs)
          if err != nil {
              return nil, nil, err
      Severity: Minor
      Found in vcr/pe/presentation_definition.go - About 25 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

      There are no issues that match your filters.

      Category
      Status