SUSE/stratos

View on GitHub

Showing 1,395 of 1,395 total issues

Method PostgresCNSIRepository.Update has 6 return statements (exceeds 4 allowed).
Open

func (p *PostgresCNSIRepository) Update(endpoint interfaces.CNSIRecord, encryptionKey []byte) error {
    log.Debug("Update endpoint")

    if endpoint.GUID == "" {
        msg := "Unable to update Endpoint without a valid guid."
Severity: Major
Found in src/jetstream/repository/cnsis/pgsql_cnsis.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

      Method ConsoleConfigRepository.GetConsoleConfig has 6 return statements (exceeds 4 allowed).
      Open

      func (c *ConsoleConfigRepository) GetConsoleConfig() (*interfaces.ConsoleConfig, error) {
          log.Debug("Get ConsoleConfig")
          rows, err := c.db.Query(getConsoleConfig)
          if err != nil {
              return nil, fmt.Errorf("Unable to retrieve console config record: %v", err)
      Severity: Major
      Found in src/jetstream/repository/console_config/psql_console_config.go - About 40 mins to fix

        Method CloudFoundrySpecification.openNoaaConsumer has 6 return statements (exceeds 4 allowed).
        Open

        func (c CloudFoundrySpecification) openNoaaConsumer(echoContext echo.Context) (*AuthorizedConsumer, error) {
        
            ac := &AuthorizedConsumer{}
        
            // Get the CNSI and app IDs from route parameters
        Severity: Major
        Found in src/jetstream/plugins/cloudfoundry/cf_websocket_streams.go - About 40 mins to fix

          Method CloudFoundrySpecification.cfLoginHook has 6 return statements (exceeds 4 allowed).
          Open

          func (c *CloudFoundrySpecification) cfLoginHook(context echo.Context) error {
          
              cfAPI, cfCnsi, err := c.fetchAutoRegisterEndpoint()
              // CF auto reg url missing, continue as normal
              if cfAPI == "" {
          Severity: Major
          Found in src/jetstream/plugins/cloudfoundry/main.go - About 40 mins to fix

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

            func createPluginForEndpointType(endpointType string) GeneratedEndpointPlugin {
                log.Debugf("Generating plugin %s", endpointType)
                gep := GeneratedEndpointPlugin{}
                gep.endpointType = endpointType
                gep.subTypes = make(map[string]pluginConfig)
            Severity: Major
            Found in src/jetstream/plugins/yamlgenerated/main.go - About 40 mins to fix

              Method CustomBinder.bindData has 6 return statements (exceeds 4 allowed).
              Open

              func (b *CustomBinder) bindData(ptr interface{}, data map[string][]string, tag string) error {
                  typ := reflect.TypeOf(ptr).Elem()
                  val := reflect.ValueOf(ptr).Elem()
              
                  if typ.Kind() != reflect.Struct {
              Severity: Major
              Found in src/jetstream/custombinder/custombinder.go - About 40 mins to fix

                Method portalProxy.DoRegisterEndpoint has 6 return statements (exceeds 4 allowed).
                Open

                func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, ssoAllowed bool, subType string, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
                
                    if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
                        return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
                            http.StatusBadRequest,
                Severity: Major
                Found in src/jetstream/cnsi.go - About 40 mins to fix

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

                  func ApplyMigrations(conf *goose.DBConf, db *sql.DB) error {
                      current, err := goose.EnsureDBVersion(conf, db)
                      if err != nil {
                          return fmt.Errorf("Failed to get database version: %s", err.Error())
                      }
                  Severity: Major
                  Found in src/jetstream/datastore/datastore_migrator.go - About 40 mins to fix

                    Method PostgresCNSIRepository.List has 6 return statements (exceeds 4 allowed).
                    Open

                    func (p *PostgresCNSIRepository) List(encryptionKey []byte) ([]*interfaces.CNSIRecord, error) {
                        log.Debug("List")
                        rows, err := p.db.Query(listCNSIs)
                        if err != nil {
                            return nil, fmt.Errorf("Unable to retrieve CNSI records: %v", err)
                    Severity: Major
                    Found in src/jetstream/repository/cnsis/pgsql_cnsis.go - About 40 mins to fix

                      Method portalProxy.setupSaveConfig has 6 return statements (exceeds 4 allowed).
                      Open

                      func (p *portalProxy) setupSaveConfig(c echo.Context) error {
                      
                          log.Debug("setupSaveConfig")
                      
                          consoleRepo, err := console_config.NewPostgresConsoleConfigRepository(p.DatabaseConnectionPool)
                      Severity: Major
                      Found in src/jetstream/setup_console.go - About 40 mins to fix

                        Method portalProxy.logoutOfCNSI has 6 return statements (exceeds 4 allowed).
                        Open

                        func (p *portalProxy) logoutOfCNSI(c echo.Context) error {
                            log.Debug("logoutOfCNSI")
                        
                            cnsiGUID := c.Param("cnsi_guid")
                        
                        
                        Severity: Major
                        Found in src/jetstream/authcnsi.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

                            Consider simplifying this complex logical expression.
                            Open

                                if (!secrets ||
                                  !secrets.consoleUsers || !secrets.consoleUsers.admin || !secrets.consoleUsers.nonAdmin ||
                                  !secrets.endpoints || !secrets.endpoints.cf
                                ) {
                                  throw new Error(`Failed to validate secrets`);
                            Severity: Major
                            Found in src/test-e2e/helpers/secrets-helpers.ts - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                  if (isAdmin) {
                                    const allCfUsersAction = this.createCfGetAllUsersAction(cfGuid);
                              
                                    if (!orgGuid) {
                                      return observableOf(allCfUsersAction);

                                Consider simplifying this complex logical expression.
                                Open

                                  if (ep.provider && ep.provider.metadata && ep.provider.metadata && ep.provider.metadata.metrics_stratos
                                    && Array.isArray(ep.provider.metadata.metrics_stratos)) {
                                    ep.provider.metadata.metrics_stratos.forEach(endp => {
                                      // See if we already know about this endpoint
                                      const hasEndpoint = data.findIndex(i => compareUrl(i.url, endp.url) || compareUrl(i.url, endp.cfEndpoint)) !== -1;
                                Severity: Major
                                Found in src/frontend/packages/core/src/features/metrics/metrics.helpers.ts - About 40 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                      if (dsEndpointType || onlyConnected) {
                                        transformEntities.push((entities: EndpointModel[]) => {
                                          return dsEndpointType || onlyConnected ? entities.filter(endpoint => {
                                            return (!onlyConnected || endpoint.connectionStatus === 'connected') &&
                                              (!dsEndpointType || endpoint.cnsi_type === dsEndpointType);

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

                                    package analysis
                                    
                                    import (
                                        "database/sql"
                                        "strings"
                                    Severity: Minor
                                    Found in src/jetstream/plugins/analysis/20200210105400_Analysis.go and 1 other location - About 40 mins to fix
                                    src/jetstream/plugins/analysis/20201005105400_AnalysisUpstream.go on lines 1..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 210.

                                    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 analysis
                                    
                                    import (
                                        "database/sql"
                                        "strings"
                                    src/jetstream/plugins/analysis/20200210105400_Analysis.go on lines 1..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 210.

                                    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

                                    Function newPortalProxy has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                    func newPortalProxy(pc interfaces.PortalConfig, dcp *sql.DB, ss HttpSessionStore, sessionStoreOptions *sessions.Options, env *env.VarSet) *portalProxy {
                                    Severity: Minor
                                    Found in src/jetstream/main.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language