vcr/issuer/openid.go
Method openidHandler.validateProof
has 108 lines of code (exceeds 50 allowed). Consider refactoring. Open
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
Method openidHandler.HandleCredentialRequest
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
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,
Function NewOpenIDHandler
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewOpenIDHandler(issuerDID did.DID, issuerIdentifierURL string, definitionsDIR string, httpClient core.HTTPRequestDoer, keyResolver resolver.KeyResolver, sessionDatabase storage.SessionDatabase) (OpenIDHandler, error) {
Method openidHandler.loadCredentialDefinitions
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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 {
- Read upRead up
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"