k8up-io/k8up

View on GitHub

Showing 28 of 82 total issues

File zz_generated.deepcopy.go has 1192 lines of code (exceeds 500 allowed). Consider refactoring.
Open

//go:build !ignore_autogenerated

// Code generated by controller-gen. DO NOT EDIT.

package v1
Severity: Major
Found in api/v1/zz_generated.deepcopy.go - About 2 days to fix

    Function RunRestore has 136 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func RunRestore(ctx *cli.Context) error {
        var restoreName, snapshot string
        var s3, pvc v1.RestoreMethod
        logger := cmd.AppLogger(ctx).WithName("cli-restore")
    
    
    Severity: Major
    Found in cmd/cli/main.go - About 4 hrs to fix

      Method BackupExecutor.startBackup has 96 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (b *BackupExecutor) startBackup(ctx context.Context) error {
          ready, err := b.StartPreBackup(ctx)
          if err != nil {
              return err
          }
      Severity: Major
      Found in operator/backupcontroller/executor.go - About 2 hrs to fix

        Method BackupExecutor.listAndFilterPVCs has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
        Open

        func (b *BackupExecutor) listAndFilterPVCs(ctx context.Context, annotation string) ([]backupItem, error) {
            log := controllerruntime.LoggerFrom(ctx)
        
            pods := &corev1.PodList{}
            pvcPodMap := make(map[string]corev1.Pod)
        Severity: Minor
        Found in operator/backupcontroller/executor.go - About 2 hrs to fix

        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 BackupExecutor.listAndFilterPVCs has 78 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (b *BackupExecutor) listAndFilterPVCs(ctx context.Context, annotation string) ([]backupItem, error) {
            log := controllerruntime.LoggerFrom(ctx)
        
            pods := &corev1.PodList{}
            pvcPodMap := make(map[string]corev1.Pod)
        Severity: Major
        Found in operator/backupcontroller/executor.go - About 2 hrs to fix

          Method BackupExecutor.startBackup has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
          Open

          func (b *BackupExecutor) startBackup(ctx context.Context) error {
              ready, err := b.StartPreBackup(ctx)
              if err != nil {
                  return err
              }
          Severity: Minor
          Found in operator/backupcontroller/executor.go - About 1 hr to fix

          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 Backend.DeepCopyInto has 64 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (in *Backend) DeepCopyInto(out *Backend) {
              *out = *in
              if in.RepoPasswordSecretRef != nil {
                  in, out := &in.RepoPasswordSecretRef, &out.RepoPasswordSecretRef
                  *out = new(corev1.SecretKeySelector)
          Severity: Minor
          Found in api/v1/zz_generated.deepcopy.go - About 1 hr to fix

            Method ScheduleSpec.DeepCopyInto has 52 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (in *ScheduleSpec) DeepCopyInto(out *ScheduleSpec) {
                *out = *in
                if in.Restore != nil {
                    in, out := &in.Restore, &out.Restore
                    *out = new(RestoreSchedule)
            Severity: Minor
            Found in api/v1/zz_generated.deepcopy.go - About 1 hr to fix

              Method PodLister.ListPods has 51 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (p *PodLister) ListPods() ([]BackupPod, error) {
                  p.log.Info("listing all pods", "annotation", p.backupCommandAnnotation, "namespace", p.namespace)
              
                  if p.err != nil {
                      return nil, p.err
              Severity: Minor
              Found in restic/kubernetes/pod_list.go - About 1 hr to fix

                Method Restic.Prune has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (r *Restic) Prune(tags ArrayOpts) error {
                    prunelogger := r.logger.WithName("prune")
                
                    prunelogger.Info("pruning repository")
                
                
                Severity: Minor
                Found in restic/cli/prune.go - About 1 hr to fix

                  Method BackupExecutor.startBackup has 10 return statements (exceeds 4 allowed).
                  Open

                  func (b *BackupExecutor) startBackup(ctx context.Context) error {
                      ready, err := b.StartPreBackup(ctx)
                      if err != nil {
                          return err
                      }
                  Severity: Major
                  Found in operator/backupcontroller/executor.go - About 1 hr to fix

                    Function RunRestore has 8 return statements (exceeds 4 allowed).
                    Open

                    func RunRestore(ctx *cli.Context) error {
                        var restoreName, snapshot string
                        var s3, pvc v1.RestoreMethod
                        logger := cmd.AppLogger(ctx).WithName("cli-restore")
                    
                    
                    Severity: Major
                    Found in cmd/cli/main.go - About 50 mins to fix

                      Method ScheduleHandler.createJobList has 7 return statements (exceeds 4 allowed).
                      Open

                      func (s *ScheduleHandler) createJobList(ctx context.Context) error {
                          type objectInstantiator struct {
                              spec k8upv1.ScheduleSpecInterface
                              ctor func(spec k8upv1.ScheduleSpecInterface) k8upv1.JobObject
                          }
                      Severity: Major
                      Found in operator/schedulecontroller/handler.go - About 45 mins to fix

                        Function NewPodLister has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func NewPodLister(ctx context.Context, k8cli client.Client, backupCommandAnnotation, fileExtensionAnnotation, backupContainerAnnotation, namespace string, targetPods []string, skipPreBackup bool, log logr.Logger) *PodLister {
                        Severity: Minor
                        Found in restic/kubernetes/pod_list.go - About 45 mins to fix

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

                          func generatePemFile(clientCert string, clientKey string, dest string) error {
                              certIn, err := os.Open(clientCert)
                              if err != nil {
                                  return err
                              }
                          Severity: Major
                          Found in restic/cli/utils.go - About 40 mins to fix

                            Method Config.SetConditionFalseWithMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            func (c *Config) SetConditionFalseWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{}) {
                            Severity: Minor
                            Found in operator/job/status.go - About 35 mins to fix

                              Method Config.SetConditionTrueWithMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              func (c *Config) SetConditionTrueWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{}) {
                              Severity: Minor
                              Found in operator/job/status.go - About 35 mins to fix

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

                                func SetFailed(ctx context.Context, name, ns string, typ k8upv1.JobType, objStatus *k8upv1.Status, message string) {
                                Severity: Minor
                                Found in operator/job/job.go - About 35 mins to fix

                                  Method Config.patchConditions has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  func (c *Config) patchConditions(ctx context.Context, conditionStatus metav1.ConditionStatus, reason k8upv1.ConditionReason, message string, condition k8upv1.ConditionType) {
                                  Severity: Minor
                                  Found in operator/job/status.go - About 35 mins to fix

                                    Method Suite.SetCondition has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        resource client.Object,
                                        conditions *[]metav1.Condition,
                                        cType k8upv1.ConditionType,
                                        status metav1.ConditionStatus,
                                        reason k8upv1.ConditionReason) {
                                    Severity: Minor
                                    Found in envtest/envsuite.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language