Invert if statement to reduce nesting in archive parser

Signed-off-by: Dan Luhring <dan.luhring@anchore.com>
This commit is contained in:
Dan Luhring
2021-01-27 10:34:52 -05:00
parent 0ccfee03f1
commit 1416e3cb7a
+4 -2
View File
@@ -178,7 +178,10 @@ func (j *archiveParser) discoverPkgsFromPomProperties(parentPkg *pkg.Package) ([
return nil, fmt.Errorf("failed to parse pom.properties (%s): %w", j.virtualPath, err) return nil, fmt.Errorf("failed to parse pom.properties (%s): %w", j.virtualPath, err)
} }
if propsObj != nil { if propsObj == nil {
continue
}
if propsObj.Version != "" && propsObj.ArtifactID != "" { if propsObj.Version != "" && propsObj.ArtifactID != "" {
// TODO: if there is no parentPkg (no java manifest) one of these poms could be the parent. We should discover the right parent and attach the correct info accordingly to each discovered package // TODO: if there is no parentPkg (no java manifest) one of these poms could be the parent. We should discover the right parent and attach the correct info accordingly to each discovered package
@@ -241,7 +244,6 @@ func (j *archiveParser) discoverPkgsFromPomProperties(parentPkg *pkg.Package) ([
} }
} }
} }
}
return pkgs, nil return pkgs, nil
} }