Showing 1,111 of 1,370 total issues
Method KubeTerminal.createPod
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func (k *KubeTerminal) createPod(c echo.Context, kubeConfig, kubeVersion string, ws *websocket.Conn) (*PodCreationData, error) {
// Unique ID for the secret and pod name
id := uuid.NewV4().String()
id = strings.ReplaceAll(id, "-", "")
// Names for the secret and pod
- 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 a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. 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) {
- 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 HelmReleaseGraph.ProcessService
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func (r *HelmReleaseGraph) ProcessService(id string, res KubeResource, spec v1.ServiceSpec) {
if len(spec.Selector) > 0 {
// Find all Pods that match this selector
for _, item := range r.Release.Resources {
switch o := item.Resource.(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
Method SemanticVersion.LessThan
has 5 return statements (exceeds 4 allowed). Open
func (s *SemanticVersion) LessThan(d *SemanticVersion) bool {
if d == nil {
return true
}
if s.Valid && d.Valid {
Method MetricsSpecification.createMetadata
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func (m *MetricsSpecification) createMetadata(metricEndpoint *url.URL, httpClient http.Client, auth *MetricsAuth) (string, error) {
basicMetricRequest := fmt.Sprintf("%s/api/v1/query?query=firehose_total_metrics_received", metricEndpoint)
req, err := http.NewRequest("GET", basicMetricRequest, nil)
if err != nil {
msg := "Failed to create request for the Metrics Endpoint: %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 KubernetesSpecification.GetHelmConfiguration
has 5 return statements (exceeds 4 allowed). Open
func (c *KubernetesSpecification) GetHelmConfiguration(endpointGUID, userID, namespace string) (*action.Configuration, *HelmConfiguration, error) {
// Need to get a config object for the target endpoint
var p = c.portalProxy
hc := &HelmConfiguration{}
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
Function getKubeDashboardPod
has 5 return statements (exceeds 4 allowed). Open
func getKubeDashboardPod(p interfaces.PortalProxy, cnsiGUID, userGUID string, labelSelector string) (*v1.Pod, error) {
log.Debug("kubeDashboardStatus request")
response, err := p.DoProxySingleRequest(cnsiGUID, userGUID, "GET", "/api/v1/pods?labelSelector="+labelSelector, nil, nil)
if err != nil || response.StatusCode != 200 {
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
Method Analysis.deleteReports
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
func (c *Analysis) deleteReports(ec echo.Context) error {
log.Debug("deleteReports")
var p = c.portalProxy
// Need to get a config object for the target endpoint
- 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 LocalUserInfo.UpdateUserInfo
has 5 return statements (exceeds 4 allowed). Open
func (userInfo *LocalUserInfo) UpdateUserInfo(profile *uaaUser) (int, error) {
// Fetch the user, make updates and save
id := profile.ID
localUsersRepo, err := localusers.NewPgsqlLocalUsersRepository(userInfo.portalProxy.GetDatabaseConnection())
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 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)
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
Function getScriptFolder
has 5 return statements (exceeds 4 allowed). Open
func getScriptFolder() string {
fallbackPath, err := os.Getwd()
if err != nil {
fallbackPath = "."
}
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 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)
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
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"