Showing 28 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) {
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) {
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 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 {
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,
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 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 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 {