Skip to content

Commit d7ffed9

Browse files
committed
refactor: merge path params
Signed-off-by: Gareth Jones <[email protected]>
1 parent 1660fea commit d7ffed9

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tools/osv-linter/internal/pkgchecker/version_check.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func versionsExistInGeneric(
2121
versions []string,
2222
eco string,
2323
packageInstanceURL string,
24-
releasesPath string,
2524
versionsPath string,
2625
) error {
2726
resp, err := faulttolerant.Get(packageInstanceURL)
@@ -40,11 +39,9 @@ func versionsExistInGeneric(
4039
}
4140
// Fetch all known versions of package.
4241
versionsInRepository := []string{}
43-
releases := gjson.GetBytes(respJSON, releasesPath)
44-
releases.ForEach(func(key, value gjson.Result) bool {
45-
versionsInRepository = append(versionsInRepository, value.Get(versionsPath).String())
46-
return true // keep iterating.
47-
})
42+
for _, result := range gjson.GetBytes(respJSON, versionsPath).Array() {
43+
versionsInRepository = append(versionsInRepository, result.String())
44+
}
4845
// Determine which referenced versions are missing.
4946
versionsMissing := []string{}
5047
for _, versionToCheckFor := range versions {
@@ -81,7 +78,7 @@ func versionsExistInCrates(pkg string, versions []string) error {
8178
pkg, versions,
8279
"crates.io",
8380
packageInstanceURL,
84-
"versions", "num",
81+
"versions.#.num",
8582
)
8683
}
8784

@@ -207,7 +204,7 @@ func versionsExistInHackage(pkg string, versions []string) error {
207204
pkg, versions,
208205
"Hackage",
209206
packageInstanceURL,
210-
"@keys", "@this",
207+
"@keys",
211208
)
212209
}
213210

@@ -219,7 +216,7 @@ func versionsExistInNpm(pkg string, versions []string) error {
219216
pkg, versions,
220217
"npm",
221218
packageInstanceURL,
222-
"versions.@keys", "@this",
219+
"versions.@keys",
223220
)
224221
}
225222

@@ -231,7 +228,7 @@ func versionsExistInPackagist(pkg string, versions []string) error {
231228
pkg, versions,
232229
"Packagist",
233230
packageInstanceURL,
234-
fmt.Sprintf("packages.%s", pkg), "version",
231+
fmt.Sprintf("packages.%s.#.version", pkg),
235232
)
236233
}
237234

@@ -246,7 +243,7 @@ func versionsExistInPyPI(pkg string, versions []string) error {
246243
pkg, versions,
247244
"PyPI",
248245
packageInstanceURL,
249-
"releases.@keys", "@this",
246+
"releases.@keys",
250247
)
251248
}
252249

@@ -258,6 +255,6 @@ func versionsExistInRubyGems(pkg string, versions []string) error {
258255
pkg, versions,
259256
"RubyGems",
260257
packageInstanceURL,
261-
"@this", "number",
258+
"@this.#.number",
262259
)
263260
}

0 commit comments

Comments
 (0)