chore: gofmt the tree, clear staticcheck, add a CI gofmt gate

Nine files had drifted from gofmt and nothing checked; nine staticcheck
findings were live (three dead symbols, capitalization, a redundant
Sprintf, two literal-to-conversion sites, a nil test context). Fix all
of them and make CI fail on unformatted Go so this cannot re-drift.
This commit is contained in:
Lemon-miaow committed 2026-09-22 17:49:54 +08:00
1 parent a56c326518
commit a05edc934c
15 files changed
+56 -57

No files matched your search

+10 -10
View File
@@ -51,7 +51,7 @@ func TestWindowContains(t *testing.T) {
// The load-bearing invariants live here. Each row is a single component evaluated
// against a latest map, at a fixed `now`, asserting the Kind the plan must yield.
func TestPlanUpdatesInvariants(t *testing.T) {
now := time.Date(2026, 7, 1, 3, 30, 0, 0, time.UTC) // inside the window below
now := time.Date(2026, 7, 1, 3, 30, 0, 0, time.UTC) // inside the window below
openWin := Window{
Start: time.Date(2026, 7, 1, 3, 0, 0, 0, time.UTC),
End: time.Date(2026, 7, 1, 4, 0, 0, 0, time.UTC),
@@ -62,10 +62,10 @@ func TestPlanUpdatesInvariants(t *testing.T) {
}
cases := []struct {
name string
comp Component
latest string // "" ⇒ absent from the map (unknown latest)
want ActionKind
name string
comp Component
latest string // "" ⇒ absent from the map (unknown latest)
want ActionKind
}{
{
name: "pinned is never touched even with a newer stable upstream",
@@ -162,11 +162,11 @@ func TestPlanUpdatesPreservesOrderAndPending(t *testing.T) {
End: time.Date(2026, 7, 1, 4, 0, 0, 0, time.UTC),
}
comps := []Component{
{Name: "felis-api", Current: mustV(t, "1.4.0"), Policy: PolicyScheduled, Manageable: true, Window: win}, // apply
{Name: "k3s", Current: mustV(t, "v1.30.2+k3s1"), Policy: PolicyNotify, Manageable: true}, // notify
{Name: "cloudflared", Current: mustV(t, "2024.2.1"), Policy: PolicyScheduled, Manageable: true}, // no window ⇒ notify
{Name: "velocity", Current: mustV(t, "3.3.0"), Policy: PolicyScheduled, Manageable: false}, // off-cluster ⇒ notify
{Name: "mc-survival", Current: mustV(t, "1.20.1"), Policy: PolicyPinned}, // pinned
{Name: "felis-api", Current: mustV(t, "1.4.0"), Policy: PolicyScheduled, Manageable: true, Window: win}, // apply
{Name: "k3s", Current: mustV(t, "v1.30.2+k3s1"), Policy: PolicyNotify, Manageable: true}, // notify
{Name: "cloudflared", Current: mustV(t, "2024.2.1"), Policy: PolicyScheduled, Manageable: true}, // no window ⇒ notify
{Name: "velocity", Current: mustV(t, "3.3.0"), Policy: PolicyScheduled, Manageable: false}, // off-cluster ⇒ notify
{Name: "mc-survival", Current: mustV(t, "1.20.1"), Policy: PolicyPinned}, // pinned
}
latest := map[string]Version{
"felis-api": mustV(t, "1.5.0"),
+12 -12
View File
@@ -9,18 +9,18 @@ func TestParseTolerant(t *testing.T) {
pre string
}{
{"1.2.3", 1, 2, 3, ""},
{"v1.2.3", 1, 2, 3, ""}, // leading v
{"V1.2.3", 1, 2, 3, ""}, // leading V
{"v1.30.2+k3s1", 1, 30, 2, ""}, // k3s build suffix ignored
{"1.30.2+k3s1", 1, 30, 2, ""}, // build suffix, no v
{"2024.2.1", 2024, 2, 1, ""}, // cloudflared calendar version
{"1.2.3-rc.1", 1, 2, 3, "rc.1"}, // prerelease
{"v3.3.0-SNAPSHOT", 3, 3, 0, "SNAPSHOT"}, // velocity-style
{"1.2.3-rc.1+build.9", 1, 2, 3, "rc.1"}, // prerelease AND build
{"v0.0.0+g1a2b3c4", 0, 0, 0, ""}, // stamp of a build pinned to a ref with no tag behind it
{"v2", 2, 0, 0, ""}, // missing minor/patch fill 0
{"2.0", 2, 0, 0, ""}, // missing patch fills 0
{" v1.2.3 ", 1, 2, 3, ""}, // surrounding whitespace
{"v1.2.3", 1, 2, 3, ""}, // leading v
{"V1.2.3", 1, 2, 3, ""}, // leading V
{"v1.30.2+k3s1", 1, 30, 2, ""}, // k3s build suffix ignored
{"1.30.2+k3s1", 1, 30, 2, ""}, // build suffix, no v
{"2024.2.1", 2024, 2, 1, ""}, // cloudflared calendar version
{"1.2.3-rc.1", 1, 2, 3, "rc.1"}, // prerelease
{"v3.3.0-SNAPSHOT", 3, 3, 0, "SNAPSHOT"}, // velocity-style
{"1.2.3-rc.1+build.9", 1, 2, 3, "rc.1"}, // prerelease AND build
{"v0.0.0+g1a2b3c4", 0, 0, 0, ""}, // stamp of a build pinned to a ref with no tag behind it
{"v2", 2, 0, 0, ""}, // missing minor/patch fill 0
{"2.0", 2, 0, 0, ""}, // missing patch fills 0
{" v1.2.3 ", 1, 2, 3, ""}, // surrounding whitespace
}
for _, c := range cases {
v, err := Parse(c.in)