Skip to content

Enforce-readiness: 5 unenforced linters (writebytestring, lenstringsplit, stringreplaceminusone, osgetenvlibrary, ossetenvlibrar [Content truncated due to length] #49469

Description

@github-actions

Summary

Five registered custom analyzers are absent from the CI LINTER_FLAGS gate (.github/workflows/cgo.yml:1362/1365) but are clean against the current codebase (./cmd/... ./pkg/..., default build). All five should be promoted to enforced, following the same pattern as the last enforce-readiness batches (#47916, #46341, #45629, #45186).

Evidence

writebytestring
lenstringsplit
stringreplaceminusone
  • Grep of strings.Replace( across pkg/ (non-test) finds 13 production call sites, but every one passes an explicit n=1 (intentional single-replacement), not n=-1. The only -1 occurrence in non-test code is inside the linter's own doc comment (pkg/linters/stringreplaceminusone/stringreplaceminusone.go:102).
  • Zero production violations of the actual strings.Replace(s, old, new, -1)strings.ReplaceAll pattern.
osgetenvlibrary / ossetenvlibrary
  • osgetenvlibrary excludes main//cmd/ packages via pass.Pkg.Path() and resolves the callee through astutil.CalledOSFunc (type-resolved: fn.Pkg().Path() != "os", not syntactic name-matching — no IsPkgSelector-class bug here).
  • 10 production call sites exist across pkg/logger, pkg/envutil, pkg/constants, pkg/parser, pkg/github, pkg/consoleevery single one already carries //nolint:osgetenvlibrary, i.e. deliberately-suppressed process-boundary env reads (e.g. DEBUG, ACCESSIBLE, NO_COLOR).
  • os.Setenv( has zero call sites anywhere in pkg/ outside pkg/cli/pkg/lintersossetenvlibrary has nothing to flag at all in its scope.
  • Zero unsuppressed production violations for both.

Recommendation

Add all five flags to both LINTER_FLAGS invocations in .github/workflows/cgo.yml (line 1362 default-build gate, line 1365 GOOS=js GOARCH=wasm gate):

-writebytestring -lenstringsplit -stringreplaceminusone -osgetenvlibrary -ossetenvlibrary

Validation checklist

  • make golint-custom LINTER_FLAGS="-writebytestring -lenstringsplit -stringreplaceminusone -osgetenvlibrary -ossetenvlibrary -test=false" reports zero findings on ./cmd/... ./pkg/...
  • Same command under GOOS=js GOARCH=wasm with LINTER_PACKAGES="./pkg/console ./pkg/parser ./pkg/styles ./pkg/tty ./pkg/workflow" reports zero findings
  • Add the five flags to both cgo.yml LINTER_FLAGS lines

Effort

Trivial — CI config change only, no source changes required.

Generated by 🤖 Sergo - Serena Go Expert · agent · 177.3 AIC · ⌖ 6.07 AIC · ⊞ 6K ·

  • expires on Aug 7, 2026, 9:03 PM UTC-08:00

Metadata

Metadata

Labels

cookieIssue Monster Loves Cookies!sergo

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions