Showing 1,395 of 1,395 total issues
Method Analyzer.Start
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func (a *Analyzer) Start() {
// Reports folder
// Init reports directory
- 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 getKubeDashboardSecretToken
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func getKubeDashboardSecretToken(p interfaces.PortalProxy, cnsiGUID, userGUID string, sa *v1.ServiceAccount) (string, error) {
log.Debug("getKubeDashboardSecretToken request")
namespace := sa.Namespace
- 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 Monocular.fetchChartsFromArtifactHub
has 5 return statements (exceeds 4 allowed). Open
func (m *Monocular) fetchChartsFromArtifactHub(c echo.Context, endpointID string) error {
cacheFolder := path.Join(m.CacheFolder, endpointID)
indexFile := path.Join(cacheFolder, "hub_index.json")
if ok := useCachedFile(indexFile); ok {
// Just send the cached file
Method Monocular.getChartURL
has 5 return statements (exceeds 4 allowed). Open
func (m *Monocular) getChartURL(repoURL, name, version string) (string, error) {
httpClient := m.portalProxy.GetHttpClient(true)
helmIndexURL := joinURL(repoURL, "index.yaml")
resp, err := httpClient.Get(helmIndexURL)
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)
Method CFHosting.Init
has 5 return statements (exceeds 4 allowed). Open
func (ch *CFHosting) Init() error {
// Determine if we are running CF by presence of env var "VCAP_APPLICATION" and configure appropriately
if ch.portalProxy.Env().IsSet(VCapApplication) {
log.Info("Detected that Console is deployed as a Cloud Foundry Application")
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 {
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
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
Function SetStructFieldValue
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func SetStructFieldValue(value reflect.Value, field reflect.Value, val string) error {
var newVal interface{}
var err error
typ := field.Type()
- 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 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)
Method portalProxy.listRegisteredCNSIs
has 5 return statements (exceeds 4 allowed). Open
func (p *portalProxy) listRegisteredCNSIs(c echo.Context) error {
log.Debug("listRegisteredCNSIs")
userGUIDIntf, err := p.GetSessionValue(c, "user_id")
if err != nil {
return interfaces.NewHTTPShadowError(
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
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]"
- 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 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 {
Function init
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. 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;"
- 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 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"
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)
- 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.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)
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)