Showing 90 of 163 total issues
File api.go
has 701 lines of code (exceeds 500 allowed). Consider refactoring. Open
/*
* Copyright (C) 2023 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Wrapper
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
type Wrapper struct {
auth auth.AuthenticationServices
policyBackend policy.PDPBackend
storageEngine storage.Engine
jsonldManager jsonld.JSONLD
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
File openid4vp.go
has 543 lines of code (exceeds 500 allowed). Consider refactoring. Open
/*
* Copyright (C) 2023 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
state
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
type state struct {
db stoabs.KVStore
graph *dag
payloadStore PayloadStore
txVerifiers []Verifier
Method dag.Migrate
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func (d *dag) Migrate() error {
return d.db.Write(context.Background(), func(tx stoabs.WriteTx) error {
writer := tx.GetShelfWriter(metadataShelf)
// Migrate highest LC value
// Todo: remove after V5 release
- 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"
Further reading
Method openidHandler.HandleCredentialOffer
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (h *openidHandler) HandleCredentialOffer(ctx context.Context, offer openid4vci.CredentialOffer) error {
// TODO: This check is too simplistic, there can be multiple credential offers,
// but the issuer should only request the one it's interested in.
// See https://github.com/nuts-foundation/nuts-node/issues/2049
if len(offer.Credentials) != 1 {
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{
- 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"
Further reading
Method Wrapper.handleAuthorizeResponseSubmission
has 81 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r Wrapper) handleAuthorizeResponseSubmission(ctx context.Context, request HandleAuthorizeResponseRequestObject) (HandleAuthorizeResponseResponseObject, error) {
verifier, err := r.toOwnedDIDForOAuth2(ctx, request.Did)
if err != nil {
return nil, oauthError(oauth.InvalidRequest, "unknown verifier id")
}
Function issueVC
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func issueVC() *cobra.Command {
var publish bool
var visibilityStr string
var expirationDate string
result := &cobra.Command{
- 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"
Further reading
Function matchFormat
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func matchFormat(format *PresentationDefinitionClaimFormatDesignations, credential vc.VerifiableCredential) bool {
if format == nil || len(*format) == 0 {
return true
}
- 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"
Further reading
File didman.go
has 503 lines of code (exceeds 500 allowed). Consider refactoring. Open
/*
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
Method Resolver.Resolve
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r Resolver) Resolve(id did.DID, _ *resolver.ResolveMetadata) (*did.Document, *resolver.DocumentMetadata, error) {
if id.Method != MethodName {
return nil, nil, fmt.Errorf("unsupported DID method: %s", id.Method)
}
encodedKey := id.ID
Method Wrapper.handleUserLanding
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r Wrapper) handleUserLanding(echoCtx echo.Context) error {
// todo: user authentication is currently not implemented, user consent is not implemented
// This means that this handler succeeds if the token is valid
// It only checks for an existing RequestAccessTokenRequestObject in the store
// It does not (yet) check for user consent or the existence of a user wallet
Method StatusList2021.Entry
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (cs *StatusList2021) Entry(ctx context.Context, issuer did.DID, purpose StatusPurpose) (*StatusList2021Entry, error) {
if purpose != StatusPurposeRevocation {
return nil, errUnsupportedPurpose
}
- 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"
Further reading
Function parseCredentialOptions
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func parseCredentialOptions(request IssueVCRequestObject) (*issuer.CredentialOptions, error) {
issuerDID, err := did.ParseDID(request.Body.Issuer)
if err != nil {
return nil, err
}
- 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"
Further reading
Method engine.initSQLDatabase
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (e *engine) initSQLDatabase() error {
connectionString := e.config.SQL.ConnectionString
if len(connectionString) == 0 {
connectionString = sqliteConnectionString(e.datadir)
}
Method PresentationSubmissionBuilder.Build
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func (b *PresentationSubmissionBuilder) Build(format string) (PresentationSubmission, SignInstructions, error) {
presentationSubmission := PresentationSubmission{
Id: uuid.New().String(),
DefinitionId: b.presentationDefinition.Id,
}
- 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"
Further reading
Method store.applyFrom
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tl *store) applyFrom(tx stoabs.WriteTx, base *event, applyList []event) error {
var document *did.Document
var metadata *documentMetadata
var err error
Method ambassador.handleUpdateDIDDocument
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (n *ambassador) handleUpdateDIDDocument(transaction dag.Transaction, proposedDIDDocument did.Document) error {
log.Logger().
WithField(core.LogFieldTransactionRef, transaction.Ref()).
WithField(core.LogFieldDID, proposedDIDDocument.ID).
Debug("Handling DID document update")