k8up-io/k8up

View on GitHub

Showing 76 of 82 total issues

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 SetSucceeded has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func SetSucceeded(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 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 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

            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

              Function RunRestore has a Cognitive Complexity of 22 (exceeds 20 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: Minor
              Found in cmd/cli/main.go - About 35 mins 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

              Function backupAnnotatedPods has 5 return statements (exceeds 4 allowed).
              Open

              func backupAnnotatedPods(ctx context.Context, resticCLI *resticCli.Restic, mainLogger logr.Logger) error {
                  _, serviceErr := os.Stat("/var/run/secrets/kubernetes.io")
                  _, kubeconfigErr := os.Stat(cfg.Config.KubeConfig)
              
                  if serviceErr != nil && kubeconfigErr != nil {
              Severity: Major
              Found in cmd/restic/main.go - About 35 mins to fix

                Method Restic.isRestoreSingleFile has 5 return statements (exceeds 4 allowed).
                Open

                func (r *Restic) isRestoreSingleFile(log logr.Logger, snapshot dto.Snapshot) (bool, error) {
                    buf := bytes.Buffer{}
                
                    opts := CommandOptions{
                        Path:   r.resticPath,
                Severity: Major
                Found in restic/cli/restore.go - About 35 mins to fix

                  Method Client.Connect has 5 return statements (exceeds 4 allowed).
                  Open

                  func (c *Client) Connect(ctx context.Context) error {
                      u, err := url.Parse(c.Endpoint)
                      if err != nil {
                          return fmt.Errorf("error parsing S3 Endpoint URL: %w", err)
                      }
                  Severity: Major
                  Found in restic/s3/client.go - About 35 mins to fix

                    Method BackupReconciler.Provision has 5 return statements (exceeds 4 allowed).
                    Open

                    func (r *BackupReconciler) Provision(ctx context.Context, obj *k8upv1.Backup) (reconcile.Result, error) {
                        log := controllerruntime.LoggerFrom(ctx)
                    
                        repository := cfg.Config.GetGlobalRepository()
                        if obj.Spec.Backend != nil {
                    Severity: Major
                    Found in operator/backupcontroller/controller.go - About 35 mins to fix

                      Method BackupExecutor.createServiceAccountAndBinding has 5 return statements (exceeds 4 allowed).
                      Open

                      func (b *BackupExecutor) createServiceAccountAndBinding(ctx context.Context) error {
                          sa := &corev1.ServiceAccount{}
                          sa.Name = cfg.Config.ServiceAccount
                          sa.Namespace = b.backup.Namespace
                          _, err := controllerruntime.CreateOrUpdate(ctx, b.Config.Client, sa, func() error {
                      Severity: Major
                      Found in operator/backupcontroller/backup_utils.go - About 35 mins to fix

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

                            if in.Paths != nil {
                                in, out := &in.Paths, &out.Paths
                                *out = new([]string)
                                if **in != nil {
                                    in, out := *in, *out
                        Severity: Minor
                        Found in api/v1/zz_generated.deepcopy.go and 1 other location - About 35 mins to fix
                        api/v1/zz_generated.deepcopy.go on lines 360..368

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

                        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

                            if in.Tags != nil {
                                in, out := &in.Tags, &out.Tags
                                *out = new([]string)
                                if **in != nil {
                                    in, out := *in, *out
                        Severity: Minor
                        Found in api/v1/zz_generated.deepcopy.go and 1 other location - About 35 mins to fix
                        api/v1/zz_generated.deepcopy.go on lines 1342..1350

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

                        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 (in *PreBackupPodSpec) DeepCopyInto(out *PreBackupPodSpec) {
                            *out = *in
                            if in.Pod != nil {
                                in, out := &in.Pod, &out.Pod
                                *out = new(Pod)
                        Severity: Minor
                        Found in api/v1/zz_generated.deepcopy.go and 1 other location - About 30 mins to fix
                        api/v1/zz_generated.deepcopy.go on lines 94..101

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

                        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 (in *ArchiveSpec) DeepCopyInto(out *ArchiveSpec) {
                            *out = *in
                            if in.RestoreSpec != nil {
                                in, out := &in.RestoreSpec, &out.RestoreSpec
                                *out = new(RestoreSpec)
                        Severity: Minor
                        Found in api/v1/zz_generated.deepcopy.go and 1 other location - About 30 mins to fix
                        api/v1/zz_generated.deepcopy.go on lines 659..666

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language