Skip to content

Clean up pre-existing golangci-lint findings on main #5

Description

@henryjarend

Background

lint.yml was workflow_dispatch-only before #2, so golangci-lint never
actually ran automatically in CI against this codebase. Wiring it to run on
push/PR (#2) surfaced 42 pre-existing findings on main, unrelated to any
in-flight feature work. Tracking here so they can be cleaned up as a
dedicated PR rather than mixed into feature branches.

Reference run: https://github.com/InterWorks/typesense-operator/actions/runs/33202281929/job/98954432885

Findings by linter

  • gocyclo (4) — functions over the complexity-30 threshold:
    • internal/controller/typesensecluster_controller.go:117 Reconcile (37)
    • internal/controller/typesensecluster_httproute.go:24 ReconcileHttpRoute (33)
    • internal/controller/typesensecluster_ingress.go:60 ReconcileIngress (53)
    • internal/controller/typesensecluster_quorum.go:25 ReconcileQuorum (39)
  • staticcheck (14):
    • typesensecluster_configmap.go:179,328,338 — remove embedded Client from selector (QF1008)
    • typesensecluster_configmap.go:273 — ineffective break in nested loop, may not break outer loop as intended (SA4011)
    • typesensecluster_httproute.go:73,148 — assigned httpRoute value never used (SA4006)
    • typesensecluster_httproute.go:283 — remove embedded CommonRouteSpec from selector (QF1008)
    • typesensecluster_ingress.go:646,647,649 — remove embedded ObjectMeta from selector (QF1008)
    • typesensecluster_quorum.go:146 — use strings.ReplaceAll instead of strings.Replace(..., -1) (QF1004)
    • utils.go:237 (internal/controller) — remove embedded VolumeSource from selector (QF1008)
    • test/utils/utils.go:25 — dot import (ST1001)
    • test/utils/utils.go:138 — use strings.ReplaceAll (QF1004)
  • unused (5):
    • typesensecluster_quorum_helpers.go:227 getHealthyReadLagThreshold unused
    • internal/controller/utils.go:35 generateSecureRandomString unused
    • internal/controller/utils.go:203-207 minDelayPerReplicaFactor, maxDelayPerReplicaFactor, getDelayPerReplicaFactor unused
  • unparam (4) — unused first return value:
    • typesensecluster_configmap.go:92 updateConfigMap (*v1.ConfigMap)
    • typesensecluster_httproute.go:345 createReferenceGrant (*ReferenceGrant)
    • typesensecluster_services.go:160 createService (*v1.Service)
    • internal/controller/utils.go:218 contains (int)
  • revive (3)api/v1alpha1/typesensecluster_types_httproute.go:30-32 comment-spacing (//// +optional etc. need a space after //)
  • nakedret (3)typesensecluster_quorum_helpers.go:260,269,295 naked returns in getHealthyLagThresholds (41 lines, over the naked-return line limit)
  • errcheck (2) — unchecked resp.Body.Close():
    • typesensecluster_quorum_helpers.go:45
    • typesensecluster_quorum_helpers.go:131
  • goimports (2) — files not properly formatted:
    • typesensecluster_quorum_types.go:4
    • typesensecluster_secret.go:5
  • ineffassign (2)typesensecluster_quorum.go:334,336 assignments to conditionReason/conditionStatus never read
  • misspell (1)typesensecluster_quorum.go:109 commitedcommitted
  • prealloc (1)typesensecluster_ingress.go:401 var filters []string could be pre-allocated
  • unconvert (1)typesensecluster_quorum_helpers.go:192 unnecessary type conversion

Acceptance criteria

  • make lint passes clean with no exemptions added beyond what's already in .golangci.yml
  • No behavior change — this is lint-only cleanup (verify with make test / make test-e2e)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions