cloudfoundry/stratos

View on GitHub

Showing 718 of 1,370 total issues

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

  error: any,
  action: EntityRequestAction,
  catalogEntity: StratosBaseCatalogEntity,
  requestType: ApiRequestTypes,
  actionDispatcher: ActionDispatcher,

    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

    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

      Avoid deeply nested control flow statements.
      Open

                    if (this.allSteps[index].onEnter) {
                      this.allSteps[index].onEnter(this.enterData);
                    }

        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

        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

            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

              Method CertKubeAuth.DoFlowRequest has 6 return statements (exceeds 4 allowed).
              Open

              func (c *CertKubeAuth) DoFlowRequest(cnsiRequest *interfaces.CNSIRequest, req *http.Request) (*http.Response, error) {
                  log.Debug("doCertAuthFlowRequest")
              
                  authHandler := func(tokenRec interfaces.TokenRecord, cnsi interfaces.CNSIRecord) (*http.Response, error) {
              
              
              Severity: Major
              Found in src/jetstream/plugins/kubernetes/auth/cert.go - About 40 mins to fix

                Method UserInvite.initClientToken has 6 return statements (exceeds 4 allowed).
                Open

                func (userinvite *UserInvite) initClientToken(context echo.Context) error {
                    // Do we have a valid cf guid?
                    if userinvite.portalProxy.GetConfig().CloudFoundryInfo == nil ||
                        len(userinvite.portalProxy.GetConfig().CloudFoundryInfo.EndpointGUID) == 0 {
                        return nil
                Severity: Major
                Found in src/jetstream/plugins/userinvite/main.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

                    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

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

                        func (userInfo *UserInfo) updateUserInfo(c echo.Context) error {
                            _, 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 Analysis.getLatestReport has 6 return statements (exceeds 4 allowed).
                          Open

                          func (c *Analysis) getLatestReport(ec echo.Context) error {
                              log.Debug("getLatestReport")
                              var p = c.portalProxy
                          
                              // Need to get a config object for the target endpoint
                          Severity: Major
                          Found in src/jetstream/plugins/analysis/list.go - About 40 mins to fix

                            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

                              Method UserFavorites.create has 6 return statements (exceeds 4 allowed).
                              Open

                              func (uf *UserFavorites) create(c echo.Context) error {
                              
                                  store, err := userfavoritesstore.NewFavoritesDBStore(uf.portalProxy.GetDatabaseConnection())
                                  if err != nil {
                                      return interfaces.NewHTTPShadowError(
                              Severity: Major
                              Found in src/jetstream/plugins/userfavorites/favorites.go - About 40 mins to fix

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

                                func findDatabaseConfig(vcapServices map[string][]VCAPService, db *DatabaseConfig, env *env.VarSet) bool {
                                    var service VCAPService
                                    configs := findDatabaseConfigurations(vcapServices)
                                    log.Infof("Found %d database service instances", len(configs))
                                    for _, s := range configs {
                                Severity: Major
                                Found in src/jetstream/datastore/database_cf_config.go - About 40 mins to fix

                                  Function init has 6 return statements (exceeds 4 allowed).
                                  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: Major
                                  Found in src/jetstream/datastore/20191008121900_PrimaryKeys.go - About 40 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language