cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

Function InstallDashboard has 8 return statements (exceeds 4 allowed).
Open

func InstallDashboard(p interfaces.PortalProxy, endpointGUID, userGUID string) error {
    // Download the Yaml for the dashboard
    kubeDashboardImage := p.Env().String("STRATOS_KUBERNETES_DASHBOARD_IMAGE", "")
    if len(kubeDashboardImage) == 0 {
        kubeDashboardImage = dashboardInstallYAMLDownloadURL
Severity: Major
Found in src/jetstream/plugins/kubernetes/dashboard/configure.go - About 50 mins to fix

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      describe('EditAutoscalerPolicyStep1Component', () => {
        let component: EditAutoscalerPolicyStep1Component;
        let fixture: ComponentFixture<EditAutoscalerPolicyStep1Component>;
      
        beforeEach(async(() => {
      src/frontend/packages/cf-autoscaler/src/features/autoscaler-metric-page/autoscaler-metric-page.component.spec.ts on lines 16..52

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 206.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      describe('PodMetricsComponent', () => {
        let component: PodMetricsComponent;
        let fixture: ComponentFixture<PodMetricsComponent>;
      
        beforeEach(async(() => {
      src/frontend/packages/kubernetes/src/kubernetes/kubernetes-tab-base/kubernetes-tab-base.component.spec.ts on lines 8..43

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 206.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      describe('AutoscalerMetricPageComponent', () => {
        let component: AutoscalerMetricPageComponent;
        let fixture: ComponentFixture<AutoscalerMetricPageComponent>;
      
        beforeEach(async(() => {
      src/frontend/packages/cf-autoscaler/src/features/edit-autoscaler-policy/edit-autoscaler-policy-step1/edit-autoscaler-policy-step1.component.spec.ts on lines 16..52

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 206.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      describe('KubernetesTabBaseComponent', () => {
        let component: KubernetesTabBaseComponent;
        let fixture: ComponentFixture<KubernetesTabBaseComponent>;
      
        beforeEach(async(() => {
      src/frontend/packages/kubernetes/src/kubernetes/pod-metrics/pod-metrics.component.spec.ts on lines 9..44

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 206.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func mergeEndpoints(first, second []*interfaces.CNSIRecord) []*interfaces.CNSIRecord {
      
          if first == nil {
              return second
          }
      Severity: Minor
      Found in src/jetstream/plugins/desktop/endpoints.go and 1 other location - About 45 mins to fix
      src/jetstream/plugins/desktop/endpoints.go on lines 114..141

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 217.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func mergeConnectedEndpoints(first, second []*interfaces.ConnectedEndpoint) []*interfaces.ConnectedEndpoint {
      
          if first == nil {
              return second
          }
      Severity: Minor
      Found in src/jetstream/plugins/desktop/endpoints.go and 1 other location - About 45 mins to fix
      src/jetstream/plugins/desktop/endpoints.go on lines 84..111

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 217.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

        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 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

            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

              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

                Method GKEKubeAuth.FetchToken has 7 return statements (exceeds 4 allowed).
                Open

                func (c *GKEKubeAuth) FetchToken(cnsiRecord interfaces.CNSIRecord, ec echo.Context) (*interfaces.TokenRecord, *interfaces.CNSIRecord, error) {
                    log.Debug("FetchToken (GKE)")
                
                    // We should already have the refresh token in the body sent to us
                    req := ec.Request()
                Severity: Major
                Found in src/jetstream/plugins/kubernetes/auth/gke.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 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

                    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

                      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

                        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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language