Showing 650 of 1,370 total issues
Function editModeChanged
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
Open
editModeChanged(mode) {
this.mode = mode.value;
if (this.mode === EditorMode.CodeEditor) {
// Form -> Editor
- 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 setErrorMessage
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
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') {
- 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 CertKubeAuth.DoFlowRequest
has 6 return statements (exceeds 4 allowed). Open
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) {
Method Monocular.cacheChartFromURL
has 6 return statements (exceeds 4 allowed). Open
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
Method UserFavorites.setMetadata
has 6 return statements (exceeds 4 allowed). Open
Open
func (uf *UserFavorites) setMetadata(c echo.Context) error {
store, err := userfavoritesstore.NewFavoritesDBStore(uf.portalProxy.GetDatabaseConnection())
if err != nil {
return err
Function detectTLSCert
has 6 return statements (exceeds 4 allowed). Open
Open
func detectTLSCert(pc interfaces.PortalConfig) (string, string, error) {
log.Debug("detectTLSCert")
certFilename := "pproxy.crt"
certKeyFilename := "pproxy.key"
Method KubeConfigAuth.FetchToken
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *KubeConfigAuth) FetchToken(cnsiRecord interfaces.CNSIRecord, ec echo.Context) (*interfaces.TokenRecord, *interfaces.CNSIRecord, error) {
log.Debug("FetchToken (KubeConfigAuth)")
req := ec.Request()
Method CloudFoundrySpecification.cfLoginHook
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *CloudFoundrySpecification) cfLoginHook(context echo.Context) error {
cfAPI, cfCnsi, err := c.fetchAutoRegisterEndpoint()
// CF auto reg url missing, continue as normal
if cfAPI == "" {
Function NewKubeTerminal
has 6 return statements (exceeds 4 allowed). Open
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
Method UserInfo.updateUserInfo
has 6 return statements (exceeds 4 allowed). Open
Open
func (userInfo *UserInfo) updateUserInfo(c echo.Context) error {
_, err := userInfo.preFlightChecks(c)
if err != nil {
return err
}
Function createPluginForEndpointType
has 6 return statements (exceeds 4 allowed). Open
Open
func createPluginForEndpointType(endpointType string) GeneratedEndpointPlugin {
log.Debugf("Generating plugin %s", endpointType)
gep := GeneratedEndpointPlugin{}
gep.endpointType = endpointType
gep.subTypes = make(map[string]pluginConfig)
Method CFPushApp.Init
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *CFPushApp) Init(appDir string, manifestPath string, overrides CFPushAppOverrides) error {
// App name
if len(overrides.Name) > 0 {
c.pushCommand.OptionalArgs = flag.OptionalAppName{
Method UserInfo.updateUserPassword
has 6 return statements (exceeds 4 allowed). Open
Open
func (userInfo *UserInfo) updateUserPassword(c echo.Context) error {
id, err := userInfo.preFlightChecks(c)
if err != nil {
return err
}
Method cnsiTokenBackup.BackupEndpoints
has 6 return statements (exceeds 4 allowed). Open
Open
func (ctb *cnsiTokenBackup) BackupEndpoints(c echo.Context) error {
log.Debug("BackupEndpoints")
// Create the backup request struct from the body
body, err := ioutil.ReadAll(c.Request().Body)
Function extractArchiveFiles
has 6 return statements (exceeds 4 allowed). Open
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 {
Method Analysis.getLatestReport
has 6 return statements (exceeds 4 allowed). Open
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
Function getKubeDashboardSecretToken
has 6 return statements (exceeds 4 allowed). Open
Open
func getKubeDashboardSecretToken(p interfaces.PortalProxy, cnsiGUID, userGUID string, sa *v1.ServiceAccount) (string, error) {
log.Debug("getKubeDashboardSecretToken request")
namespace := sa.Namespace
Method portalProxy.setupSaveConfig
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *portalProxy) setupSaveConfig(c echo.Context) error {
log.Debug("setupSaveConfig")
consoleRepo, err := console_config.NewPostgresConsoleConfigRepository(p.DatabaseConnectionPool)
Method portalProxy.initialiseConsoleConfig
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *portalProxy) initialiseConsoleConfig(envLookup *env.VarSet) (*interfaces.ConsoleConfig, error) {
log.Debug("initialiseConsoleConfig")
consoleConfig := &interfaces.ConsoleConfig{}
if err := config.Load(consoleConfig, envLookup.Lookup); err != nil {
Method PostgresCNSIRepository.listBy
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *PostgresCNSIRepository) listBy(query string, match string, encryptionKey []byte) ([]*interfaces.CNSIRecord, error) {
rows, err := p.db.Query(query, match)
if err != nil {
return nil, fmt.Errorf("Unable to retrieve CNSI records: %v", err)
}