Method portalProxy.SetupMiddleware
has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring. Open
func (p *portalProxy) SetupMiddleware() echo.MiddlewareFunc {
return func(h echo.HandlerFunc) echo.HandlerFunc {
if !setupComplete {
- 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.initialiseConsoleConfig
has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring. Open
func (p *portalProxy) initialiseConsoleConfig(envLookup *env.VarSet) (*interfaces.ConsoleConfig, error) {
log.Debug("initialiseConsoleConfig")
consoleConfig := &interfaces.ConsoleConfig{}
if err := config.Load(consoleConfig, envLookup.Lookup); 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.setupGetAvailableScopes
has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring. Open
func (p *portalProxy) setupGetAvailableScopes(c echo.Context) error {
// Check if already set up
if p.GetConfig().ConsoleConfig.IsSetupComplete() {
return c.NoContent(http.StatusServiceUnavailable)
- 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 saveUAAConsoleConfig
has 8 return statements (exceeds 4 allowed). Open
func saveUAAConsoleConfig(consoleRepo console_config.Repository, consoleConfig *interfaces.ConsoleConfig) error {
log.Debugf("Saving ConsoleConfig: %+v", consoleConfig)
if err := consoleRepo.SetValue(systemGroupName, "UAA_ENDPOINT", consoleConfig.UAAEndpoint.String()); err != nil {
return err
Method portalProxy.setupGetAvailableScopes
has 7 return statements (exceeds 4 allowed). Open
func (p *portalProxy) setupGetAvailableScopes(c echo.Context) error {
// Check if already set up
if p.GetConfig().ConsoleConfig.IsSetupComplete() {
return c.NoContent(http.StatusServiceUnavailable)
Avoid deeply nested control flow statements. Open
if consoleConfig.AuthorizationEndpoint == nil {
// No Authorization endpoint
consoleConfig.AuthorizationEndpoint = consoleConfig.UAAEndpoint
log.Debugf("Using UAA Endpoint for Auth Endpoint: %s", consoleConfig.AuthorizationEndpoint)
}
Function saveLocalUserConsoleConfig
has 6 return statements (exceeds 4 allowed). Open
func saveLocalUserConsoleConfig(consoleRepo console_config.Repository, consoleConfig *interfaces.ConsoleConfig) error {
log.Debug("saveLocalUserConsoleConfig")
if err := consoleRepo.SetValue(systemGroupName, "AUTH_ENDPOINT_TYPE", "local"); err != nil {
Method portalProxy.setupSaveConfig
has 6 return statements (exceeds 4 allowed). Open
func (p *portalProxy) setupSaveConfig(c echo.Context) error {
log.Debug("setupSaveConfig")
consoleRepo, err := console_config.NewPostgresConsoleConfigRepository(p.DatabaseConnectionPool)
Method portalProxy.initialiseConsoleConfig
has 6 return statements (exceeds 4 allowed). Open
func (p *portalProxy) initialiseConsoleConfig(envLookup *env.VarSet) (*interfaces.ConsoleConfig, error) {
log.Debug("initialiseConsoleConfig")
consoleConfig := &interfaces.ConsoleConfig{}
if err := config.Load(consoleConfig, envLookup.Lookup); err != nil {
Function parseConsoleConfigFromForm
has 5 return statements (exceeds 4 allowed). Open
func parseConsoleConfigFromForm(c echo.Context) (*interfaces.ConsoleConfig, error) {
consoleConfig := new(interfaces.ConsoleConfig)
// Local admin user configuration?
password := c.FormValue("local_admin_password")