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

    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 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 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 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 Configuration.validatePrune has 5 return statements (exceeds 4 allowed).
              Open

              func (c *Configuration) validatePrune() error {
                  if !c.DoPrune {
                      return nil
                  }
              
              
              Severity: Major
              Found in restic/cfg/config.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

                  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

                    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 operatorMain has 5 return statements (exceeds 4 allowed).
                    Open

                    func operatorMain(c *cli.Context) error {
                        operatorLog := cmd.AppLogger(c).WithName("operator")
                        operatorLog.Info("initializing")
                        ctrl.SetLogger(operatorLog)
                    
                    
                    Severity: Major
                    Found in cmd/operator/main.go - About 35 mins to fix

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

                      func PodExec(pod BackupPod, log logr.Logger) (*ExecData, error) {
                          execLogger := log.WithName("k8sExec")
                          config, _ := getClientConfig()
                          k8sclient, err := kubernetes.NewForConfig(config)
                          if err != nil {
                      Severity: Major
                      Found in restic/kubernetes/pod_exec.go - About 35 mins to fix

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

                        func doNonBackupTasks(resticCLI *resticCli.Restic) error {
                            if err := doPrune(resticCLI); err != nil {
                                return err
                            }
                        
                        
                        Severity: Major
                        Found in cmd/restic/main.go - About 35 mins to fix

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