Skip to content

CI lint blind spot: build-constrained (*_wasm.go) files escape all 39 custom analyzers — proven by an un-migrated sprintfint sit [Content truncated due to length] #42645

Description

@github-actions

Summary

The custom linter driver runs multichecker.Main(...) over ./cmd/... ./pkg/... (Makefile:725) under the CI host's default build (GOOS=linux, no -tags). go/packages therefore never loads files gated by other build constraints, so every //go:build js || wasm file — roughly 20 *_wasm.go production files across pkg/console, pkg/workflow, pkg/parser, pkg/styles, pkg/tty — is invisible to all 39 custom analyzers, including the 16 CI-enforced ones.

This is not theoretical. It has already let a real violation drift in.

Concrete proof: a hidden sprintfint true-positive

The default-build and wasm variants of renderContext diverged when the strconv.Itoa conversion was applied to only one side:

File (build) Line Code
pkg/console/console.go (default) 110 lineNumWidth := len(strconv.Itoa(maxLineNum)) ✅ converted
pkg/console/console_wasm.go (js||wasm) 41 lineNumWidth := len(fmt.Sprintf("%d", maxLineNum)) ❌ un-migrated

maxLineNum := err.Position.Line + len(err.Context)/2 is int (console_types.go:6 Line int), so console_wasm.go:41 is an exact sprintfint violation. The default sibling was already fixed; the wasm sibling was silently missed because the linter never analyzes it. Any of the 16 enforced analyzers could have similar undetected drift in the wasm implementation.

Recommendations

  1. Fix the concrete drift — convert console_wasm.go:41 to match its sibling:
    • len(fmt.Sprintf("%d", maxLineNum))len(strconv.Itoa(maxLineNum))
    • add "strconv" to the imports of console_wasm.go (it currently imports only fmt, os, strings; fmt is still used elsewhere in the file, e.g. :47).
  2. Close the blind spot — add a second custom-lint pass covering the wasm build in cgo.yml, e.g. run make golint-custom a second time with GOOS=js GOARCH=wasm (or a -tags variant) so *_wasm.go files are analyzed. Sequence after step 1 so the new pass starts green.

Validation checklist

  • console_wasm.go:41 uses strconv.Itoa; strconv imported; go build for GOOS=js GOARCH=wasm ./cmd/gh-aw-wasm still compiles.
  • A wasm-targeted lint pass runs the custom analyzers over *_wasm.go files in CI.
  • Grep confirms no other Sprintf("%d", <int>) (or other enforced-linter patterns) remain in build-tagged files.

Effort: S for the concrete fix; M for the CI second-pass wiring.

Generated by 🤖 Sergo - Serena Go Expert · 252.6 AIC · ⌖ 13.6 AIC · ⊞ 5.9K ·

  • expires on Jul 7, 2026, 9:22 PM UTC-08:00

Metadata

Metadata

Labels

cookieIssue Monster Loves Cookies!sergo

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions