cloudfoundry/stratos

View on GitHub

Showing 718 of 1,370 total issues

Method Monocular.artifactHubCacheChartFiles has 5 return statements (exceeds 4 allowed).
Open

func (m *Monocular) artifactHubCacheChartFiles(endpointID, repoName, repoURL, name, version, digest string) (string, error) {

    // First look to see if there is a digest file
    cacheFolder := path.Join(m.CacheFolder, endpointID, fmt.Sprintf("%s_%s_%s", repoName, name, version))
    if hasDigestFile(cacheFolder, digest) {
Severity: Major
Found in src/jetstream/plugins/monocular/artifacthub.go - About 35 mins to fix

    Method LocalUserInfo.UpdateUserInfo has 5 return statements (exceeds 4 allowed).
    Open

    func (userInfo *LocalUserInfo) UpdateUserInfo(profile *uaaUser) (int, error) {
    
        // Fetch the user, make updates and save
        id := profile.ID
        localUsersRepo, err := localusers.NewPgsqlLocalUsersRepository(userInfo.portalProxy.GetDatabaseConnection())
    Severity: Major
    Found in src/jetstream/plugins/userinfo/local_user.go - About 35 mins to fix

      Method Analyzer.Start has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
      Open

      func (a *Analyzer) Start() {
      
          // Reports folder
      
          // Init reports directory
      Severity: Minor
      Found in src/jetstream/plugins/analysis/container/main.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 MetricsSpecification.createMetadata has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
      Open

      func (m *MetricsSpecification) createMetadata(metricEndpoint *url.URL, httpClient http.Client, auth *MetricsAuth) (string, error) {
          basicMetricRequest := fmt.Sprintf("%s/api/v1/query?query=firehose_total_metrics_received", metricEndpoint)
          req, err := http.NewRequest("GET", basicMetricRequest, nil)
          if err != nil {
              msg := "Failed to create request for the Metrics Endpoint: %v"
      Severity: Minor
      Found in src/jetstream/plugins/metrics/main.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 SemanticVersion.LessThan has 5 return statements (exceeds 4 allowed).
      Open

      func (s *SemanticVersion) LessThan(d *SemanticVersion) bool {
          if d == nil {
              return true
          }
          if s.Valid && d.Valid {
      Severity: Major
      Found in src/jetstream/plugins/monocular/store/version.go - About 35 mins to fix

        Method HelmReleaseGraph.ProcessService has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
        Open

        func (r *HelmReleaseGraph) ProcessService(id string, res KubeResource, spec v1.ServiceSpec) {
            if len(spec.Selector) > 0 {
                // Find all Pods that match this selector
                for _, item := range r.Release.Resources {
                    switch o := item.Resource.(type) {
        Severity: Minor
        Found in src/jetstream/plugins/kubernetes/helm/graph.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 UserInvite.SendEmail has 5 return statements (exceeds 4 allowed).
        Open

        func (invite *UserInvite) SendEmail(emailAddress, inviteLink string, endpoint interfaces.CNSIRecord) error {
            log.Debugf("User Invite: Sending Email to: %s", emailAddress)
            mailHost := fmt.Sprintf("%s:%d", invite.Config.SMTP.Host, invite.Config.SMTP.Port)
        
            var auth smtp.Auth
        Severity: Major
        Found in src/jetstream/plugins/userinvite/email.go - About 35 mins to fix

          Function getScriptFolder has 5 return statements (exceeds 4 allowed).
          Open

          func getScriptFolder() string {
              fallbackPath, err := os.Getwd()
              if err != nil {
                  fallbackPath = "."
              }
          Severity: Major
          Found in src/jetstream/plugins/analysis/container/main.go - About 35 mins to fix

            Method Analysis.doRunReport has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
            Open

            func (c *Analysis) doRunReport(ec echo.Context, analyzer, endpointID, userID string, dbStore store.AnalysisStore, report *store.AnalysisRecord) error {
            
                // Get Kube Config
                k8s := c.portalProxy.GetPlugin("kubernetes")
                if k8s == nil {
            Severity: Minor
            Found in src/jetstream/plugins/analysis/run.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 Analysis.deleteReports has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
            Open

            func (c *Analysis) deleteReports(ec echo.Context) error {
                log.Debug("deleteReports")
                var p = c.portalProxy
            
                // Need to get a config object for the target endpoint
            Severity: Minor
            Found in src/jetstream/plugins/analysis/list.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 KubeTerminal.createPod has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
            Open

            func (k *KubeTerminal) createPod(c echo.Context, kubeConfig, kubeVersion string, ws *websocket.Conn) (*PodCreationData, error) {
                // Unique ID for the secret and pod name
                id := uuid.NewV4().String()
                id = strings.ReplaceAll(id, "-", "")
                // Names for the secret and pod
            Severity: Minor
            Found in src/jetstream/plugins/kubernetes/terminal/helpers.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 Monocular.fetchChartsFromArtifactHub has 5 return statements (exceeds 4 allowed).
            Open

            func (m *Monocular) fetchChartsFromArtifactHub(c echo.Context, endpointID string) error {
                cacheFolder := path.Join(m.CacheFolder, endpointID)
                indexFile := path.Join(cacheFolder, "hub_index.json")
                if ok := useCachedFile(indexFile); ok {
                    // Just send the cached file
            Severity: Major
            Found in src/jetstream/plugins/monocular/artifacthub.go - About 35 mins to fix

              Method Monocular.getChartURL has 5 return statements (exceeds 4 allowed).
              Open

              func (m *Monocular) getChartURL(repoURL, name, version string) (string, error) {
                  httpClient := m.portalProxy.GetHttpClient(true)
              
                  helmIndexURL := joinURL(repoURL, "index.yaml")
                  resp, err := httpClient.Get(helmIndexURL)
              Severity: Major
              Found in src/jetstream/plugins/monocular/artifacthub.go - About 35 mins to fix

                Method UserInvite.processUserInvite has 5 return statements (exceeds 4 allowed).
                Open

                func (invite *UserInvite) processUserInvite(cfGUID, userGUID string, userInviteRequest *UserInviteReq, user UserInviteUser, endpoint interfaces.CNSIRecord) (UserInviteUser, bool) {
                    log.Debugf("Creating CF User for: %s", user.Email)
                    // Create the user in Cloud Foundry
                    if cfError, err := invite.CreateCloudFoundryUser(cfGUID, userGUID, user.UserID); err != nil {
                        return updateUserInviteRecordForError(user, "Failed to create user in Cloud Foundry", cfError), true
                Severity: Major
                Found in src/jetstream/plugins/userinvite/invite.go - About 35 mins to fix

                  Function getKubeDashboardSecretToken has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
                  Open

                  func getKubeDashboardSecretToken(p interfaces.PortalProxy, cnsiGUID, userGUID string, sa *v1.ServiceAccount) (string, error) {
                      log.Debug("getKubeDashboardSecretToken request")
                  
                      namespace := sa.Namespace
                  
                  
                  Severity: Minor
                  Found in src/jetstream/plugins/kubernetes/dashboard/common.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

                    Function getKubeDashboardService has 5 return statements (exceeds 4 allowed).
                    Open

                    func getKubeDashboardService(p interfaces.PortalProxy, cnsiGUID, userGUID string, labelSelector string) (ServiceInfo, error) {
                        log.Debug("getKubeDashboardService request")
                    
                        info := ServiceInfo{}
                        response, err := p.DoProxySingleRequest(cnsiGUID, userGUID, "GET", "/api/v1/services?labelSelector="+labelSelector, nil, nil)
                    Severity: Major
                    Found in src/jetstream/plugins/kubernetes/dashboard/common.go - About 35 mins to fix

                      Method CFHosting.Init has 5 return statements (exceeds 4 allowed).
                      Open

                      func (ch *CFHosting) Init() error {
                      
                          // Determine if we are running CF by presence of env var "VCAP_APPLICATION" and configure appropriately
                          if ch.portalProxy.Env().IsSet(VCapApplication) {
                              log.Info("Detected that Console is deployed as a Cloud Foundry Application")
                      Severity: Major
                      Found in src/jetstream/plugins/cloudfoundryhosting/main.go - About 35 mins to fix

                        Method portalProxy.loginToCNSI has 5 return statements (exceeds 4 allowed).
                        Open

                        func (p *portalProxy) loginToCNSI(c echo.Context) error {
                            log.Debug("loginToCNSI")
                        
                            var systemSharedToken = false
                        
                        
                        Severity: Major
                        Found in src/jetstream/authcnsi.go - About 35 mins to fix

                          Function init has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
                          Open

                          func init() {
                              RegisterMigration(20191008121900, "PrimaryKeys", func(txn *sql.Tx, conf *goose.DBConf) error {
                          
                                  // Make sure all tokens have a CNSI guid
                                  ensureTokensHaveCnsi := "UPDATE tokens SET cnsi_guid='STRATOS' WHERE token_type='uaa' and cnsi_guid IS NULL;"
                          Severity: Minor
                          Found in src/jetstream/datastore/20191008121900_PrimaryKeys.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

                          Severity
                          Category
                          Status
                          Source
                          Language