src/jetstream/cnsi.go
Method portalProxy.updateEndpoint
has a Cognitive Complexity of 45 (exceeds 8 allowed). Consider refactoring. Open
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
Method portalProxy.updateEndpoint
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *portalProxy) updateEndpoint(ec echo.Context) error {
log.Debug("updateEndpoint")
params := new(interfaces.UpdateEndpointParams)
if err := ec.Bind(params); err != nil {
portalProxy
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
func (p *portalProxy) RegisterEndpoint(c echo.Context, fetchInfo interfaces.InfoFunc) error {
log.Debug("registerEndpoint")
params := new(interfaces.RegisterEndpointParams)
err := interfaces.BindOnce(params, c)
File cnsi.go
has 517 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package main
import (
"crypto/x509"
"encoding/json"
Method portalProxy.DoRegisterEndpoint
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, ssoAllowed bool, subType string, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
http.StatusBadRequest,
Method portalProxy.DoRegisterEndpoint
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, ssoAllowed bool, subType string, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
Method portalProxy.updateEndpoint
has 9 return statements (exceeds 4 allowed). Open
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
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
Open
if err != nil {
return fmt.Errorf("Can not get endpoint type for %s: '%v'", endpoint.CNSIType, err)
}
Method portalProxy.DoRegisterEndpoint
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, ssoAllowed bool, subType string, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
http.StatusBadRequest,
Method portalProxy.DoRegisterEndpoint
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
Open
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, ssoAllowed bool, subType string, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
http.StatusBadRequest,
- 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.listRegisteredCNSIs
has 5 return statements (exceeds 4 allowed). Open
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
Open
// TODO (wchrisjohnson) We need do this as a TRANSACTION, vs a set of single calls
- Exclude checks