lint: fix all 24 goconst findings (repeated string literals) #178

Open
opened 2026-08-07 18:40:49 +02:00 by clawbot · 0 comments
Collaborator

Surveyed 2026-08-07: golangci-lint 2.12.2 reports 24 goconst
findings on main — repeated string literals that should be named
constants. Breakdown:

Production code (10):

  • internal/handlers/app.go: error (14×), App (8×), status
    (6×), Error (5×), logs (4×)
  • internal/handlers/webhook_events.go: App (8×)
  • internal/handlers/setup.go: Error (5×)
  • internal/handlers/api.go: error (14×)

Test code (14):

  • internal/service/app/app_test.go: repo URL fixtures (2 findings)
  • internal/service/webhook/webhook_test.go: main, X-Gitea-Event,
    X-GitHub-Event, Push Hook (4 findings)
  • internal/middleware/realip_test.go: IP fixtures (6 findings)
  • internal/middleware/ratelimit_test.go: 10.0.0.1:1234 (1 finding)
  • internal/handlers/handlers_test.go: secret, main (2 findings)
  • internal/docker/validation_test.go: main (1 finding)

Remediation: extract package-level (or test-file-level) constants with
meaningful names — e.g. template data keys (App, Error) in
handlers, header names and branch fixtures in tests. Where the same
literal appears in both app.go and api.go/webhook_events.go,
share one constant in the handlers package rather than duplicating.

Definition of done:

  • make lint (golangci-lint ≥ 2.12) reports zero goconst findings
  • no //nolint directives added; no behavior change
  • make test passes; make fmt run before commit
  • TODO.md updated per the repo workflow
  • lands via PR from a feature branch off main
Surveyed 2026-08-07: golangci-lint 2.12.2 reports 24 `goconst` findings on `main` — repeated string literals that should be named constants. Breakdown: Production code (10): - `internal/handlers/app.go`: `error` (14×), `App` (8×), `status` (6×), `Error` (5×), `logs` (4×) - `internal/handlers/webhook_events.go`: `App` (8×) - `internal/handlers/setup.go`: `Error` (5×) - `internal/handlers/api.go`: `error` (14×) Test code (14): - `internal/service/app/app_test.go`: repo URL fixtures (2 findings) - `internal/service/webhook/webhook_test.go`: `main`, `X-Gitea-Event`, `X-GitHub-Event`, `Push Hook` (4 findings) - `internal/middleware/realip_test.go`: IP fixtures (6 findings) - `internal/middleware/ratelimit_test.go`: `10.0.0.1:1234` (1 finding) - `internal/handlers/handlers_test.go`: `secret`, `main` (2 findings) - `internal/docker/validation_test.go`: `main` (1 finding) Remediation: extract package-level (or test-file-level) constants with meaningful names — e.g. template data keys (`App`, `Error`) in handlers, header names and branch fixtures in tests. Where the same literal appears in both `app.go` and `api.go`/`webhook_events.go`, share one constant in the `handlers` package rather than duplicating. Definition of done: - `make lint` (golangci-lint ≥ 2.12) reports zero `goconst` findings - no `//nolint` directives added; no behavior change - `make test` passes; `make fmt` run before commit - `TODO.md` updated per the repo workflow - lands via PR from a feature branch off `main`
clawbot added this to the 1.1.0 milestone 2026-08-07 18:40:49 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/upaas#178