cloudfoundry/stratos

View on GitHub
src/jetstream/setup_console.go

Summary

Maintainability
C
1 day
Test Coverage

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 {
Severity: Minor
Found in src/jetstream/setup_console.go - About 2 hrs to fix

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 {
Severity: Minor
Found in src/jetstream/setup_console.go - About 1 hr to fix

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)
Severity: Minor
Found in src/jetstream/setup_console.go - About 1 hr to fix

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
Severity: Major
Found in src/jetstream/setup_console.go - About 50 mins to fix

    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)
                }
    Severity: Major
    Found in src/jetstream/setup_console.go - About 45 mins to fix

      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)
      Severity: Major
      Found in src/jetstream/setup_console.go - About 45 mins to fix

        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)
        Severity: Major
        Found in src/jetstream/setup_console.go - About 40 mins to fix

          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 {
          Severity: Major
          Found in src/jetstream/setup_console.go - About 40 mins to fix

            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 {
            Severity: Major
            Found in src/jetstream/setup_console.go - About 40 mins to fix

              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")
              Severity: Major
              Found in src/jetstream/setup_console.go - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status