Method portalProxy.updateEndpoint
has a Cognitive Complexity of 45 (exceeds 8 allowed). Consider refactoring. Open
func (p *portalProxy) updateEndpoint(ec echo.Context) error {
log.Debug("updateEndpoint")
params := new(interfaces.UpdateEndpointParams)
if err := ec.Bind(params); 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"
Further reading
File cnsi.go
has 660 lines of code (exceeds 500 allowed). Consider refactoring. Open
package main
import (
"crypto/x509"
"encoding/json"
Method portalProxy.DoRegisterEndpoint
has a Cognitive Complexity of 36 (exceeds 8 allowed). Consider refactoring. Wontfix
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, createSystemEndpoint bool, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
log.Debug("DoRegisterEndpoint")
if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
- 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 portalProxy.buildCNSIList
has a Cognitive Complexity of 35 (exceeds 8 allowed). Consider refactoring. Open
func (p *portalProxy) buildCNSIList(c echo.Context) ([]*interfaces.CNSIRecord, error) {
log.Debug("buildCNSIList")
if p.GetConfig().UserEndpointsEnabled != config.UserEndpointsConfigEnum.Disabled {
userID, err := p.GetSessionValue(c, "user_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 portalProxy.DoRegisterEndpoint
has 101 lines of code (exceeds 50 allowed). Consider refactoring. Wontfix
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, createSystemEndpoint bool, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
log.Debug("DoRegisterEndpoint")
if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
portalProxy
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
func (p *portalProxy) RegisterEndpoint(c echo.Context, fetchInfo interfaces.InfoFunc) error {
log.Debug("registerEndpoint")
params := new(interfaces.RegisterEndpointParams)
err := interfaces.BindOnce(params, c)
Method portalProxy.updateEndpoint
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *portalProxy) updateEndpoint(ec echo.Context) error {
log.Debug("updateEndpoint")
params := new(interfaces.UpdateEndpointParams)
if err := ec.Bind(params); err != nil {
Method portalProxy.DoRegisterEndpoint
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, createSystemEndpoint bool, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
Method portalProxy.DoRegisterEndpoint
has 10 return statements (exceeds 4 allowed). Open
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, createSystemEndpoint bool, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
log.Debug("DoRegisterEndpoint")
if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
Method portalProxy.updateEndpoint
has 9 return statements (exceeds 4 allowed). Open
func (p *portalProxy) updateEndpoint(ec echo.Context) error {
log.Debug("updateEndpoint")
params := new(interfaces.UpdateEndpointParams)
if err := ec.Bind(params); err != nil {
Avoid deeply nested control flow statements. Open
if err != nil {
if ok, detail := isSSLRelatedError(err); ok {
return interfaces.NewHTTPShadowError(
http.StatusForbidden,
"SSL error - "+detail,
Avoid deeply nested control flow statements. Open
if err != nil {
return fmt.Errorf("Can not get endpoint type for %s: '%v'", endpoint.CNSIType, err)
}
Method portalProxy.buildCNSIList
has 6 return statements (exceeds 4 allowed). Open
func (p *portalProxy) buildCNSIList(c echo.Context) ([]*interfaces.CNSIRecord, error) {
log.Debug("buildCNSIList")
if p.GetConfig().UserEndpointsEnabled != config.UserEndpointsConfigEnum.Disabled {
userID, err := p.GetSessionValue(c, "user_id")
Method portalProxy.listRegisteredCNSIs
has 5 return statements (exceeds 4 allowed). Open
func (p *portalProxy) listRegisteredCNSIs(c echo.Context) error {
log.Debug("listRegisteredCNSIs")
userGUIDIntf, err := p.GetSessionValue(c, "user_id")
if err != nil {
return interfaces.NewHTTPShadowError(
TODO found Open
// TODO (wchrisjohnson) We need do this as a TRANSACTION, vs a set of single calls
- Exclude checks