SUSE/stratos

View on GitHub
src/jetstream/cnsi.go

Summary

Maintainability
D
2 days
Test Coverage

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

    portalProxy has 23 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)
    Severity: Minor
    Found in src/jetstream/cnsi.go - About 2 hrs to fix

      File cnsi.go has 517 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package main
      
      import (
          "crypto/x509"
          "encoding/json"
      Severity: Minor
      Found in src/jetstream/cnsi.go - About 2 hrs to fix

        Method portalProxy.DoRegisterEndpoint has 55 lines of code (exceeds 50 allowed). Consider refactoring.
        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,
        Severity: Minor
        Found in src/jetstream/cnsi.go - About 1 hr to fix

          Method portalProxy.DoRegisterEndpoint has 8 arguments (exceeds 4 allowed). Consider refactoring.
          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) {
          Severity: Major
          Found in src/jetstream/cnsi.go - About 1 hr to fix

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

              Avoid deeply nested control flow statements.
              Open

                                  if err != nil {
                                      if ok, detail := isSSLRelatedError(err); ok {
                                          return interfaces.NewHTTPShadowError(
                                              http.StatusForbidden,
                                              "SSL error - "+detail,
              Severity: Major
              Found in src/jetstream/cnsi.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if err != nil {
                                        return fmt.Errorf("Can not get endpoint type for %s: '%v'", endpoint.CNSIType, err)
                                    }
                Severity: Major
                Found in src/jetstream/cnsi.go - About 45 mins to fix

                  Method portalProxy.DoRegisterEndpoint has 6 return statements (exceeds 4 allowed).
                  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,
                  Severity: Major
                  Found in src/jetstream/cnsi.go - About 40 mins to fix

                    Method portalProxy.DoRegisterEndpoint has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
                    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,
                    Severity: Minor
                    Found in src/jetstream/cnsi.go - About 35 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

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

                      TODO found
                      Open

                      // TODO (wchrisjohnson) We need do this as a TRANSACTION, vs a set of single calls
                      Severity: Minor
                      Found in src/jetstream/cnsi.go by fixme

                      There are no issues that match your filters.

                      Category
                      Status