ekristen/gcp-nuke

View on GitHub

Showing 55 of 55 total issues

Function init has 58 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func init() {
    flags := []cli.Flag{
        &cli.PathFlag{
            Name:  "config",
            Usage: "path to config file",
Severity: Minor
Found in pkg/commands/run/command.go - About 1 hr to fix

    Method CloudFunctionLister.List has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (l *CloudFunctionLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
        var resources []resource.Resource
    
        opts := o.(*nuke.ListerOpts)
        if err := opts.BeforeList(nuke.Regional, "cloudfunctions.googleapis.com"); err != nil {
    Severity: Minor
    Found in resources/cloud-function.go - About 1 hr to fix

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          for {
              resp, err := it.Next()
              if errors.Is(err, iterator.Done) {
                  break
              }
      Severity: Major
      Found in resources/vpc-global-ip-address.go and 3 other locations - About 1 hr to fix
      resources/compute-forwarding-rule.go on lines 116..134
      resources/compute-security-policy.go on lines 121..139
      resources/vpc-ip-address.go on lines 58..76

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 135.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          for {
              resp, err := it.Next()
              if errors.Is(err, iterator.Done) {
                  break
              }
      Severity: Major
      Found in resources/compute-forwarding-rule.go and 3 other locations - About 1 hr to fix
      resources/compute-security-policy.go on lines 121..139
      resources/vpc-global-ip-address.go on lines 57..75
      resources/vpc-ip-address.go on lines 58..76

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 135.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          for {
              resp, err := it.Next()
              if errors.Is(err, iterator.Done) {
                  break
              }
      Severity: Major
      Found in resources/vpc-ip-address.go and 3 other locations - About 1 hr to fix
      resources/compute-forwarding-rule.go on lines 116..134
      resources/compute-security-policy.go on lines 121..139
      resources/vpc-global-ip-address.go on lines 57..75

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 135.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          for {
              resp, err := it.Next()
              if errors.Is(err, iterator.Done) {
                  break
              }
      Severity: Major
      Found in resources/compute-security-policy.go and 3 other locations - About 1 hr to fix
      resources/compute-forwarding-rule.go on lines 116..134
      resources/vpc-global-ip-address.go on lines 57..75
      resources/vpc-ip-address.go on lines 58..76

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 135.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method IAMWorkloadIdentityPoolProviderLister.List has 52 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (l *IAMWorkloadIdentityPoolProviderLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
          var resources []resource.Resource
      
          opts := o.(*nuke.ListerOpts)
          if err := opts.BeforeList(nuke.Global, "iam.googleapis.com"); err != nil {
      Severity: Minor
      Found in resources/iam-workload-identity-pool-provider.go - About 1 hr to fix

        Function New has 10 return statements (exceeds 4 allowed).
        Open

        func New(ctx context.Context, projectID, impersonateServiceAccount string) (*GCP, error) {
            gcp := &GCP{
                Organizations: make([]*Organization, 0),
                Projects:      make([]*Project, 0),
                Regions:       []string{"global"},
        Severity: Major
        Found in pkg/gcputil/gcp.go - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  for _, org := range resp.Organizations {
                      newOrg := &Organization{
                          Name:        org.Name,
                          DisplayName: org.DisplayName,
                      }
          Severity: Minor
          Found in pkg/gcputil/gcp.go and 1 other location - About 45 mins to fix
          pkg/gcputil/gcp.go on lines 167..179

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 115.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  for _, project := range page.Projects {
                      newProject := &Project{
                          Name:      project.Name,
                          ProjectID: project.ProjectId,
                      }
          Severity: Minor
          Found in pkg/gcputil/gcp.go and 1 other location - About 45 mins to fix
          pkg/gcputil/gcp.go on lines 148..161

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 115.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function execute has 6 return statements (exceeds 4 allowed).
          Open

          func execute(c *cli.Context) error {
              ctx, cancel := context.WithCancel(c.Context)
              defer cancel()
          
              gcp, err := gcputil.New(ctx, c.String("project-id"), c.String("impersonate-service-account"))
          Severity: Major
          Found in pkg/commands/run/command.go - About 40 mins to fix

            Method FirebaseRealtimeDatabase.EmptyDefaultDatabase has 6 return statements (exceeds 4 allowed).
            Open

            func (r *FirebaseRealtimeDatabase) EmptyDefaultDatabase(ctx context.Context) error {
                if r.settings == nil {
                    return nil
                }
            
            
            Severity: Major
            Found in resources/firebase-realtime-database.go - About 40 mins to fix

              Method FirebaseDatabaseService.ListDatabaseInstances has 5 return statements (exceeds 4 allowed).
              Open

              func (s *FirebaseDatabaseService) ListDatabaseInstances(ctx context.Context, parent string) ([]*DatabaseInstance, error) {
                  url1 := fmt.Sprintf("%sv1beta/%s/instances", s.BasePath, parent)
                  logrus.Tracef("url: %s", url1)
              
                  req, err := http.NewRequestWithContext(ctx, http.MethodGet, url1, nil)
              Severity: Major
              Found in pkg/gcputil/firebase.go - About 35 mins to fix

                Method VPCGlobalIPAddress.HandleWait has 5 return statements (exceeds 4 allowed).
                Open

                func (r *VPCGlobalIPAddress) HandleWait(ctx context.Context) error {
                    if r.removeOp == nil {
                        return nil
                    }
                
                
                Severity: Major
                Found in resources/vpc-global-ip-address.go - About 35 mins to fix

                  Method ComputeForwardingRule.HandleWait has 5 return statements (exceeds 4 allowed).
                  Open

                  func (r *ComputeForwardingRule) HandleWait(ctx context.Context) error {
                      if r.removeOp == nil {
                          return nil
                      }
                  
                  
                  Severity: Major
                  Found in resources/compute-forwarding-rule.go - About 35 mins to fix

                    Method CloudFunctionLister.List has 5 return statements (exceeds 4 allowed).
                    Open

                    func (l *CloudFunctionLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
                        var resources []resource.Resource
                    
                        opts := o.(*nuke.ListerOpts)
                        if err := opts.BeforeList(nuke.Regional, "cloudfunctions.googleapis.com"); err != nil {
                    Severity: Major
                    Found in resources/cloud-function.go - About 35 mins to fix

                      Method VPCNetwork.HandleWait has 5 return statements (exceeds 4 allowed).
                      Open

                      func (r *VPCNetwork) HandleWait(ctx context.Context) error {
                          if r.removeOp == nil {
                              return nil
                          }
                      
                      
                      Severity: Major
                      Found in resources/vpc-network.go - About 35 mins to fix

                        Method GKECluster.HandleWait has 5 return statements (exceeds 4 allowed).
                        Open

                        func (r *GKECluster) HandleWait(ctx context.Context) error {
                            if r.removeOp == nil {
                                return nil
                            }
                        
                        
                        Severity: Major
                        Found in resources/gke-cluster.go - About 35 mins to fix

                          Method FirebaseRealtimeDatabaseLister.List has 5 return statements (exceeds 4 allowed).
                          Open

                          func (l *FirebaseRealtimeDatabaseLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
                              var resources []resource.Resource
                          
                              opts := o.(*nuke.ListerOpts)
                              if err := opts.BeforeList(nuke.Regional, "firebasedatabase.googleapis.com"); err != nil {
                          Severity: Major
                          Found in resources/firebase-realtime-database.go - About 35 mins to fix

                            Method ComputeTargetHTTPSProxy.HandleWait has 5 return statements (exceeds 4 allowed).
                            Open

                            func (r *ComputeTargetHTTPSProxy) HandleWait(ctx context.Context) error {
                                if r.removeOp == nil {
                                    return nil
                                }
                            
                            
                            Severity: Major
                            Found in resources/compute-target-https-proxy.go - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language