From 105349a24db40d371d0b37ceab1a77ab3d7a3c2d Mon Sep 17 00:00:00 2001 From: Alexandre Mahdhaoui Date: Sat, 27 Apr 2024 12:07:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1=20simplify=20syntax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexandre Mahdhaoui --- hack/tools/cmd/gomodcheck/main.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/hack/tools/cmd/gomodcheck/main.go b/hack/tools/cmd/gomodcheck/main.go index 45f0e6b96d..5cbaf377e2 100644 --- a/hack/tools/cmd/gomodcheck/main.go +++ b/hack/tools/cmd/gomodcheck/main.go @@ -80,29 +80,33 @@ func main() { // then we add the version and the ref to the list of out of sync modules. for mod, version := range projectModules { if _, ok := excludedMods[mod]; ok { - logger.Infof("skipped excluded module: %s", mod) + logger.Infof("skipped: %s", mod) continue } if versionToRef, ok := upstreamModules[mod]; ok { - upstreams := make([]upstream, 0) + outOfSyncUpstream := make([]upstream, 0) for upstreamVersion, upstreamRef := range versionToRef { - if version != upstreamVersion { - upstreams = append(upstreams, upstream{ - Ref: upstreamRef, - Version: upstreamVersion, - }) + if version == upstreamVersion { // pass if version in sync. + continue } - } - if len(upstreams) > 0 { - oosMods = append(oosMods, oosMod{ - Name: mod, - Version: version, - Upstreams: upstreams, + outOfSyncUpstream = append(outOfSyncUpstream, upstream{ + Ref: upstreamRef, + Version: upstreamVersion, }) } + + if len(outOfSyncUpstream) == 0 { // pass if no out of sync upstreams. + continue + } + + oosMods = append(oosMods, oosMod{ + Name: mod, + Version: version, + Upstreams: outOfSyncUpstream, + }) } }