Showing 34 of 82 total issues
File zz_generated.deepcopy.go
has 1192 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
//go:build !ignore_autogenerated
// Code generated by controller-gen. DO NOT EDIT.
package v1
Function RunRestore
has 136 lines of code (exceeds 50 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")
Method BackupExecutor.startBackup
has 96 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (b *BackupExecutor) startBackup(ctx context.Context) error {
ready, err := b.StartPreBackup(ctx)
if err != nil {
return err
}
Method BackupExecutor.listAndFilterPVCs
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
Open
func (b *BackupExecutor) listAndFilterPVCs(ctx context.Context, annotation string) ([]backupItem, error) {
log := controllerruntime.LoggerFrom(ctx)
pods := &corev1.PodList{}
pvcPodMap := make(map[string]corev1.Pod)
- 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
Method BackupExecutor.listAndFilterPVCs
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (b *BackupExecutor) listAndFilterPVCs(ctx context.Context, annotation string) ([]backupItem, error) {
log := controllerruntime.LoggerFrom(ctx)
pods := &corev1.PodList{}
pvcPodMap := make(map[string]corev1.Pod)
Method BackupExecutor.startBackup
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
Open
func (b *BackupExecutor) startBackup(ctx context.Context) error {
ready, err := b.StartPreBackup(ctx)
if err != nil {
return err
}
- 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
Method Backend.DeepCopyInto
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (in *Backend) DeepCopyInto(out *Backend) {
*out = *in
if in.RepoPasswordSecretRef != nil {
in, out := &in.RepoPasswordSecretRef, &out.RepoPasswordSecretRef
*out = new(corev1.SecretKeySelector)
Method ScheduleSpec.DeepCopyInto
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (in *ScheduleSpec) DeepCopyInto(out *ScheduleSpec) {
*out = *in
if in.Restore != nil {
in, out := &in.Restore, &out.Restore
*out = new(RestoreSchedule)
Method Restic.Prune
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (r *Restic) Prune(tags ArrayOpts) error {
prunelogger := r.logger.WithName("prune")
prunelogger.Info("pruning repository")
Function PodExec
has 51 lines of code (exceeds 50 allowed). Consider refactoring. 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 {
Method PodLister.ListPods
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
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
Method BackupExecutor.startBackup
has 10 return statements (exceeds 4 allowed). Open
Open
func (b *BackupExecutor) startBackup(ctx context.Context) error {
ready, err := b.StartPreBackup(ctx)
if err != nil {
return err
}
Function RunRestore
has 8 return statements (exceeds 4 allowed). Open
Open
func RunRestore(ctx *cli.Context) error {
var restoreName, snapshot string
var s3, pvc v1.RestoreMethod
logger := cmd.AppLogger(ctx).WithName("cli-restore")
Function NewPodLister
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewPodLister(ctx context.Context, k8cli client.Client, backupCommandAnnotation, fileExtensionAnnotation, backupContainerAnnotation, namespace string, targetPods []string, skipPreBackup bool, log logr.Logger) *PodLister {
Method ScheduleHandler.createJobList
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *ScheduleHandler) createJobList(ctx context.Context) error {
type objectInstantiator struct {
spec k8upv1.ScheduleSpecInterface
ctor func(spec k8upv1.ScheduleSpecInterface) k8upv1.JobObject
}
Function generatePemFile
has 6 return statements (exceeds 4 allowed). Open
Open
func generatePemFile(clientCert string, clientKey string, dest string) error {
certIn, err := os.Open(clientCert)
if err != nil {
return err
}
Function SetFailed
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func SetFailed(ctx context.Context, name, ns string, typ k8upv1.JobType, objStatus *k8upv1.Status, message string) {
Method Config.patchConditions
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *Config) patchConditions(ctx context.Context, conditionStatus metav1.ConditionStatus, reason k8upv1.ConditionReason, message string, condition k8upv1.ConditionType) {
Method Restic.folderRestore
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (r *Restic) folderRestore(restoreDir string, snapshot dto.Snapshot, restoreFilter string, verify bool, log logr.Logger) error {
Method Config.SetConditionUnknownWithMessage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *Config) SetConditionUnknownWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{}) {