cloudfoundry/stratos

View on GitHub
src/jetstream/main.go

Summary

Maintainability
F
4 days
Test Coverage

File main.go has 891 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package main

import (
    "crypto/sha1"
    "crypto/tls"
Severity: Major
Found in src/jetstream/main.go - About 1 day to fix

    Function main has 183 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func main() {
    
        // Register time.Time in gob
        gob.Register(time.Time{})
    
    
    Severity: Major
    Found in src/jetstream/main.go - About 6 hrs to fix

      Function main has a Cognitive Complexity of 37 (exceeds 8 allowed). Consider refactoring.
      Open

      func main() {
      
          // Register time.Time in gob
          gob.Register(time.Time{})
      
      
      Severity: Minor
      Found in src/jetstream/main.go - About 5 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.registerRoutes has 99 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *portalProxy) registerRoutes(e *echo.Echo, needSetupMiddleware bool) {
          log.Debug("registerRoutes")
      
          e.GET("/swagger/*", echoSwagger.WrapHandler)
      
      
      Severity: Major
      Found in src/jetstream/main.go - About 2 hrs to fix

        Method portalProxy.registerRoutes has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
        Open

        func (p *portalProxy) registerRoutes(e *echo.Echo, needSetupMiddleware bool) {
            log.Debug("registerRoutes")
        
            e.GET("/swagger/*", echoSwagger.WrapHandler)
        
        
        Severity: Minor
        Found in src/jetstream/main.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

        Function newPortalProxy has 63 lines of code (exceeds 50 allowed). Consider refactoring.
        Wontfix

        func newPortalProxy(pc interfaces.PortalConfig, dcp *sql.DB, ss HttpSessionStore, sessionStoreOptions *sessions.Options, env *env.VarSet) *portalProxy {
            log.Debug("newPortalProxy")
        
            // Generate cookie name - avoids issues if the cookie domain is changed
            cookieName := jetstreamSessionName
        Severity: Minor
        Found in src/jetstream/main.go - About 1 hr to fix

          Function start has 62 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func start(config interfaces.PortalConfig, p *portalProxy, needSetupMiddleware bool, isUpgrade bool, envLookup *env.VarSet) error {
              log.Debug("start")
              e := echo.New()
              e.HideBanner = true
              e.HidePort = true
          Severity: Minor
          Found in src/jetstream/main.go - About 1 hr to fix

            Function start has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
            Open

            func start(config interfaces.PortalConfig, p *portalProxy, needSetupMiddleware bool, isUpgrade bool, envLookup *env.VarSet) error {
                log.Debug("start")
                e := echo.New()
                e.HideBanner = true
                e.HidePort = true
            Severity: Minor
            Found in src/jetstream/main.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 echoV2DefaultHTTPErrorHandler has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
            Open

            func echoV2DefaultHTTPErrorHandler(err error, c echo.Context) {
            
                code := http.StatusInternalServerError
                msg := http.StatusText(code)
                if he, ok := err.(*echo.HTTPError); ok {
            Severity: Minor
            Found in src/jetstream/main.go - About 45 mins 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 detectTLSCert has 6 return statements (exceeds 4 allowed).
            Open

            func detectTLSCert(pc interfaces.PortalConfig) (string, string, error) {
                log.Debug("detectTLSCert")
                certFilename := "pproxy.crt"
                certKeyFilename := "pproxy.key"
            
            
            Severity: Major
            Found in src/jetstream/main.go - About 40 mins to fix

              Function newPortalProxy has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func newPortalProxy(pc interfaces.PortalConfig, dcp *sql.DB, ss HttpSessionStore, sessionStoreOptions *sessions.Options, env *env.VarSet) *portalProxy {
              Severity: Minor
              Found in src/jetstream/main.go - About 35 mins to fix

                Function initSessionStore has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func initSessionStore(db *sql.DB, databaseProvider string, pc interfaces.PortalConfig, sessionExpiry int, env *env.VarSet) (HttpSessionStore, *sessions.Options, error) {
                Severity: Minor
                Found in src/jetstream/main.go - About 35 mins to fix

                  Function start has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func start(config interfaces.PortalConfig, p *portalProxy, needSetupMiddleware bool, isUpgrade bool, envLookup *env.VarSet) error {
                  Severity: Minor
                  Found in src/jetstream/main.go - About 35 mins to fix

                    Function detectTLSCert has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
                    Open

                    func detectTLSCert(pc interfaces.PortalConfig) (string, string, error) {
                        log.Debug("detectTLSCert")
                        certFilename := "pproxy.crt"
                        certKeyFilename := "pproxy.key"
                    
                    
                    Severity: Minor
                    Found in src/jetstream/main.go - About 25 mins 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

                    There are no issues that match your filters.

                    Category
                    Status