chore(lint): address pre-existing lint debt surfaced by golangci-lint v2.12.1 bump

Open
#163 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
64/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
github-actions, go
Domain
backend, ci-cd, tooling

Research direction

Start with the v2.12.1 CI output, .golangci.yml, and .github/workflows/ci.yml, then inspect the listed production and test files for goconst and modernize findings. Check existing seiv1alpha1 constants and the k8s.io/utils/ptr usage before changing helpers. Done means the full v2.12.1 run passes without only-new-issues, with no new //nolint directives or behavior changes.

Written by the indexing model from the issue text.

Description

Problem

PR #162 forced a bump of golangci-lint from v2.8.0v2.12.1 because the seictl v0.0.37 module dragged go.mod's go directive to 1.26.0 (seictl declares go 1.26.0 as a minimum), and v2.8.0 was built with go1.25 and refuses to lint a 1.26 module.

The newer linter surfaces ~50 pre-existing issues spanning the codebase. None of them are introduced by #162's diff — they are pre-existing tech debt newly visible.

To unblock #162, the workflow runs with only-new-issues: true so the diff itself is gated but the debt isn't surfaced as a blocker on every PR. This issue tracks paying that debt down.

Surface

Counts from the v2.12.1 run on commit 3a80a53:

  • 34 × goconst — repeated string literals flagged for extraction. Two buckets:

    • Generic K8s field names: "name", "namespace", "port", "action", "targetLabel", "data", "start", "true". These appear 3-6 times each in CRD / PrometheusRule / Service / pod-spec construction. Extracting these to constants is worseconst namespaceField = "namespace" adds confusion, not clarity. Right fix: bump goconst's min-occurrences threshold to 5 (or higher) in .golangci.yml so it stops flagging field names that just happen to recur.
    • Domain identifiers: "rpc", "validator", "archive", "exporter", "replayer", "evm", "grpc", "seid", "sei.io/nodedeployment", "chain". These are legitimate constants. Some likely already exist as exported constants somewhere in the codebase (e.g., seiv1alpha1.RoleValidator?) — should be re-used rather than duplicated.
  • 16 × modernize (newexpr) — strPtr(x) / boolPtr(x) / int32Ptr(x) / To(x) calls and helper-fn definitions. Mechanical fixes:

    • At call sites: strPtr("foo")func() *string { v := "foo"; return &v }() is wordy; usually the right move is to replace the helper with ptr.To(...) from k8s.io/utils/ptr (or pointer.String(...) from k8s.io/utils/pointer). Some call sites with zero-value args (strPtr("")) genuinely simplify to new(string).
    • At helper definitions (internal/controller/node/plan_execution_test.go:89 defines strPtr, etc.): replace with ptr.To import.
  • 1 × other — single residual flagged as (true) linter; likely revive's bool-literal-in-expr or similar. Easy.

Affected files (from CI log)

Production:

  • internal/controller/nodedeployment/{internal_service,monitoring,networking,nodes,per_pod_services}.go
  • internal/noderesource/noderesource.go
  • internal/task/bootstrap_resources.go

Tests:

  • internal/controller/node/{import_pvc,peers,plan_execution,reconciler,sidecar_probe_integration,plan_execution_integration}_test.go
  • internal/controller/nodedeployment/{internal_service,plan}_test.go
  • internal/planner/executor_test.go
  • internal/task/observe_image_test.go

Impact

Low-severity debt. The code works. The lint failure was a CI artifact of the linter version bump, not a regression in behavior.

Worth addressing because:

  • only-new-issues: true is a workaround that masks future debt accumulation in untouched files. A reader can introduce identical patterns to the existing-but-suppressed issues and the linter won't flag them as long as they don't appear in the PR diff.
  • goconst and modernize are both legitimately useful when calibrated. Tuning them once produces ongoing value.

Proposed approach

  1. .golangci.yml calibration — bump goconst.min-occurrences to 5 (silences generic-field-name noise). Keep the linter enabled for cases that genuinely warrant constants.
  2. Extract real constants for the domain identifiers in monitoring.go, networking.go, nodedeployment/*.go. Search first — seiv1alpha1 may already export some of these.
  3. modernize fixes — replace local strPtr/boolPtr/int32Ptr helpers with k8s.io/utils/ptr.To[T] (a generic that subsumes all three). Drop the helpers. Mechanical 1-line-per-site replacement.
  4. Remove only-new-issues: true from .github/workflows/ci.yml once the run is clean.

Estimated time: 30-45 min focused work. Could be one PR or split if the goconst constant extractions need code review.

Acceptance criteria

  • golangci-lint v2.12.1 run on main exits 0 without only-new-issues: true.
  • .golangci.yml is the only place that suppresses linter rules; no in-source //nolint directives added.
  • No behavior change — purely lint cleanup.

Out of scope

  • Bumping golangci-lint past v2.12.1 (latest as of filing). Future bumps may surface new rules; address those when they happen.
  • Migrating to a different linter framework or adding new linters.
  • The follow-up #161 work (drop taskParamser) — different concern, separate workstream.

References

🤖 Generated with Claude Code

Dominant language
Go
Stars
1
Forks
2
Avg merge
2h 29m
Merged PRs (30d)
56

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sei-protocol/sei-k8s-controller

All issues in sei-protocol/sei-k8s-controller

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.