Skip to content

Commit 0ad4c4c

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

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

hack/tools/cmd/gomodcheck/main.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,28 @@ func main() {
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)