Skip to content

Refactor: use == 0 instead of <= 0 for len(SCMProviders) check in applicationset.go #2132

Description

@coderabbitai

Summary

In controllers/argocd/applicationset.go, the condition checking whether SCMProviders is empty uses <= 0 instead of the more idiomatic == 0:

if len(appsetsSourceNamespaces) > 0 && (len(cr.Spec.ApplicationSet.SCMProviders) <= 0) {

also:

...fmt.Sprint(strings.Join(appsetsSourceNamespaces, ","))...

Since len() never returns a negative value, the <= 0 check should be replaced with == 0 for clarity and correctness.

Suggested Fix

if len(appsetsSourceNamespaces) > 0 && len(cr.Spec.ApplicationSet.SCMProviders) == 0 {

References

cc @nmirasch — you may want to pick this up as a small follow-up cleanup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions