Skip to content

Commit

Permalink
Nits - APK installed optimizations (#227)
Browse files Browse the repository at this point in the history
Hello,

ported to APK installed parser common optimizations already merged for
DPKG in #168.
Additionally, a couple of staticcheck linter errors have been corrected
(I think!).
I saw the comments here:
https://github.com/google/osv-scanner/blob/fb4d2c4d8e4e59961db70121e31870593e045a4e/pkg/osvscanner/osvscanner.go#L39-L43
but after my change both lints and tests are ok so it's not clear to me
if comments are now out of date or if I'm missing something!

Comments have been introduced in #149.

Thank you,
Regards.
  • Loading branch information
cmaritan authored and hayleycd committed Mar 9, 2023
1 parent bf6ab52 commit 2191000
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/lockfile/apk-installed.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ func groupApkPackageLines(scanner *bufio.Scanner) [][]string {
for scanner.Scan() {
line := scanner.Text()

if line == "" {
if len(group) > 0 {
groups = append(groups, group)
}
group = make([]string, 0)

if line != "" {
group = append(group, line)
continue
}
group = append(group, line)
if len(group) > 0 {
groups = append(groups, group)
}
group = make([]string, 0)
}

if len(group) > 0 {
Expand Down Expand Up @@ -56,7 +55,7 @@ func parseApkPackageGroup(group []string, pathToLockfile string) PackageDetails
if pkg.Version == "" {
pkgPrintName := pkg.Name
if pkgPrintName == "" {
pkgPrintName = "<unknown>"
pkgPrintName = unknownPkgName
}

_, _ = fmt.Fprintf(
Expand Down

0 comments on commit 2191000

Please sign in to comment.