k8up-io/k8up

View on GitHub

Showing 28 of 82 total issues

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