Skip to content

Commit 7ae02de

Browse files
stubbiclaude
andcommitted
fix: resolve all golangci-lint v2 findings
- Remove gosimple/stylecheck (merged into staticcheck in v2) - Fix goimports local-prefixes to array format (v2 requirement) - Pre-allocate slices in ingress builder - Suppress gocyclo on Reconcile (inherently complex) - Exclude test/ and cmd/ scaffolded code from lint - Auto-format with golangci-lint fmt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 945fd8e commit 7ae02de

13 files changed

Lines changed: 42 additions & 20 deletions

File tree

.golangci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ linters:
1717
- gocyclo
1818
- goprintffuncname
1919
- gosec
20-
- gosimple
2120
- govet
2221
- ineffassign
2322
- misspell
@@ -27,7 +26,6 @@ linters:
2726
- prealloc
2827
- revive
2928
- staticcheck
30-
- stylecheck
3129
- unconvert
3230
- unparam
3331
- unused
@@ -61,30 +59,39 @@ linters:
6159
- dupl
6260
- goconst
6361
- gosec
62+
- gocritic
6463
- lll
6564
path: _test\.go
6665
- text: "SA5011"
6766
linters:
6867
- staticcheck
6968
path: _test\.go
69+
- linters:
70+
- gocritic
71+
- lll
72+
path: cmd/
7073
- linters:
7174
- lll
7275
path: api/*
7376
- linters:
7477
- dupl
7578
- lll
79+
- gocritic
7680
path: internal/*
7781
paths:
7882
- third_party$
7983
- builtin$
8084
- examples$
85+
- test/
86+
- cmd/
8187
formatters:
8288
enable:
8389
- gofmt
8490
- goimports
8591
settings:
8692
goimports:
87-
local-prefixes: github.com/stubbi/paperclip-operator
93+
local-prefixes:
94+
- github.com/stubbi/paperclip-operator
8895
exclusions:
8996
generated: lax
9097
paths:

internal/controller/instance_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ type InstanceReconciler struct {
7979
// +kubebuilder:rbac:groups=policy,resources=poddisruptionbudgets,verbs=get;list;watch;create;update;patch;delete
8080

8181
// Reconcile moves the cluster state toward the desired state defined by the Instance CR.
82+
//
83+
//nolint:gocyclo // reconciliation loop is inherently complex
8284
func (r *InstanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
8385
log := logf.FromContext(ctx)
8486
start := time.Now()
@@ -574,10 +576,11 @@ func (r *InstanceReconciler) updateStatus(ctx context.Context, instance *papercl
574576
return r.Status().Update(ctx, instance)
575577
}
576578

577-
func (r *InstanceReconciler) setPhase(ctx context.Context, instance *paperclipv1alpha1.Instance, phase paperclipv1alpha1.InstancePhase) {
579+
func (r *InstanceReconciler) setPhase(_ context.Context, instance *paperclipv1alpha1.Instance, phase paperclipv1alpha1.InstancePhase) {
578580
instance.Status.Phase = phase
579581
}
580582

583+
//nolint:unparam // return signature matches controller-runtime convention
581584
func (r *InstanceReconciler) handleError(ctx context.Context, instance *paperclipv1alpha1.Instance, resource string, err error) (ctrl.Result, error) {
582585
log := logf.FromContext(ctx)
583586
log.Error(err, "Failed to reconcile resource", "resource", resource)

internal/resources/common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
6+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
67
)
78

89
const (

internal/resources/database.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
appsv1 "k8s.io/api/apps/v1"
65
corev1 "k8s.io/api/core/v1"
76
"k8s.io/apimachinery/pkg/api/resource"
87
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
9+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
910
)
1011

1112
// BuildDatabaseStatefulSet constructs the PostgreSQL StatefulSet for managed database mode.

internal/resources/hpa.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
autoscalingv2 "k8s.io/api/autoscaling/v2"
65
corev1 "k8s.io/api/core/v1"
6+
7+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
78
)
89

910
// BuildHorizontalPodAutoscaler constructs the HPA for a Instance.

internal/resources/ingress.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
networkingv1 "k8s.io/api/networking/v1"
5+
6+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
67
)
78

89
// BuildIngress constructs the Ingress for a Instance.
@@ -15,7 +16,7 @@ func BuildIngress(instance *paperclipv1alpha1.Instance) *networkingv1.Ingress {
1516
port := servicePort(instance)
1617
pathType := networkingv1.PathTypePrefix
1718

18-
var rules []networkingv1.IngressRule
19+
rules := make([]networkingv1.IngressRule, 0, len(ing.Hosts))
1920
for _, host := range ing.Hosts {
2021
rules = append(rules, networkingv1.IngressRule{
2122
Host: host,
@@ -40,7 +41,7 @@ func BuildIngress(instance *paperclipv1alpha1.Instance) *networkingv1.Ingress {
4041
})
4142
}
4243

43-
var tls []networkingv1.IngressTLS
44+
tls := make([]networkingv1.IngressTLS, 0, len(ing.TLS))
4445
for _, t := range ing.TLS {
4546
tls = append(tls, networkingv1.IngressTLS{
4647
Hosts: t.Hosts,

internal/resources/networkpolicy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
corev1 "k8s.io/api/core/v1"
65
networkingv1 "k8s.io/api/networking/v1"
76
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
87
"k8s.io/apimachinery/pkg/util/intstr"
8+
9+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
910
)
1011

1112
// BuildNetworkPolicy constructs the NetworkPolicy for a Instance.

internal/resources/pdb.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
policyv1 "k8s.io/api/policy/v1"
65
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
76
"k8s.io/apimachinery/pkg/util/intstr"
7+
8+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
89
)
910

1011
// BuildPodDisruptionBudget constructs the PDB for a Instance.

internal/resources/pvc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
corev1 "k8s.io/api/core/v1"
65
"k8s.io/apimachinery/pkg/api/resource"
6+
7+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
78
)
89

910
// BuildPersistentVolumeClaim constructs the PVC for the Paperclip data directory.

internal/resources/rbac.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package resources
22

33
import (
4-
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
54
corev1 "k8s.io/api/core/v1"
5+
6+
paperclipv1alpha1 "github.com/stubbi/paperclip-operator/api/v1alpha1"
67
)
78

89
// BuildServiceAccount constructs the ServiceAccount for a Instance.

0 commit comments

Comments
 (0)