cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

Avoid deeply nested control flow statements.
Open

            if (scExtState) {
              extState = scExtState;
            } else {
              extState = pkgState + '(' +
                this.formatCount(counts.running) + ',' +

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

      constructor(
        public activatedRoute: ActivatedRoute,
        public kubeEndpointService: KubernetesEndpointService
      ) {
        this.podName = activatedRoute.snapshot.params.podName;

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

    export function dashboardReducer(state: DashboardState = defaultDashboardState, action): DashboardState {
      switch (action.type) {
        case OPEN_SIDE_NAV:
          if (state.isMobile) {
            return { ...state, isMobileNavOpen: true };
    Severity: Minor
    Found in src/frontend/packages/store/src/reducers/dashboard-reducer.ts - 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 (!resources[entityType]) {
                      resources[entityType] = [];
                    }

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

      function deleteEntity(state, entityKey, guid) {
        const newState = {} as Record<string, any>;
        for (const entityTypeKey in state) {
          if (entityTypeKey === entityKey) {
            newState[entityTypeKey] = {};

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

        constructor(private store: Store<AppState>, private activatedRoute: ActivatedRoute) {
          // Determine the starting state of the filter by repo section
          stratosEntityCatalog.endpoint.store.getAll.getPaginationService().entities$.pipe(
            filter(entities => !!entities),
            first()

      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 failApiRequest has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        store: Store<T>,
        apiAction: EntityRequestAction,
        error,
        catalogEntity: StratosBaseCatalogEntity,
        requestType: ApiRequestTypes = 'fetch',

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

          store: Store<GeneralEntityAppState>,
          entityKey: string,
          paginationKey: string,
          paginationAction: PaginatedAction | PaginatedAction[],
          paginationMonitor: PaginationMonitor,

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

            editModeChanged(mode) {
              this.mode = mode.value;
          
              if (this.mode === EditorMode.CodeEditor) {
                // Form -> Editor

          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 (itemFormat) {
                    arrayItem.format = itemFormat;
                  }

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

              private setErrorMessage(auth: AuthState) {
                // Default error message
                this.message = `Couldn't log in, please try again.`;
                if (auth.error && auth.errorResponse) {
                  if (auth.errorResponse === 'Invalid session') {

            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

            func (br *BackupRestore) backupEndpoints(c echo.Context) error {
                log.Debug("backupEndpoints")
            
                userID, err := br.portalProxy.GetSessionStringValue(c, "user_id")
                if err != nil {
            Severity: Minor
            Found in src/jetstream/plugins/backup/main.go and 1 other location - About 45 mins to fix
            src/jetstream/plugins/backup/main.go on lines 90..112

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

            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 (br *BackupRestore) restoreEndpoints(c echo.Context) error {
                log.Debug("restoreEndpoints")
            
                userID, err := br.portalProxy.GetSessionStringValue(c, "user_id")
                if err != nil {
            Severity: Minor
            Found in src/jetstream/plugins/backup/main.go and 1 other location - About 45 mins to fix
            src/jetstream/plugins/backup/main.go on lines 66..88

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

            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 Monocular.cacheChartFromURL has 6 return statements (exceeds 4 allowed).
            Open

            func (m *Monocular) cacheChartFromURL(chartCachePath, digest, name, chartURL string) error {
                // Check to see if we have the same digest
                if ok := hasDigestFile(chartCachePath, digest); ok {
                    log.Debug("Skipping download - already have archive with the same digest")
                    return nil
            Severity: Major
            Found in src/jetstream/plugins/monocular/cache.go - About 40 mins to fix

              Function NewKubeTerminal has 6 return statements (exceeds 4 allowed).
              Open

              func NewKubeTerminal(p interfaces.PortalProxy) *KubeTerminal {
                  // Only enabled in tech preview
                  if !p.GetConfig().EnableTechPreview {
                      log.Info("Kube Terminal not enabled - requires tech preview")
                      return nil
              Severity: Major
              Found in src/jetstream/plugins/kubernetes/terminal/terminal.go - About 40 mins to fix

                Method CFPushApp.Init has 6 return statements (exceeds 4 allowed).
                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: Major
                Found in src/jetstream/plugins/cfapppush/pushapp.go - About 40 mins to fix

                  Function extractArchiveFiles has 6 return statements (exceeds 4 allowed).
                  Open

                  func extractArchiveFiles(archivePath, chartName, downloadFolder string, filenames []string) error {
                      // Map the filenames array into a map of path to destination file
                      requiredFiles := make(map[string]string)
                      requiredCount := len(filenames)
                      for _, name := range filenames {
                  Severity: Major
                  Found in src/jetstream/plugins/monocular/cache.go - About 40 mins to fix

                    Method UserInfo.updateUserPassword has 6 return statements (exceeds 4 allowed).
                    Open

                    func (userInfo *UserInfo) updateUserPassword(c echo.Context) error {
                        id, err := userInfo.preFlightChecks(c)
                        if err != nil {
                            return err
                        }
                    Severity: Major
                    Found in src/jetstream/plugins/userinfo/main.go - About 40 mins to fix

                      Method KubeConfigAuth.FetchToken has 6 return statements (exceeds 4 allowed).
                      Open

                      func (c *KubeConfigAuth) FetchToken(cnsiRecord interfaces.CNSIRecord, ec echo.Context) (*interfaces.TokenRecord, *interfaces.CNSIRecord, error) {
                          log.Debug("FetchToken (KubeConfigAuth)")
                      
                          req := ec.Request()
                      
                      
                      Severity: Major
                      Found in src/jetstream/plugins/kubernetes/auth/kubeconfig.go - About 40 mins to fix

                        Function detectTLSCert has 6 return statements (exceeds 4 allowed).
                        Open

                        func detectTLSCert(pc interfaces.PortalConfig) (string, string, error) {
                            log.Debug("detectTLSCert")
                            certFilename := "pproxy.crt"
                            certKeyFilename := "pproxy.key"
                        
                        
                        Severity: Major
                        Found in src/jetstream/main.go - About 40 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language