nuts-foundation/nuts-node

View on GitHub
vcr/issuer/openid.go

Summary

Maintainability
B
5 hrs
Test Coverage
B
85%

Method openidHandler.validateProof has 108 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (i *openidHandler) validateProof(ctx context.Context, flow *Flow, request openid4vci.CredentialRequest) error {
    credential := flow.Credentials[0] // there's always just one (at least for now)
    wallet, _ := credential.SubjectDID()

    // augment invalid_proof errors according to ยง7.3.2 of openid4vci spec
Severity: Major
Found in vcr/issuer/openid.go - About 3 hrs to fix

    Method openidHandler.HandleCredentialRequest has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (i *openidHandler) HandleCredentialRequest(ctx context.Context, request openid4vci.CredentialRequest, accessToken string) (*vc.VerifiableCredential, error) {
        if request.Format != vc.JSONLDCredentialProofFormat {
            return nil, openid4vci.Error{
                Err:        fmt.Errorf("credential request: unsupported format '%s'", request.Format),
                Code:       openid4vci.UnsupportedCredentialType,
    Severity: Minor
    Found in vcr/issuer/openid.go - About 1 hr to fix

      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

        Method openidHandler.loadCredentialDefinitions has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func (i *openidHandler) loadCredentialDefinitions() error {
        
            // retrieve the definitions from assets and add to the list of CredentialsSupported
            definitionsDir, err := assets.FS.ReadDir("definitions")
            if err != nil {
        Severity: Minor
        Found in vcr/issuer/openid.go - About 35 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