cloudfoundry/stratos

View on GitHub

Showing 1,155 of 1,370 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
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 and 1 other location - About 3 hrs to fix
src/jetstream/plugins/desktop/kubernetes/kubeconfig.go on lines 144..184

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

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

func (a *Analyzer) doRun(ec echo.Context) error {

    log.Debug("Run analyzer!")

    engine := ec.Param("analyzer")
Severity: Minor
Found in src/jetstream/plugins/analysis/container/run.go - About 3 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 ngOnInit has a Cognitive Complexity of 28 (exceeds 8 allowed). Consider refactoring.
Open

  ngOnInit() {
    this.hasFavEntities = this.userFavoriteManager.endpointHasEntitiesThatCanFavorite(this.endpoint.cnsi_type);
    // Favorites for this endpoint
    this.favorites$ = this.userFavoriteManager.getFavoritesForEndpoint(this.endpoint.guid);
    this.entity = entityCatalog.getEndpoint(this.endpoint.cnsi_type, this.endpoint.sub_type);

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

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

describe('KubernetesNodeIpsComponent', () => {
  let component: KubernetesNodeIpsComponent;
  let fixture: ComponentFixture<KubernetesNodeIpsComponent>;

  beforeEach(async(() => {
src/frontend/packages/kubernetes/src/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.spec.ts on lines 6..47
src/frontend/packages/kubernetes/src/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.spec.ts on lines 6..47

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

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 3 locations. Consider refactoring.
Open

describe('KubernetesNodeLabelsComponent', () => {
  let component: KubernetesNodeLabelsComponent;
  let fixture: ComponentFixture<KubernetesNodeLabelsComponent>;

  beforeEach(async(() => {
src/frontend/packages/kubernetes/src/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.spec.ts on lines 6..47
src/frontend/packages/kubernetes/src/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.spec.ts on lines 6..47

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

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 3 locations. Consider refactoring.
Open

describe('KubernetesNodePressureComponent', () => {
  let component: KubernetesNodePressureComponent;
  let fixture: ComponentFixture<KubernetesNodePressureComponent>;

  beforeEach(async(() => {
src/frontend/packages/kubernetes/src/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.spec.ts on lines 6..47
src/frontend/packages/kubernetes/src/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.spec.ts on lines 6..47

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

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

File deploy.go has 562 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package cfapppush

import (
    "encoding/base64"
    "encoding/json"
Severity: Minor
Found in src/jetstream/plugins/cfapppush/deploy.go - About 3 hrs to fix

    Function constructor has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(
        ext: ExtensionService,
        private store: Store<GeneralEntityAppState>,
        eventService: GlobalEventService,
        private userFavoriteManager: UserFavoriteManager,
    Severity: Major
    Found in src/frontend/packages/core/src/app.module.ts - About 3 hrs to fix

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

      package cfappssh
      
      import (
          "errors"
      
      
      Severity: Major
      Found in src/jetstream/plugins/cfappssh/main.go and 1 other location - About 3 hrs to fix
      src/jetstream/plugins/cfapppush/main.go on lines 1..54

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

      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

      package cfapppush
      
      import (
          "errors"
      
      
      Severity: Major
      Found in src/jetstream/plugins/cfapppush/main.go and 1 other location - About 3 hrs to fix
      src/jetstream/plugins/cfappssh/main.go on lines 1..54

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

      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

            inject([Store], (iStore: Store<InternalAppState>) => {
              const dispatchSpy = spyOn(iStore, 'dispatch').and.callThrough();
      
              const res = validateEntityRelations({
                cfGuid,
      src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations-validate.spec.ts on lines 128..149

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

      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

          function testSortBy(sortFieldName: string) {
            const sortFieldForm = spaceList.header.getSortFieldForm();
            sortFieldForm.fill({ 'sort-field': sortFieldName });
      
            let expectedTitleOrder: string[];
      Severity: Major
      Found in src/test-e2e/cloud-foundry/org-level/org-spaces-e2e.spec.ts and 1 other location - About 3 hrs to fix
      src/test-e2e/applications/application-wall-e2e.spec.ts on lines 173..192

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

      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

          function testSortBy(sortFieldName: string) {
            const sortFieldForm = appList.header.getSortFieldForm();
            sortFieldForm.fill({ 'sort-field': sortFieldName });
      
            let expectedTitleOrder: string[];
      Severity: Major
      Found in src/test-e2e/applications/application-wall-e2e.spec.ts and 1 other location - About 3 hrs to fix
      src/test-e2e/cloud-foundry/org-level/org-spaces-e2e.spec.ts on lines 126..145

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

      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

          inject([Store], (iStore: Store<CFAppState>) => {
            const dispatchSpy = spyOn(iStore, 'dispatch').and.callThrough();
      
            const res = validateEntityRelations({
              cfGuid,
      src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations-validate.spec.ts on lines 325..347

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

      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

      File cf-entity-factory.ts has 310 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { EntitySchema } from '../../store/src/helpers/entity-schema';
      import { metricEntityType } from '../../store/src/helpers/stratos-entity-factory';
      import { APIResource } from '../../store/src/types/api.types';
      import {
        CFApplicationEntitySchema,
      Severity: Minor
      Found in src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts - About 3 hrs to fix

        File deploy-application-step2.component.ts has 310 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { HttpClient } from '@angular/common/http';
        import { AfterContentInit, Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
        import { NgForm } from '@angular/forms';
        import { ActivatedRoute } from '@angular/router';
        import { Store } from '@ngrx/store';

          Function hash has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static hash( string: any ) : string
            {
                let temp: string;
          
                if ( typeof string !== 'string' )
          Severity: Major
          Found in src/frontend/packages/core/src/shared/components/user-avatar/md5.ts - About 3 hrs to fix

            Function InstallDashboard has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
            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: Minor
            Found in src/jetstream/plugins/kubernetes/dashboard/configure.go - About 3 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 update has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              update(): void {
                let width;
                if (this.series.length) {
                  width = this.xScale.bandwidth();
                  this.bandwidth.emit(width);

              ListDataSource has 28 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export abstract class ListDataSource<T, A = T> extends DataSource<T> implements IListDataSource<T> {
              
                // -------------- Public
                // Core observables
                public pagination$: Observable<PaginationEntityState>;
                Severity
                Category
                Status
                Source
                Language