Skip to content

Unnecessary conditions in the code #245

Closed
@dholbach

Description

@dholbach

From Ada Logics

In the following code, the auto.Spec.Update is not needed, and if indeed auto.Spec.Update was nil then the first conditional statement would be panic due to a nil-dereference.

manifestsPath := tmp
if auto.Spec.Update.Path != "" {
tracelog.Info("adjusting update path according to .spec.update.path", "base", tmp, "spec-path", auto.Spec.Update.Path)
if p, err := securejoin.SecureJoin(tmp, auto.Spec.Update.Path); err != nil {
return failWithError(err)
} else {
manifestsPath = p
}
}
switch {
case auto.Spec.Update != nil && auto.Spec.Update.Strategy == imagev1.UpdateStrategySetters:

Recommendation
Remove unnecessary code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions