cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

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

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

    export class PageAutoscalerEventBase extends Page {
    
      list: ListComponent;
    
      constructor(public cfGuid: string, public appGuid: string) {
    Severity: Major
    Found in src/test-e2e/application/po/page-autoscaler-event-base.po.ts and 1 other location - About 3 hrs to fix
    src/test-e2e/application/po/page-autoscaler-metric-base.po.ts on lines 6..29

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

    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

    export class PageAutoscalerMetricBase extends Page {
    
      list: ListComponent;
    
      constructor(public cfGuid: string, public appGuid: string) {
    src/test-e2e/application/po/page-autoscaler-event-base.po.ts on lines 6..29

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

    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

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

    export class CfUserPermissionsChecker extends BaseCurrentUserPermissionsChecker implements ICurrentUserPermissionsChecker {
      static readonly ALL_SPACES = 'PERMISSIONS__ALL_SPACES_PLEASE';
    
      constructor(private store: Store<GeneralEntityAppState>) {
        super();

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

        Function getDefaultInitialTestStratosStoreState has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getDefaultInitialTestStratosStoreState() {
          return {
            recentlyVisited: {},
            userFavoritesGroups: {
              busy: false,
        Severity: Major
        Found in src/frontend/packages/store/testing/src/store-test-helper.ts - About 3 hrs to fix

          Function start has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public start() {
              if (this.isStarted()) {
                return;
              }
          
          

            Method MetricsSpecification.getMetricsEndpoints has a Cognitive Complexity of 26 (exceeds 8 allowed). Consider refactoring.
            Open

            func (m *MetricsSpecification) getMetricsEndpoints(userGUID string, cnsiList []string) (map[string]EndpointMetricsRelation, error) {
            
                metricsProviders := make([]MetricsMetadata, 0)
                endpointsMap := make(map[string]*interfaces.ConnectedEndpoint)
                results := make(map[string]EndpointMetricsRelation)
            Severity: Minor
            Found in src/jetstream/plugins/metrics/main.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 endpointActions has a Cognitive Complexity of 26 (exceeds 8 allowed). Consider refactoring.
            Open

              endpointActions(includeSeparators = false): IListAction<EndpointModel>[] {
                // Add any additional actions that are per endpoint type
                const customActions = entityCatalog.getAllEndpointTypes()
                  .map(endpoint => endpoint.definition.endpointListActions)
                  .filter(endpointListActions => !!endpointListActions)

            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

            File entity-catalog-entity.ts has 298 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { ActionReducer } from '@ngrx/store';
            
            import { IRequestEntityTypeState } from '../../app-state';
            import {
              EntitiesFetchHandler,

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

                @Effect()
                deleteAppAutoscalerCredential$ = this.actions$.pipe(
                  ofType<DeleteAppAutoscalerCredentialAction>(DELETE_APP_AUTOSCALER_CREDENTIAL),
                  mergeMap(action => {
                    const actionType = 'delete';
              src/frontend/packages/cf-autoscaler/src/store/autoscaler.effects.ts on lines 184..208

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

              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

                @Effect()
                detachAppAutoscalerPolicy$ = this.actions$.pipe(
                  ofType<DetachAppAutoscalerPolicyAction>(DETACH_APP_AUTOSCALER_POLICY),
                  mergeMap(action => {
                    const actionType = 'delete';
              src/frontend/packages/cf-autoscaler/src/store/autoscaler.effects.ts on lines 245..269

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

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

              func (c *CFPushApp) Init(appDir string, manifestPath string, overrides CFPushAppOverrides) error {
              
                  // App name
                  if len(overrides.Name) > 0 {
                      c.pushCommand.OptionalArgs = flag.OptionalAppName{
              Severity: Minor
              Found in src/jetstream/plugins/cfapppush/pushapp.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

              Method PgsqlTokenRepository.findCNSIToken has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
              Open

              func (p *PgsqlTokenRepository) findCNSIToken(cnsiGUID string, userGUID string, encryptionKey []byte, includeDisconnected bool) (interfaces.TokenRecord, error) {
                  log.Debug("findCNSIToken")
                  if cnsiGUID == "" {
                      msg := "Unable to find CNSI Token without a valid CNSI GUID."
                      log.Debug(msg)
              Severity: Minor
              Found in src/jetstream/repository/tokens/pgsql_tokens.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

              File chart-values-editor.component.ts has 294 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { HttpClient } from '@angular/common/http';
              import { AfterViewInit, Component, ElementRef, Input, OnDestroy, OnInit, Renderer2, ViewChild } from '@angular/core';
              import { JsonSchemaFormComponent } from '@cfstratos/ajsf-core';
              import * as yaml from 'js-yaml';
              import { BehaviorSubject, combineLatest, fromEvent, Observable, of, Subscription } from 'rxjs';

                portalProxy has 26 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 3 hrs to fix

                  Function fill has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    fill(fields: { [fieldKey: string]: string | boolean | number[] }, expectFailure = false): promise.Promise<void> {
                      return this.getControlsMapFormFill().then(ctrls => {
                        Object.keys(fields).forEach(field => {
                          const ctrl = ctrls[field] as FormItem;
                          const value: any = fields[field];
                  Severity: Major
                  Found in src/test-e2e/po/form.po.ts - About 3 hrs to fix

                    Function setProps has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      setProps(props: KubernetesResourceViewerConfig) {
                        this.title = props.title;
                        this.analysis = props.analysis;
                        this.component = props.component;
                    
                    

                      Method portalProxy.registerRoutes has 99 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (p *portalProxy) registerRoutes(e *echo.Echo, needSetupMiddleware bool) {
                          log.Debug("registerRoutes")
                      
                          e.GET("/swagger/*", echoSwagger.WrapHandler)
                      
                      
                      Severity: Major
                      Found in src/jetstream/main.go - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language