Skip to content

Commit 105349a

Browse files
🌱 simplify syntax
Signed-off-by: Alexandre Mahdhaoui <[email protected]>
1 parent 6449beb commit 105349a

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

hack/tools/cmd/gomodcheck/main.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,33 @@ func main() {
8080
// then we add the version and the ref to the list of out of sync modules.
8181
for mod, version := range projectModules {
8282
if _, ok := excludedMods[mod]; ok {
83-
logger.Infof("skipped excluded module: %s", mod)
83+
logger.Infof("skipped: %s", mod)
8484
continue
8585
}
8686

8787
if versionToRef, ok := upstreamModules[mod]; ok {
88-
upstreams := make([]upstream, 0)
88+
outOfSyncUpstream := make([]upstream, 0)
8989

9090
for upstreamVersion, upstreamRef := range versionToRef {
91-
if version != upstreamVersion {
92-
upstreams = append(upstreams, upstream{
93-
Ref: upstreamRef,
94-
Version: upstreamVersion,
95-
})
91+
if version == upstreamVersion { // pass if version in sync.
92+
continue
9693
}
97-
}
9894

99-
if len(upstreams) > 0 {
100-
oosMods = append(oosMods, oosMod{
101-
Name: mod,
102-
Version: version,
103-
Upstreams: upstreams,
95+
outOfSyncUpstream = append(outOfSyncUpstream, upstream{
96+
Ref: upstreamRef,
97+
Version: upstreamVersion,
10498
})
10599
}
100+
101+
if len(outOfSyncUpstream) == 0 { // pass if no out of sync upstreams.
102+
continue
103+
}
104+
105+
oosMods = append(oosMods, oosMod{
106+
Name: mod,
107+
Version: version,
108+
Upstreams: outOfSyncUpstream,
109+
})
106110
}
107111
}
108112

0 commit comments

Comments
 (0)