Showing 718 of 1,370 total issues
Method GKEKubeAuth.FetchToken
has 7 return statements (exceeds 4 allowed). Open
func (c *GKEKubeAuth) FetchToken(cnsiRecord interfaces.CNSIRecord, ec echo.Context) (*interfaces.TokenRecord, *interfaces.CNSIRecord, error) {
log.Debug("FetchToken (GKE)")
// We should already have the refresh token in the body sent to us
req := ec.Request()
Method CFPushApp.Run
has 7 return statements (exceeds 4 allowed). Open
func (c *CFPushApp) Run(msgSender DeployAppMessageSender, clientWebsocket *websocket.Conn) error {
// Get a CF Config
config, err := configv3.LoadConfig()
if err != nil {
Avoid deeply nested control flow statements. Open
if err == nil {
isValid, err := k.PortalProxy.GetSessionDataStore().IsValidSession(i)
if err == nil && !isValid {
log.Debugf("Deleting secret %s", secret.Name)
secretClient.Delete(secret.Name, nil)
Method LocalUserInfo.UpdatePassword
has 7 return statements (exceeds 4 allowed). Open
func (userInfo *LocalUserInfo) UpdatePassword(id string, passwordInfo *passwordChangeInfo) (int, error) {
// Fetch the user, make updates and save
localUsersRepo, err := localusers.NewPgsqlLocalUsersRepository(userInfo.portalProxy.GetDatabaseConnection())
if err != nil {
Method UserInvite.checkPermissions
has 7 return statements (exceeds 4 allowed). Open
func (invite *UserInvite) checkPermissions(c echo.Context, endpoint interfaces.CNSIRecord, userInviteRequest *UserInviteReq) error {
cfGUID := c.Param("id")
userGUID := c.Get("user_id").(string)
// Get the User information for the endpoint connection
Avoid deeply nested control flow statements. Open
if strings.HasPrefix(err.Error(), "no kind") {
var t interface{}
if err := yaml.Unmarshal(data, &t); err == nil {
r.processYamlResource(t, data)
} else {
Method KubernetesSpecification.UpgradeRelease
has 7 return statements (exceeds 4 allowed). Open
func (c *KubernetesSpecification) UpgradeRelease(ec echo.Context) error {
endpointGUID := ec.Param("endpoint")
releaseName := ec.Param("name")
namespace := ec.Param("namespace")
Method CFAppPush.getGitSCMSource
has 7 return statements (exceeds 4 allowed). Open
func (cfAppPush *CFAppPush) getGitSCMSource(clientWebSocket *websocket.Conn, tempDir string, msg SocketMessage, userGUID string) (StratosProject, string, error) {
var (
err error
)
Function makePrometheusRequestInfos
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func makePrometheusRequestInfos(c echo.Context, userGUID string, metrics map[string]EndpointMetricsRelation, prometheusOp string, queries string, addJob bool) []interfaces.ProxyRequestInfo {
Avoid deeply nested control flow statements. Open
if err != nil {
if ok, detail := isSSLRelatedError(err); ok {
return interfaces.NewHTTPShadowError(
http.StatusForbidden,
"SSL error - "+detail,
Method PostgresCNSIRepository.ListByUser
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. 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)
- Read upRead up
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.openNoaaConsumer
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
func (c CloudFoundrySpecification) openNoaaConsumer(echoContext echo.Context) (*AuthorizedConsumer, error) {
ac := &AuthorizedConsumer{}
// Get the CNSI and app IDs from route parameters
- Read upRead up
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 consoleConfig.AuthorizationEndpoint == nil {
// No Authorization endpoint
consoleConfig.AuthorizationEndpoint = consoleConfig.UAAEndpoint
log.Debugf("Using UAA Endpoint for Auth Endpoint: %s", consoleConfig.AuthorizationEndpoint)
}
Method portalProxy.ProxyRequest
has 7 return statements (exceeds 4 allowed). Open
func (p *portalProxy) ProxyRequest(c echo.Context, uri *url.URL) (map[string]*interfaces.CNSIRequest, error) {
log.Debug("ProxyRequest")
cnsiList := strings.Split(c.Request().Header.Get("x-cap-cnsi-list"), ",")
shouldPassthrough := "true" == c.Request().Header.Get("x-cap-passthrough")
longRunning := "true" == c.Request().Header.Get(longRunningTimeoutHeader)
Method PgsqlLocalUsersRepository.AddLocalUser
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
func (p *PgsqlLocalUsersRepository) AddLocalUser(user interfaces.LocalUser) error {
log.Debug("AddLocalUser")
//Validate args
- Read upRead up
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 updateCFFIle
has 7 return statements (exceeds 4 allowed). Open
func updateCFFIle(updates map[string]string) error {
usr, err := user.Current()
if err != nil {
return err
}
Method portalProxy.buildCNSIRequest
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (p *portalProxy) buildCNSIRequest(cnsiGUID string, userGUID string, method string, uri *url.URL, body []byte, header http.Header) (interfaces.CNSIRequest, error) {
Method portalProxy.DoLoginToCNSIwithConsoleUAAtoken
has 7 return statements (exceeds 4 allowed). Open
func (p *portalProxy) DoLoginToCNSIwithConsoleUAAtoken(c echo.Context, theCNSIrecord interfaces.CNSIRecord) error {
userID, err := p.GetSessionStringValue(c, "user_id")
if err != nil {
return errors.New("could not find correct session value")
}
Method PgsqlLocalUsersRepository.UpdateLocalUser
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
func (p *PgsqlLocalUsersRepository) UpdateLocalUser(user interfaces.LocalUser) error {
log.Debug("UpdateLocalUser")
//Validate args
var err error
- Read upRead up
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.setupGetAvailableScopes
has 7 return statements (exceeds 4 allowed). Open
func (p *portalProxy) setupGetAvailableScopes(c echo.Context) error {
// Check if already set up
if p.GetConfig().ConsoleConfig.IsSetupComplete() {
return c.NoContent(http.StatusServiceUnavailable)