cloudfoundry-incubator/stratos

View on GitHub

Showing 650 of 1,370 total issues

Avoid deeply nested control flow statements.
Open

                        if err == nil {
                            isValid, err := k.PortalProxy.GetSessionDataStore().IsValidSession(i)
                            if err == nil && !isValid {
                                log.Debugf("Deleting secret %s", secret.Name)
                                secretClient.Delete(secret.Name, nil)
Severity: Major
Found in src/jetstream/plugins/kubernetes/terminal/cleanup.go - About 45 mins to fix

    Method HelmRelease.UpdatePods has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
    Open

    func (r *HelmRelease) UpdatePods(jetstream interfaces.PortalProxy) {
        var jobs []KubeResourceJob
        for _, job := range r.PodJobs {
            jobs = append(jobs, job)
        }
    Severity: Minor
    Found in src/jetstream/plugins/kubernetes/helm/release.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

    Method KubernetesSpecification.UpgradeRelease has 7 return statements (exceeds 4 allowed).
    Open

    func (c *KubernetesSpecification) UpgradeRelease(ec echo.Context) error {
        endpointGUID := ec.Param("endpoint")
        releaseName := ec.Param("name")
        namespace := ec.Param("namespace")
    
    
    Severity: Major
    Found in src/jetstream/plugins/kubernetes/install_release.go - About 45 mins to fix

      Method CFAppPush.getGitSCMSource has 7 return statements (exceeds 4 allowed).
      Open

      func (cfAppPush *CFAppPush) getGitSCMSource(clientWebSocket *websocket.Conn, tempDir string, msg SocketMessage, userGUID string) (StratosProject, string, error) {
          var (
              err error
          )
      
      
      Severity: Major
      Found in src/jetstream/plugins/cfapppush/deploy.go - About 45 mins to fix

        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 KubeDashboardLogin has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
        Open

        func KubeDashboardLogin(c echo.Context, p interfaces.PortalProxy) error {
            log.Debug("kubeDashboardLogin request")
        
            endpointGUID := c.Param("guid")
            userGUID := c.Get("user_id").(string)
        Severity: Minor
        Found in src/jetstream/plugins/kubernetes/dashboard/login.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

        Method CFPushApp.Run has 7 return statements (exceeds 4 allowed).
        Open

        func (c *CFPushApp) Run(msgSender DeployAppMessageSender, clientWebsocket *websocket.Conn) error {
        
            // Get a CF Config
            config, err := configv3.LoadConfig()
            if err != nil {
        Severity: Major
        Found in src/jetstream/plugins/cfapppush/pushapp.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if err == nil {
                                      isValid, err := k.PortalProxy.GetSessionDataStore().IsValidSession(i)
                                      if err == nil && !isValid {
                                          log.Debugf("Deleting pod %s", pod.Name)
                                          podClient.Delete(pod.Name, nil)
          Severity: Major
          Found in src/jetstream/plugins/kubernetes/terminal/cleanup.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if strings.HasPrefix(err.Error(), "no kind") {
                                    var t interface{}
                                    if err := yaml.Unmarshal(data, &t); err == nil {
                                        r.processYamlResource(t, data)
                                    } else {
            Severity: Major
            Found in src/jetstream/plugins/kubernetes/helm/release.go - About 45 mins to fix

              Method LocalUserInfo.UpdatePassword has 7 return statements (exceeds 4 allowed).
              Open

              func (userInfo *LocalUserInfo) UpdatePassword(id string, passwordInfo *passwordChangeInfo) (int, error) {
              
                  // Fetch the user, make updates and save
                  localUsersRepo, err := localusers.NewPgsqlLocalUsersRepository(userInfo.portalProxy.GetDatabaseConnection())
                  if err != nil {
              Severity: Major
              Found in src/jetstream/plugins/userinfo/local_user.go - About 45 mins to fix

                Function makePrometheusRequestInfos has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func makePrometheusRequestInfos(c echo.Context, userGUID string, metrics map[string]EndpointMetricsRelation, prometheusOp string, queries string, addJob bool) []interfaces.ProxyRequestInfo {
                Severity: Minor
                Found in src/jetstream/plugins/metrics/cloud_foundry.go - About 45 mins to fix

                  Method CloudFoundrySpecification.openNoaaConsumer has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
                  Open

                  func (c CloudFoundrySpecification) openNoaaConsumer(echoContext echo.Context) (*AuthorizedConsumer, error) {
                  
                      ac := &AuthorizedConsumer{}
                  
                      // Get the CNSI and app IDs from route parameters
                  Severity: Minor
                  Found in src/jetstream/plugins/cloudfoundry/cf_websocket_streams.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

                  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

                    Function NewDatabaseConnectionParametersFromConfig has 7 return statements (exceeds 4 allowed).
                    Open

                    func NewDatabaseConnectionParametersFromConfig(dc DatabaseConfig) (DatabaseConfig, error) {
                    
                        if len(dc.DatabaseProvider) == 0 {
                            dc.DatabaseProvider = DefaultDatabaseProvider
                        }
                    Severity: Major
                    Found in src/jetstream/datastore/datastore.go - About 45 mins to fix

                      Function updateCFFIle has 7 return statements (exceeds 4 allowed).
                      Open

                      func updateCFFIle(updates map[string]string) error {
                          usr, err := user.Current()
                          if err != nil {
                              return err
                          }
                      Severity: Major
                      Found in src/jetstream/plugins/desktop/kubernetes/kubeconfig.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if strings.HasPrefix(authToken, "bearer ") {
                                                authToken = authToken[7:]
                                            }
                        Severity: Major
                        Found in src/jetstream/plugins/desktop/tokens.go - About 45 mins to fix

                          Method PostgresCNSIRepository.ListByUser has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
                          Open

                          func (p *PostgresCNSIRepository) ListByUser(userGUID string) ([]*interfaces.ConnectedEndpoint, error) {
                              log.Debug("ListByUser")
                              rows, err := p.db.Query(listCNSIsByUser, "cnsi", userGUID)
                              if err != nil {
                                  return nil, fmt.Errorf("Unable to retrieve CNSI records: %v", err)
                          Severity: Minor
                          Found in src/jetstream/repository/cnsis/pgsql_cnsis.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 updateCFFIle has 7 return statements (exceeds 4 allowed).
                          Open

                          func updateCFFIle(updates map[string]string) error {
                              usr, err := user.Current()
                              if err != nil {
                                  return err
                              }
                          Severity: Major
                          Found in src/jetstream/plugins/desktop/cloudfoundry.go - About 45 mins to fix

                            Function SetStructFieldValue has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
                            Open

                            func SetStructFieldValue(value reflect.Value, field reflect.Value, val string) error {
                            
                                var newVal interface{}
                                var err error
                                typ := field.Type()
                            Severity: Minor
                            Found in src/jetstream/repository/interfaces/config/config.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

                            Method portalProxy.buildCNSIRequest has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            func (p *portalProxy) buildCNSIRequest(cnsiGUID string, userGUID string, method string, uri *url.URL, body []byte, header http.Header) (interfaces.CNSIRequest, error) {
                            Severity: Minor
                            Found in src/jetstream/passthrough.go - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language