Showing 34 of 82 total issues
Method Suite.SetCondition
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
resource client.Object,
conditions *[]metav1.Condition,
cType k8upv1.ConditionType,
status metav1.ConditionStatus,
reason k8upv1.ConditionReason) {
Method Config.SetConditionFalseWithMessage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *Config) SetConditionFalseWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{}) {
Method Config.SetConditionTrueWithMessage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *Config) SetConditionTrueWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{}) {
Function SetSucceeded
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func SetSucceeded(ctx context.Context, name, ns string, typ k8upv1.JobType, objStatus *k8upv1.Status, message string) {
Method BackupReconciler.Provision
has 5 return statements (exceeds 4 allowed). Open
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 {
Method Client.Connect
has 5 return statements (exceeds 4 allowed). Open
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)
}
Method Configuration.validatePrune
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *Configuration) validatePrune() error {
if !c.DoPrune {
return nil
}
Method BackupExecutor.createServiceAccountAndBinding
has 5 return statements (exceeds 4 allowed). Open
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 {
Method Restic.isRestoreSingleFile
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *Restic) isRestoreSingleFile(log logr.Logger, snapshot dto.Snapshot) (bool, error) {
buf := bytes.Buffer{}
opts := CommandOptions{
Path: r.resticPath,
Function RunRestore
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func RunRestore(ctx *cli.Context) error {
var restoreName, snapshot string
var s3, pvc v1.RestoreMethod
logger := cmd.AppLogger(ctx).WithName("cli-restore")
- Read upRead up
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
Open
func operatorMain(c *cli.Context) error {
operatorLog := cmd.AppLogger(c).WithName("operator")
operatorLog.Info("initializing")
ctrl.SetLogger(operatorLog)
Function PodExec
has 5 return statements (exceeds 4 allowed). Open
Open
func PodExec(pod BackupPod, log logr.Logger) (*ExecData, error) {
execLogger := log.WithName("k8sExec")
config, _ := getClientConfig()
k8sclient, err := kubernetes.NewForConfig(config)
if err != nil {
Function doNonBackupTasks
has 5 return statements (exceeds 4 allowed). Open
Open
func doNonBackupTasks(resticCLI *resticCli.Restic) error {
if err := doPrune(resticCLI); err != nil {
return err
}
Function backupAnnotatedPods
has 5 return statements (exceeds 4 allowed). Open
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 {