Skip to content

Install golangci-lint and fix lint issues#43

Merged
riccardo-perotti merged 2 commits into
masterfrom
rp.ROP-9232.install-golangci-lint-in-scamp-go
Jun 8, 2026
Merged

Install golangci-lint and fix lint issues#43
riccardo-perotti merged 2 commits into
masterfrom
rp.ROP-9232.install-golangci-lint-in-scamp-go

Conversation

@riccardo-perotti

@riccardo-perotti riccardo-perotti commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Installs golangci-lint in CI and fixes all reported issues (~85, across 22 files). Lint clean (0 issues); go build, go vet, and tests pass. Pure lint-fix — zero runtime behavior change.

CI

Added a lint job to .github/workflows/build.yml (golangci/golangci-lint-action@v6, Go 1.26), alongside the existing build job and reusing its actions/setup-go@v5 setup. No .golangci.yml — default linters, matching the sibling rollout repos.

Fixes by category

  • errcheck (28+): _ = / _, _ = on intentionally-ignored returns (Write, Flush, Close, Register, RemoveClient, Output, Gettimeofday, deferred closes, etc.).
  • SA1019: io/ioutilos.ReadFile (service.go, ticket.go, scamp.go, tests).
  • ST1005: lowercased capitalized error strings (interpolated values unchanged) across connection.go, requester.go, packetheader.go, mocked.go.
  • staticcheck simplifications: if/else if chains → tagged switch (connection.go packetType, requester.go Envelope); make(x,n,n)make(x,n); s[a:len(s)]s[a:]; buffer.Bytes()/string(buffer.Bytes())buffer.String(); strings.Replace(…,-1)ReplaceAll; removed redundant returns in void funcs and an empty else.
  • ineffassign: fixed two ineffectual assignments in packet.go ReadPacket.
  • unused / dead-code removal (17): unused vars/fields/funcs/types — incl. a main() defined inside package scamp (never an entrypoint) + its only callers (doFakeDiscoveryCache, doCertFingerprint) in scamp.go; an unstarted periodic-stats loop (serviceStats/gatherStats/printStatsLoop, stats.go); unused test helpers. No exported API removed; TLS/dial/wire-protocol paths untouched.
  • S1000: for { select { case m, ok := <-ch } }for m := range ch in client.splitReqsAndReps (range over a channel exits on close exactly as the old !ok branch did — behavior-identical).

Deferred — two pre-existing latent bugs (NOT fixed here; tracked in a separate ticket)

golangci-lint surfaced two genuine latent bugs. Per the behavior-preservation mandate they are left exactly as-is (the dead assignments the linter flagged were removed without changing behavior), and filed separately:

  1. serviceproxy.go newServiceProxy — malformed announce data can panic (index out of range): length checks set err but don't return. Original (panicking) behavior preserved.
  2. connection.go Send — write errors on a closed/broken connection are swallowed (returns nil = success). SA4006 flagged the dead assignment; removing it preserves the original swallow-on-error behavior exactly.

Ticket created for the above issues: https://gudtech.atlassian.net/browse/ROP-9245

Jira Tickets

https://gudtech.atlassian.net/browse/ROP-9232

🤖 Generated with Claude Code

riccardo-perotti and others added 2 commits June 8, 2026 11:54
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@riccardo-perotti riccardo-perotti merged commit f54c2d7 into master Jun 8, 2026
4 checks passed
@riccardo-perotti riccardo-perotti deleted the rp.ROP-9232.install-golangci-lint-in-scamp-go branch June 8, 2026 17:55
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.

1 participant