Skip to content

Make staticcheck blocking in make check and CI, and fix its 67 findings (#923) - #938

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/923
Oct 15, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/923

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #923.

The bug

make check step 3 was staticcheck ./... || echo "staticcheck not installed, skipping...". || fires on any non-zero exit, and staticcheck exits 1 when it reports findings. So the step said "not installed" about an installed tool and passed. CI ran no linter at all. 67 findings had built up on main.

The gate

  • make check-staticcheck (called by make check): if command -v staticcheck …; then staticcheck ./...; else echo "…skipping…"; fi. Findings now fail the step. Only a missing binary skips, and it says so.
  • CI (ci.yml, after Vet): installs staticcheck 2026.2.2 (v0.8.2) the same way gitleaks is installed (Security workflow downloads the gitleaks binary with no checksum #885). The version and the SHA-256 are both pinned in the workflow, and the hash is not read from the release's .sha256 file. I checked the pinned hash against the published staticcheck_linux_amd64.tar.gz.sha256. The binary goes into $RUNNER_TEMP and onto $GITHUB_PATH, with no sudo. CI then runs staticcheck ./... directly, not the make target, so a missing binary fails in CI instead of skipping.

The 67 findings

finding fix
SA1019 parser.ParseDir (api_surface_test.go) Migrated to os.ReadDir + parser.ParseFile with the same filter. The committed snapshot is unchanged and TestPublicAPISurface passes.
SA1019 ecdsa.PublicKey.X/.Y (sporedinstall/windows.go) Migrated to PublicKey.Bytes() (SEC 1 04‖X‖Y, already 32 bytes per coordinate). New TestP256CoordinatesRoundTripFixedWidth round-trips the coordinates through ecdsa.ParseUncompressedPublicKey and makes sure a leading-zero coordinate occurs. Watched it fail against an unpadded revert that compiles.
SA1019 rsa.DecryptPKCS1v15 / EncryptPKCS1v15 (aws/windows_password*.go, 3 sites) lint:ignore. EC2 GetPasswordData uses PKCS #1 v1.5 by AWS's definition, so it is not ours to change.
SA1019 feature/s3/manager (agent/queue_runner, aws/imagebuilder, pipeline/data_handoff, staging; 16 sites) lint:ignore on each line, pointing to #932 (filed). transfermanager is not a drop-in swap: different API shape and different part-size, concurrency and checksum defaults, and three of the four sites run in spored on instances.
ST1005 "Slack …" ×3 (bot.go), "Windows …" (launch_preflight.go) lint:ignore: proper nouns, and lowercasing them would misspell them.
ST1005 trailing period (launch_preflight.go hibernation error) Period dropped, matching its EFA/MPI siblings. This is the only user-visible text change.
ST1005 + ST1012 (aws/placement_retry_test.go) inUseErr renamed to errInUse. ST1005 gets a lint:ignore because the text is EC2's verbatim error, and the classifier must match what EC2 sends.
SA1012 nil ctx ×4 (launch_sweep_detached_keys_test.go) context.Background(). These tests do not exercise nil-context handling.
SA4000 f(x) != f(x) (aws/iam_test.go) Assigned to two variables first. The determinism check is unchanged.
U1000 errEmptyProcStat, isRecentActivity (agent/agent.go) Moved to sys_linux.go, their only caller. These were GOOS-dependent: dead on darwin/windows, live on linux.
U1000 unused flag vars ×4 (sweepgroup.go) Deleted. The flags bind the shared resume*/collect* vars. Comparing the two trees turned up #935 (filed): spawn sweep resume lacks --max-concurrent-auto.
U1000 dead test helpers (inert_flags_test, taskpool/worker_test, userdata/storage_efs_retry_test) Deleted. stubBinDNSFails was orphaned when #718 reversed the mount order.
U1000 ×22 test/e2e/helpers.go The file had no build tag, but every user is a real-AWS tier. Gave it //go:build e2e_tier1 || e2e_tier2 || e2e_tier3, the same constraint as reaper.go. go vet -tags e2e_tier{0,1,2,3} ./test/e2e/ is clean for each tier.

The lint:ignores are all line-scoped and all cite #923 or #932. None is file-wide. staticcheck reports an ignore that no longer matches anything, so none of them can outlive its reason.

Evidence

  • staticcheck ./... → exit 0. Also clean with GOOS=linux and with GOTOOLCHAIN=go1.26.9 GOOS=linux, which is CI's toolchain. Local is go1.27.2.
  • Gate watched failing: a probe file pkg/ecrref/zz_gate_probe.go with an unused func, which compiles, made make check-staticcheck report func deliberatelyUnused923 is unused (U1000) and exit 2. With the probe removed, exit 0.
  • Skip path: with staticcheck off PATH, the target prints staticcheck not installed, skipping (CI runs the version pinned in .github/workflows/ci.yml) and exits 0.
  • Install step: I extracted it from ci.yml and ran it locally. The checksum verifies, and with one hash digit changed it fails with exit 1.
  • make check: everything passes except the known TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, which needs a running Docker daemon. make check-nested: all 9 nested modules clean.

Caveats

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.73913% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/agent/sys_linux.go 0.00% 31 Missing ⚠️
pkg/sporedinstall/windows.go 33.33% 2 Missing and 2 partials ⚠️
cmd/launch_preflight.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Heads-up from #974 (fixes #932): it migrates all 16 feature/s3/manager uses that this PR suppresses with //lint:ignore SA1019 ... (#932). Whichever of the two lands second has to drop those ignores. If #974 merges first, the ignores here become unused directives and conflict on the edited lines, so delete them when you rebase. If this merges first, #974 will be rebased to delete them.

@scttfrdmn
scttfrdmn merged commit 989fd20 into main Oct 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/923 branch October 15, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make check's staticcheck step can never fail: '|| echo not installed' swallows real findings (67 on main)

1 participant