Showing 13 of 13 total issues
Method ConsentLogic.HandleIncomingCordaEvent
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
Open
func (cl ConsentLogic) HandleIncomingCordaEvent(event *events.Event) {
logger().Infof("received event %v", event)
crs := bridgeClient.FullConsentRequestState{}
decodedPayload, err := base64.StdEncoding.DecodeString(event.Payload)
- 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 ConsentLogic.HandleIncomingCordaEvent
has 102 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (cl ConsentLogic) HandleIncomingCordaEvent(event *events.Event) {
logger().Infof("received event %v", event)
crs := bridgeClient.FullConsentRequestState{}
decodedPayload, err := base64.StdEncoding.DecodeString(event.Payload)
Method ConsentLogic.buildConsentRequestConstructedEvent
has 96 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (cl ConsentLogic) buildConsentRequestConstructedEvent(createConsentRequest *CreateConsentRequest) (*events.Event, error) {
var err error
var consentID string
var records []bridgeClient.ConsentRecord
legalEntities := []bridgeClient.Identifier{
File logic.go
has 519 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
/*
* Nuts consent logic holds the logic for consent creation
* Copyright (C) 2019 Nuts community
*
* This program is free software: you can redistribute it and/or modify
Method ConsentLogic.signConsentRequest
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (cl ConsentLogic) signConsentRequest(event events.Event) (*events.Event, error) {
crs := bridgeClient.FullConsentRequestState{}
decodedPayload, err := base64.StdEncoding.DecodeString(event.Payload)
if err != nil {
errorDescription := "Could not base64 decode event payload"
Method Wrapper.CreateOrUpdateConsent
has 12 return statements (exceeds 4 allowed). Open
Open
func (wrapper Wrapper) CreateOrUpdateConsent(ctx echo.Context) error {
createConsentApiRequest := &CreateConsentRequest{}
if err := ctx.Bind(createConsentApiRequest); err != nil {
ctx.Logger().Error("Could not unmarshal json body:", err)
return err
Method ConsentLogic.signConsentRequest
has 9 return statements (exceeds 4 allowed). Open
Open
func (cl ConsentLogic) signConsentRequest(event events.Event) (*events.Event, error) {
crs := bridgeClient.FullConsentRequestState{}
decodedPayload, err := base64.StdEncoding.DecodeString(event.Payload)
if err != nil {
errorDescription := "Could not base64 decode event payload"
Method ConsentLogic.HandleIncomingCordaEvent
has 8 return statements (exceeds 4 allowed). Open
Open
func (cl ConsentLogic) HandleIncomingCordaEvent(event *events.Event) {
logger().Infof("received event %v", event)
crs := bridgeClient.FullConsentRequestState{}
decodedPayload, err := base64.StdEncoding.DecodeString(event.Payload)
Method ConsentLogic.buildConsentRequestConstructedEvent
has 7 return statements (exceeds 4 allowed). Open
Open
func (cl ConsentLogic) buildConsentRequestConstructedEvent(createConsentRequest *CreateConsentRequest) (*events.Event, error) {
var err error
var consentID string
var records []bridgeClient.ConsentRecord
legalEntities := []bridgeClient.Identifier{
Method ConsentLogic.HandleEventConsentDistributed
has 6 return statements (exceeds 4 allowed). Open
Open
func (cl ConsentLogic) HandleEventConsentDistributed(event *events.Event) {
crs := bridgeClient.ConsentState{}
decodedPayload, err := base64.StdEncoding.DecodeString(event.Payload)
if err != nil {
logger().Errorf("Unable to base64 decode event payload")
Function NewConsentLogicInstance
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewConsentLogicInstance(config ConsentLogicConfig, cryptoClient crypto.Client, registryClient pkg.RegistryClient, consentStoreClient cStore.ConsentStoreClient, eventOctopusClient events.EventOctopusClient) *ConsentLogic {
Method ConsentLogic.decryptConsentRecord
has 5 return statements (exceeds 4 allowed). Open
Open
func (cl ConsentLogic) decryptConsentRecord(cr bridgeClient.ConsentRecord, legalEntity string) (string, error) {
encodedCipherText := cr.CipherText
cipherText, err := base64.StdEncoding.DecodeString(*encodedCipherText)
// convert hex string of attachment to bytes
if err != nil {
Method Wrapper.CreateOrUpdateConsent
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (wrapper Wrapper) CreateOrUpdateConsent(ctx echo.Context) error {
createConsentApiRequest := &CreateConsentRequest{}
if err := ctx.Bind(createConsentApiRequest); err != nil {
ctx.Logger().Error("Could not unmarshal json body:", err)
return 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"