horizoncd/horizon

View on GitHub
pkg/cd/cd.go

Summary

Maintainability
F
3 days
Test Coverage

Showing 15 of 15 total issues

Method cd.GetClusterStateV1 has a Cognitive Complexity of 70 (exceeds 20 allowed). Consider refactoring.
Open

func (c *cd) GetClusterStateV1(ctx context.Context,
params *GetClusterStateParams) (clusterState *ClusterState, err error) {
const op = "cd: get cluster status"
defer wlog.Start(ctx, op).StopPrint()
 
 
Severity: Minor
Found in pkg/cd/cd.go - About 1 day to fix

Method cd.GetClusterStateV1 has 141 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *cd) GetClusterStateV1(ctx context.Context,
params *GetClusterStateParams) (clusterState *ClusterState, err error) {
const op = "cd: get cluster status"
defer wlog.Start(ctx, op).StopPrint()
 
 
Severity: Major
Found in pkg/cd/cd.go - About 4 hrs to fix

    File cd.go has 527 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    /*
    Copyright The Kubernetes Authors.
     
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    Severity: Minor
    Found in pkg/cd/cd.go - About 2 hrs to fix

      Method cd.GetClusterState has 70 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *cd) GetClusterState(ctx context.Context,
      params *GetClusterStateV2Params) (*ClusterStateV2, error) {
      const op = "cd: get cluster status"
      defer wlog.Start(ctx, op).StopPrint()
       
       
      Severity: Minor
      Found in pkg/cd/cd.go - About 1 hr to fix

        Method cd.GetClusterState has 15 return statements (exceeds 4 allowed).
        Open

        func (c *cd) GetClusterState(ctx context.Context,
        params *GetClusterStateV2Params) (*ClusterStateV2, error) {
        const op = "cd: get cluster status"
        defer wlog.Start(ctx, op).StopPrint()
         
         
        Severity: Major
        Found in pkg/cd/cd.go - About 1 hr to fix

          Method cd.GetClusterStateV1 has 15 return statements (exceeds 4 allowed).
          Open

          func (c *cd) GetClusterStateV1(ctx context.Context,
          params *GetClusterStateParams) (clusterState *ClusterState, err error) {
          const op = "cd: get cluster status"
          defer wlog.Start(ctx, op).StopPrint()
           
           
          Severity: Major
          Found in pkg/cd/cd.go - About 1 hr to fix

            Method cd.GetStep has 51 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *cd) GetStep(ctx context.Context, params *GetStepParams) (*Step, error) {
            const op = "cd: get step"
            defer wlog.Start(ctx, op).StopPrint()
             
            _, kubeClient, err := c.kubeClientFactory.GetByK8SServer(params.RegionEntity.Server, params.RegionEntity.Certificate)
            Severity: Minor
            Found in pkg/cd/cd.go - About 1 hr to fix

              Method cd.GetStep has 10 return statements (exceeds 4 allowed).
              Open

              func (c *cd) GetStep(ctx context.Context, params *GetStepParams) (*Step, error) {
              const op = "cd: get step"
              defer wlog.Start(ctx, op).StopPrint()
               
              _, kubeClient, err := c.kubeClientFactory.GetByK8SServer(params.RegionEntity.Server, params.RegionEntity.Certificate)
              Severity: Major
              Found in pkg/cd/cd.go - About 1 hr to fix

                Method cd.GetClusterState has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                Open

                func (c *cd) GetClusterState(ctx context.Context,
                params *GetClusterStateV2Params) (*ClusterStateV2, error) {
                const op = "cd: get cluster status"
                defer wlog.Start(ctx, op).StopPrint()
                 
                 
                Severity: Minor
                Found in pkg/cd/cd.go - About 55 mins to fix

                Avoid deeply nested control flow statements.
                Open

                if _, ok := podMap[node.Name]; !ok {
                return nil, herrors.NewErrNotFound(herrors.PodsInK8S, fmt.Sprintf("pod %s does not exist", node.Name))
                }
                Severity: Major
                Found in pkg/cd/cd.go - About 45 mins to fix

                  Method cd.GetResourceTree has 6 return statements (exceeds 4 allowed).
                  Open

                  func (c *cd) GetResourceTree(ctx context.Context,
                  params *GetResourceTreeParams) ([]ResourceNode, error) {
                  const op = "cd: get resource tree"
                  defer wlog.Start(ctx, op).StopPrint()
                   
                   
                  Severity: Major
                  Found in pkg/cd/cd.go - About 40 mins to fix

                    Method cd.CreateCluster has 6 return statements (exceeds 4 allowed).
                    Open

                    func (c *cd) CreateCluster(ctx context.Context, params *CreateClusterParams) (err error) {
                    const op = "cd: create cluster"
                    defer wlog.Start(ctx, op).StopPrint()
                     
                    argo, err := c.factory.GetArgoCD(params.RegionEntity.Name, params.Environment)
                    Severity: Major
                    Found in pkg/cd/cd.go - About 40 mins to fix

                      Function NewCD has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func NewCD(informerFactories *regioninformers.RegionInformers, clusterGitRepo gitrepo.ClusterGitRepo,
                      argoCDMapper argocdconf.Mapper, regionArgoCDMapper argocdconf.RegionMapper, targetRevision string) CD {
                      Severity: Minor
                      Found in pkg/cd/cd.go - About 35 mins to fix

                        Method cd.DeleteCluster has 5 return statements (exceeds 4 allowed).
                        Open

                        func (c *cd) DeleteCluster(ctx context.Context, params *DeleteClusterParams) (err error) {
                        const op = "cd: delete cluster"
                        defer wlog.Start(ctx, op).StopPrint()
                         
                        argo, err := c.factory.GetArgoCD(params.Region, params.Environment)
                        Severity: Major
                        Found in pkg/cd/cd.go - About 35 mins to fix

                          Method cd.GetPodEvents has 5 return statements (exceeds 4 allowed).
                          Open

                          func (c *cd) GetPodEvents(ctx context.Context,
                          params *GetPodEventsParams) (events []Event, err error) {
                          const op = "cd: get cluster pod events"
                          defer wlog.Start(ctx, op).StopPrint()
                           
                           
                          Severity: Major
                          Found in pkg/cd/cd.go - About 35 mins to fix
                            Category
                            Status