cloudfoundry/stratos

View on GitHub

Showing 718 of 1,370 total issues

Method uaaAuth.VerifySession has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
Open

func (a *uaaAuth) VerifySession(c echo.Context, sessionUser string, sessionExpireTime int64) error {

    tr, err := a.p.GetUAATokenRecord(sessionUser)

    if err != nil {
Severity: Minor
Found in src/jetstream/authuaa.go - About 35 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

Method portalProxy.RefreshOidcToken has 5 return statements (exceeds 4 allowed).
Open

func (p *portalProxy) RefreshOidcToken(skipSSLValidation bool, cnsiGUID, userGUID, client, clientSecret, tokenEndpoint string) (t interfaces.TokenRecord, err error) {
    log.Debug("RefreshOidcToken")
    userToken, ok := p.GetCNSITokenRecordWithDisconnected(cnsiGUID, userGUID)
    if !ok {
        return t, fmt.Errorf("Info could not be found for user with GUID %s", userGUID)
Severity: Major
Found in src/jetstream/oidc_requests.go - About 35 mins to fix

    Function UnMarshalHelper has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
    Open

    func UnMarshalHelper(values map[string]interface{}, intf interface{}) error {
    
        value := reflect.ValueOf(intf)
    
        if value.Kind() != reflect.Ptr {
    Severity: Minor
    Found in src/jetstream/plugins/kubernetes/config/kube_config.go - About 35 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

    Method CloudFoundrySpecification.Info has 5 return statements (exceeds 4 allowed).
    Open

    func (c *CloudFoundrySpecification) Info(apiEndpoint string, skipSSLValidation bool) (interfaces.CNSIRecord, interface{}, error) {
        log.Debug("Info")
        var v2InfoResponse interfaces.V2Info
        var newCNSI interfaces.CNSIRecord
    
    
    Severity: Major
    Found in src/jetstream/plugins/cloudfoundry/main.go - About 35 mins to fix

      Method ConsoleConfig.IsSetupComplete has 5 return statements (exceeds 4 allowed).
      Open

      func (consoleConfig *ConsoleConfig) IsSetupComplete() bool {
      
          // No auth, then setup is complete
          if AuthEndpointTypes[consoleConfig.AuthEndpointType] == AuthNone {
              return true
      Severity: Major
      Found in src/jetstream/repository/interfaces/structs.go - About 35 mins to fix

        Function MakePluginsFromConfig has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
        Open

        func MakePluginsFromConfig() {
            log.Debug("MakePluginsFromConfig")
        
            var config []pluginConfig
        
        
        Severity: Minor
        Found in src/jetstream/plugins/yamlgenerated/main.go - About 35 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

        Function readCFFile has 5 return statements (exceeds 4 allowed).
        Open

        func readCFFile() (*CFConfigFile, *url.URL, error) {
        
            var url *url.URL
            usr, err := user.Current()
            if err != nil {
        Severity: Major
        Found in src/jetstream/plugins/desktop/cloudfoundry.go - About 35 mins to fix

          Method portalProxy.login has 5 return statements (exceeds 4 allowed).
          Open

          func (p *portalProxy) login(c echo.Context, skipSSLValidation bool, client string, clientSecret string, endpoint string) (uaaRes *interfaces.UAAResponse, u *interfaces.JWTUserTokenInfo, err error) {
              log.Debug("login")
              if c.Request().Method == http.MethodGet {
                  code := c.QueryParam("code")
                  state := c.QueryParam("state")
          Severity: Major
          Found in src/jetstream/auth.go - About 35 mins to fix

            Function parseConsoleConfigFromForm has 5 return statements (exceeds 4 allowed).
            Open

            func parseConsoleConfigFromForm(c echo.Context) (*interfaces.ConsoleConfig, error) {
                consoleConfig := new(interfaces.ConsoleConfig)
            
                // Local admin user configuration?
                password := c.FormValue("local_admin_password")
            Severity: Major
            Found in src/jetstream/setup_console.go - About 35 mins to fix

              Method PostgresCNSIRepository.ListByUser has 5 return statements (exceeds 4 allowed).
              Open

              func (p *PostgresCNSIRepository) ListByUser(userGUID string) ([]*interfaces.ConnectedEndpoint, error) {
                  log.Debug("ListByUser")
                  rows, err := p.db.Query(listCNSIsByUser, "cnsi", userGUID)
                  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 35 mins to fix

                Function getRecentLogs has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
                Open

                func getRecentLogs(ac *AuthorizedConsumer, cnsiGUID, appGUID string) ([]*events.LogMessage, error) {
                    log.Debug("getRecentLogs")
                    messages, err := ac.consumer.RecentLogs(appGUID, ac.authToken)
                    if err != nil {
                        errorPattern := "Failed to get recent messages for App %s on CNSI %s [%v]"
                Severity: Minor
                Found in src/jetstream/plugins/cloudfoundry/cf_websocket_streams.go - About 35 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

                Function init has 5 return statements (exceeds 4 allowed).
                Open

                func init() {
                    RegisterMigration(20190522121200, "LocalUsers", func(txn *sql.Tx, conf *goose.DBConf) error {
                        binaryDataType := "BYTEA"
                        if strings.Contains(conf.Driver.Name, "mysql") {
                            binaryDataType = "BLOB"
                Severity: Major
                Found in src/jetstream/datastore/20190522121200_LocalUsers.go - About 35 mins to fix

                  Method portalProxy.writeSessionHook has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
                  Open

                  func (p *portalProxy) writeSessionHook(c echo.Context) func() {
                      return func() {
                          // Has the session been modified and need saving?
                          sessionModifed := c.Get(jetStreamSessionContextUpdatedKey)
                          sessionIntf := c.Get(jetStreamSessionContextKey)
                  Severity: Minor
                  Found in src/jetstream/session.go - About 35 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

                  Function getKubeDashboardServiceAccount has 5 return statements (exceeds 4 allowed).
                  Open

                  func getKubeDashboardServiceAccount(p interfaces.PortalProxy, cnsiGUID, userGUID string, labelSelector string) (*v1.ServiceAccount, error) {
                      log.Debug("getKubeDashboardService request")
                  
                      response, err := p.DoProxySingleRequest(cnsiGUID, userGUID, "GET", "/api/v1/serviceaccounts?labelSelector="+labelSelector, nil, nil)
                      if err != nil || response.StatusCode != 200 {
                  Severity: Major
                  Found in src/jetstream/plugins/kubernetes/dashboard/common.go - About 35 mins to fix

                    Method KubeConfigFile.GetUserForCluster has 5 return statements (exceeds 4 allowed).
                    Open

                    func (k *KubeConfigFile) GetUserForCluster(clusterEndpoint string) (*KubeConfigUser, error) {
                    
                        var cluster *KubeConfigCluster
                        var err error
                    
                    
                    Severity: Major
                    Found in src/jetstream/plugins/kubernetes/config/kube_config.go - About 35 mins to fix

                      Method CustomBinder.Bind has 5 return statements (exceeds 4 allowed).
                      Open

                      func (b *CustomBinder) Bind(i interface{}, c echo.Context) error {
                          db := new(echo.DefaultBinder)
                          err := db.Bind(i, c)
                      
                          if err != nil {
                      Severity: Major
                      Found in src/jetstream/custombinder/custombinder.go - About 35 mins to fix

                        Function init has 5 return statements (exceeds 4 allowed).
                        Open

                        func init() {
                            RegisterMigration(20180824092600, "LinkedTokens", func(txn *sql.Tx, conf *goose.DBConf) error {
                        
                                addTokenID := "ALTER TABLE tokens ADD token_guid VARCHAR(36) DEFAULT 'default-token'"
                                _, err := txn.Exec(addTokenID)
                        Severity: Major
                        Found in src/jetstream/datastore/20180824092600_LinkedTokens.go - About 35 mins to fix

                          Method FavoritesDBStore.List has 5 return statements (exceeds 4 allowed).
                          Open

                          func (p *FavoritesDBStore) List(userGUID string) ([]*UserFavoriteRecord, error) {
                              log.Debug("List")
                              rows, err := p.db.Query(getFavorites, userGUID)
                              if err != nil {
                                  return nil, fmt.Errorf("Unable to retrieve User Favorite records: %v", err)

                            Function readKubeConfigFile has 5 return statements (exceeds 4 allowed).
                            Open

                            func readKubeConfigFile() (*clientcmdapi.Config, error) {
                            
                                // Use the KUBECONFIG env var if set, otherwise use default
                                kcFile := os.Getenv("KUBECONFIG")
                                if len(kcFile) == 0 {
                            Severity: Major
                            Found in src/jetstream/plugins/desktop/kubernetes/kubeconfig.go - About 35 mins to fix

                              Method portalProxy.RefreshOAuthToken has 5 return statements (exceeds 4 allowed).
                              Open

                              func (p *portalProxy) RefreshOAuthToken(skipSSLValidation bool, cnsiGUID, userGUID, client, clientSecret, tokenEndpoint string) (t interfaces.TokenRecord, err error) {
                                  log.Debug("refreshToken")
                                  userToken, ok := p.GetCNSITokenRecordWithDisconnected(cnsiGUID, userGUID)
                                  if !ok {
                                      return t, fmt.Errorf("Info could not be found for user with GUID %s", userGUID)
                              Severity: Major
                              Found in src/jetstream/oauth_requests.go - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language