Showing 650 of 1,370 total issues
Method cnsiTokenBackup.createBackup
has 5 return statements (exceeds 4 allowed). Open
func (ctb *cnsiTokenBackup) createBackup(data *BackupRequest) (*BackupContent, error) {
log.Debug("createBackup")
allEndpoints, err := ctb.p.ListEndpoints()
if err != nil {
return nil, interfaces.NewHTTPShadowError(http.StatusBadGateway, "Failed to fetch endpoints", "Failed to fetch endpoints: %+v", err)
Method Monocular.artifactHubCacheChartFiles
has 5 return statements (exceeds 4 allowed). Open
func (m *Monocular) artifactHubCacheChartFiles(endpointID, repoName, repoURL, name, version, digest string) (string, error) {
// First look to see if there is a digest file
cacheFolder := path.Join(m.CacheFolder, endpointID, fmt.Sprintf("%s_%s_%s", repoName, name, version))
if hasDigestFile(cacheFolder, digest) {
Method MetricsSpecification.getMetricsEndpoints
has 5 return statements (exceeds 4 allowed). Open
func (m *MetricsSpecification) getMetricsEndpoints(userGUID string, cnsiList []string) (map[string]EndpointMetricsRelation, error) {
metricsProviders := make([]MetricsMetadata, 0)
endpointsMap := make(map[string]*interfaces.ConnectedEndpoint)
results := make(map[string]EndpointMetricsRelation)
Method OIDCKubeAuth.GetOIDCConfig
has 5 return statements (exceeds 4 allowed). Open
func (c *OIDCKubeAuth) GetOIDCConfig(k *config.KubeConfigUser) (*KubeConfigAuthProviderOIDC, error) {
if k.User.AuthProvider.Name != "oidc" {
return nil, errors.New("User doesn't use OIDC")
}
Method AzureKubeAuth.FetchToken
has 5 return statements (exceeds 4 allowed). Open
func (p *AzureKubeAuth) FetchToken(cnsiRecord interfaces.CNSIRecord, ec echo.Context) (*interfaces.TokenRecord, *interfaces.CNSIRecord, error) {
req := ec.Request()
// Need to extract the parameters from the request body
defer req.Body.Close()
Method PushConnectionWrapper.Make
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func (cw PushConnectionWrapper) Make(request *cloudcontroller.Request, passedResponse *cloudcontroller.Response) error {
// Check to see if the token is about to expire, if it is, refresh it first
token, found := cw.portalProxy.GetCNSITokenRecord(cw.config.EndpointID, cw.config.UserID)
if found {
// Aways update the access token, in case someone else refreshed it
- 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 Analysis.doRunReport
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func (c *Analysis) doRunReport(ec echo.Context, analyzer, endpointID, userID string, dbStore store.AnalysisStore, report *store.AnalysisRecord) error {
// Get Kube Config
k8s := c.portalProxy.GetPlugin("kubernetes")
if k8s == nil {
- 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 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 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 {
- 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 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)
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 {
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)
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")
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(
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)
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")
Method GeneratedEndpointPlugin.fetchUsername
has 5 return statements (exceeds 4 allowed). Open
func (gep GeneratedEndpointPlugin) fetchUsername(config pluginConfig, cnsiRecord *interfaces.CNSIRecord, tr *interfaces.TokenRecord) string {
if len(config.UserInfoAPI) == 0 || len(config.UserInfoPath) == 0 {
// Not configured
return defaultTokenUsername
}
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 {
Function MakePluginsFromConfig
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func MakePluginsFromConfig() {
log.Debug("MakePluginsFromConfig")
var config []pluginConfig
- 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 PostgresCNSIRepository.UpdateMetadata
has 5 return statements (exceeds 4 allowed). Open
func (p *PostgresCNSIRepository) UpdateMetadata(guid string, metadata string) error {
log.Debug("UpdateMetadata")
if guid == "" {
msg := "Unable to update Endpoint without a valid guid."