k8up-io/k8up

View on GitHub

Showing 76 of 82 total issues

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

func (in *PruneList) DeepCopyInto(out *PruneList) {
    *out = *in
    out.TypeMeta = in.TypeMeta
    in.ListMeta.DeepCopyInto(&out.ListMeta)
    if in.Items != nil {
Severity: Major
Found in api/v1/zz_generated.deepcopy.go and 7 other locations - About 1 hr to fix
api/v1/zz_generated.deepcopy.go on lines 41..52
api/v1/zz_generated.deepcopy.go on lines 269..280
api/v1/zz_generated.deepcopy.go on lines 411..422
api/v1/zz_generated.deepcopy.go on lines 627..638
api/v1/zz_generated.deepcopy.go on lines 843..854
api/v1/zz_generated.deepcopy.go on lines 1147..1158
api/v1/zz_generated.deepcopy.go on lines 1299..1310

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 167.

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 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

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

    func (c *CheckExecutor) attachTLSVolumeMounts() []corev1.VolumeMount {
        var tlsVolumeMounts []corev1.VolumeMount
        if c.check.Spec.Backend != nil && !utils.ZeroLen(c.check.Spec.Backend.VolumeMounts) {
            tlsVolumeMounts = append(tlsVolumeMounts, *c.check.Spec.Backend.VolumeMounts...)
        }
    Severity: Major
    Found in operator/checkcontroller/executor.go and 2 other locations - About 1 hr to fix
    operator/prunecontroller/executor.go on lines 144..151
    operator/backupcontroller/executor.go on lines 307..314

    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 149.

    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 3 locations. Consider refactoring.
    Open

    func (b *BackupExecutor) attachTLSVolumeMounts() []corev1.VolumeMount {
        var tlsVolumeMounts []corev1.VolumeMount
        if b.backup.Spec.Backend != nil && !utils.ZeroLen(b.backup.Spec.Backend.VolumeMounts) {
            tlsVolumeMounts = append(tlsVolumeMounts, *b.backup.Spec.Backend.VolumeMounts...)
        }
    Severity: Major
    Found in operator/backupcontroller/executor.go and 2 other locations - About 1 hr to fix
    operator/prunecontroller/executor.go on lines 144..151
    operator/checkcontroller/executor.go on lines 112..119

    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 149.

    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 3 locations. Consider refactoring.
    Open

    func (p *PruneExecutor) attachTLSVolumeMounts() []corev1.VolumeMount {
        var tlsVolumeMounts []corev1.VolumeMount
        if p.prune.Spec.Backend != nil && !utils.ZeroLen(p.prune.Spec.Backend.VolumeMounts) {
            tlsVolumeMounts = append(tlsVolumeMounts, *p.prune.Spec.Backend.VolumeMounts...)
        }
    Severity: Major
    Found in operator/prunecontroller/executor.go and 2 other locations - About 1 hr to fix
    operator/backupcontroller/executor.go on lines 307..314
    operator/checkcontroller/executor.go on lines 112..119

    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 149.

    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

                        S3: &v1.S3Spec{
                            Endpoint: restore.Cfg.S3Endpoint,
                            Bucket:   restore.Cfg.S3Bucket,
                            AccessKeyIDSecretRef: &corev1.SecretKeySelector{
                                Key: restore.Cfg.S3SecretRefUsernameKey,
    Severity: Major
    Found in cmd/cli/main.go and 1 other location - About 1 hr to fix
    cmd/cli/main.go on lines 279..294

    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 144.

    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

            S3: &v1.S3Spec{
                Endpoint: restore.Cfg.RestoreToS3Endpoint,
                Bucket:   restore.Cfg.RestoreToS3Bucket,
                AccessKeyIDSecretRef: &corev1.SecretKeySelector{
                    Key: restore.Cfg.RestoreToS3SecretUsernameKey,
    Severity: Major
    Found in cmd/cli/main.go and 1 other location - About 1 hr to fix
    cmd/cli/main.go on lines 324..339

    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 144.

    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

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

        if in.VolumeMounts != nil {
            in, out := &in.VolumeMounts, &out.VolumeMounts
            *out = new([]corev1.VolumeMount)
            if **in != nil {
                in, out := *in, *out
    Severity: Major
    Found in api/v1/zz_generated.deepcopy.go and 1 other location - About 1 hr to fix
    api/v1/zz_generated.deepcopy.go on lines 892..902

    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 138.

    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

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

        if in.VolumeMounts != nil {
            in, out := &in.VolumeMounts, &out.VolumeMounts
            *out = new([]corev1.VolumeMount)
            if **in != nil {
                in, out := *in, *out
    Severity: Major
    Found in api/v1/zz_generated.deepcopy.go and 1 other location - About 1 hr to fix
    api/v1/zz_generated.deepcopy.go on lines 218..228

    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 138.

    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 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 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 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

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

          func SetSucceeded(ctx context.Context, name, ns string, typ k8upv1.JobType, objStatus *k8upv1.Status, message string) {
              log := controllerruntime.LoggerFrom(ctx)
          
              if !objStatus.HasSucceeded() {
                  // only increase success counter if new condition
          Severity: Major
          Found in operator/job/job.go and 1 other location - About 1 hr to fix
          operator/job/job.go on lines 143..153

          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 132.

          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

          func SetFailed(ctx context.Context, name, ns string, typ k8upv1.JobType, objStatus *k8upv1.Status, message string) {
              log := controllerruntime.LoggerFrom(ctx)
          
              if !objStatus.HasFailed() {
                  // only increase fail counter if new condition
          Severity: Major
          Found in operator/job/job.go and 1 other location - About 1 hr to fix
          operator/job/job.go on lines 132..142

          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 132.

          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

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

              restoreOptions := resticCli.RestoreOptions{
                  RestoreType:   resticCli.RestoreType(cfg.Config.RestoreType),
                  RestoreDir:    cfg.Config.RestoreDir,
                  RestoreFilter: cfg.Config.RestoreFilter,
                  Verify:        cfg.Config.VerifyRestore,
          Severity: Major
          Found in cmd/restic/main.go and 1 other location - About 1 hr to fix
          cmd/restic/main.go on lines 218..229

          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 130.

          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

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

              restoreOptions := resticCli.RestoreOptions{
                  RestoreType:   resticCli.RestoreType(cfg.Config.RestoreType),
                  RestoreDir:    cfg.Config.RestoreDir,
                  RestoreFilter: cfg.Config.RestoreFilter,
                  Verify:        cfg.Config.VerifyRestore,
          Severity: Major
          Found in cmd/restic/main.go and 1 other location - About 1 hr to fix
          cmd/restic/main.go on lines 243..254

          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 130.

          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 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

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

            func RandomStringGenerator(n int) string {
                var characters = []rune("abcdefghijklmnopqrstuvwxyz1234567890")
                rand.New(rand.NewSource(time.Now().UnixNano()))
                b := make([]rune, n)
                for i := range b {
            Severity: Minor
            Found in cli/restore/helpers.go and 1 other location - About 50 mins to fix
            operator/utils/utils.go on lines 15..23

            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 120.

            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

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

            func RandomStringGenerator(n int) string {
                var characters = []rune("abcdefghijklmnopqrstuvwxyz1234567890")
                rand.New(rand.NewSource(time.Now().UnixNano()))
                b := make([]rune, n)
                for i := range b {
            Severity: Minor
            Found in operator/utils/utils.go and 1 other location - About 50 mins to fix
            cli/restore/helpers.go on lines 8..16

            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 120.

            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 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
              Severity
              Category
              Status
              Source
              Language