Showing 76 of 82 total issues
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{}) {
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) {
Method Config.patchConditions
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (c *Config) patchConditions(ctx context.Context, conditionStatus metav1.ConditionStatus, reason k8upv1.ConditionReason, message string, condition k8upv1.ConditionType) {
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{}) {
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) {
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) {
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")
- 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
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
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
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
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
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 {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if in.Paths != nil {
in, out := &in.Paths, &out.Paths
*out = new([]string)
if **in != nil {
in, out := *in, *out
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 103.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if in.Tags != nil {
in, out := &in.Tags, &out.Tags
*out = new([]string)
if **in != nil {
in, out := *in, *out
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 103.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (in *PreBackupPodSpec) DeepCopyInto(out *PreBackupPodSpec) {
*out = *in
if in.Pod != nil {
in, out := &in.Pod, &out.Pod
*out = new(Pod)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 102.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (in *ArchiveSpec) DeepCopyInto(out *ArchiveSpec) {
*out = *in
if in.RestoreSpec != nil {
in, out := &in.RestoreSpec, &out.RestoreSpec
*out = new(RestoreSpec)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 102.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76