Skip to content

Commit e154dbf

Browse files
committed
ci(linter): enable several linters
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent a33a934 commit e154dbf

23 files changed

+256
-260
lines changed

.golangci.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
run:
22
timeout: 10m
33
issues-exit-code: 1
4+
max-issues-per-linter: 0
5+
max-same-issues: 0
46
tests: true
57
skip-dirs-use-default: true
68
modules-download-mode: readonly
@@ -9,13 +11,20 @@ run:
911
linters:
1012
fast: false
1113
enable:
12-
- gofmt
14+
- errcheck
15+
- exportloopref
16+
- gocritic
17+
- gofumpt
1318
- goimports
14-
- revive
15-
- govet
1619
- gomodguard
20+
- gosec
21+
- govet
1722
- misspell
18-
- exportloopref
23+
- revive
24+
- unconvert
25+
- unparam
26+
- unused
27+
- whitespace
1928
disable:
2029
- scopelint
2130
disable-all: false

apis/v1alpha2/validation/common.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ import (
2323
gatewayvalidationv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1/validation"
2424
)
2525

26-
var (
27-
// validateParentRefs validates ParentRefs SectionName must be set and uique
28-
// when ParentRefs includes 2 or more references to the same parent
29-
validateParentRefs = gatewayvalidationv1b1.ValidateParentRefs
30-
)
26+
// validateParentRefs validates ParentRefs SectionName must be set and uique
27+
// when ParentRefs includes 2 or more references to the same parent
28+
var validateParentRefs = gatewayvalidationv1b1.ValidateParentRefs
3129

3230
// validateBackendRefServicePort validates whether or not a port was specified
3331
// for a backendRef which refers to a corev1.Service, asserting that the port

apis/v1beta1/validation/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func ValidateParentRefs(parentRefs []gatewayv1b1.ParentReference, path *field.Pa
4141
}
4242
parentRefsSectionMap := make(map[sameKindParentRefs]sets.Set[parentQualifier])
4343
for i, p := range parentRefs {
44-
targetParentRefs := sameKindParentRefs{name: p.Name, namespace: *new(gatewayv1b1.Namespace), kind: *new(gatewayv1b1.Kind)}
44+
targetParentRefs := sameKindParentRefs{name: p.Name, namespace: gatewayv1b1.Namespace(""), kind: gatewayv1b1.Kind("")}
4545
pq := parentQualifier{}
4646
if p.Namespace != nil {
4747
targetParentRefs.namespace = *p.Namespace

apis/v1beta1/validation/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
2626
)
2727

28-
var path = *new(field.Path)
28+
var path = field.Path{}
2929

3030
func TestValidateParentRefs(t *testing.T) {
3131
namespace := gatewayv1b1.Namespace("example-namespace")

conformance/tests/gateway-modify-listeners.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ var GatewayModifyListeners = suite.ConformanceTest{
4343
},
4444
Manifests: []string{"tests/gateway-modify-listeners.yaml"},
4545
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
46-
4746
t.Run("should be able to add a listener that then becomes available for routing traffic", func(t *testing.T) {
4847
gwNN := types.NamespacedName{Name: "gateway-add-listener", Namespace: "gateway-conformance-infra"}
4948
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
@@ -93,7 +92,7 @@ var GatewayModifyListeners = suite.ConformanceTest{
9392
Conditions: []metav1.Condition{{
9493
Type: string(v1beta1.ListenerConditionAccepted),
9594
Status: metav1.ConditionTrue,
96-
Reason: "", //any reason
95+
Reason: "", // any reason
9796
}},
9897
AttachedRoutes: 1,
9998
},
@@ -106,7 +105,7 @@ var GatewayModifyListeners = suite.ConformanceTest{
106105
Conditions: []metav1.Condition{{
107106
Type: string(v1beta1.ListenerConditionAccepted),
108107
Status: metav1.ConditionTrue,
109-
Reason: "", //any reason
108+
Reason: "", // any reason
110109
}},
111110
AttachedRoutes: 1,
112111
},
@@ -165,7 +164,7 @@ var GatewayModifyListeners = suite.ConformanceTest{
165164
Conditions: []metav1.Condition{{
166165
Type: string(v1beta1.ListenerConditionAccepted),
167166
Status: metav1.ConditionTrue,
168-
Reason: "", //any reason
167+
Reason: "", // any reason
169168
}},
170169
AttachedRoutes: 1,
171170
},

conformance/tests/gateway-observed-generation-bump.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ var GatewayObservedGenerationBump = suite.ConformanceTest{
4242
},
4343
Manifests: []string{"tests/gateway-observed-generation-bump.yaml"},
4444
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
45-
4645
gwNN := types.NamespacedName{Name: "gateway-observed-generation-bump", Namespace: "gateway-conformance-infra"}
4746

4847
t.Run("observedGeneration should increment", func(t *testing.T) {

conformance/tests/gateway-with-attached-routes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{
5050
Conditions: []metav1.Condition{{
5151
Type: string(v1beta1.ListenerConditionAccepted),
5252
Status: metav1.ConditionTrue,
53-
Reason: "", //any reason
53+
Reason: "", // any reason
5454
}},
5555
AttachedRoutes: 1,
5656
}}
@@ -69,7 +69,7 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{
6969
Conditions: []metav1.Condition{{
7070
Type: string(v1beta1.ListenerConditionAccepted),
7171
Status: metav1.ConditionTrue,
72-
Reason: "", //any reason
72+
Reason: "", // any reason
7373
}},
7474
AttachedRoutes: 2,
7575
}}

conformance/tests/httproute-invalid-backendref-nonexistent.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,5 @@ var HTTPRouteInvalidNonExistentBackendRef = suite.ConformanceTest{
6666
Response: http.Response{StatusCode: 500},
6767
})
6868
})
69-
7069
},
7170
}

conformance/tests/httproute-invalid-backendref-unknown-kind.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,5 @@ var HTTPRouteInvalidBackendRefUnknownKind = suite.ConformanceTest{
6767
Response: http.Response{StatusCode: 500},
6868
})
6969
})
70-
7170
},
7271
}

conformance/tests/httproute-invalid-cross-namespace-backend-ref.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ var HTTPRouteInvalidCrossNamespaceBackendRef = suite.ConformanceTest{
4949
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
5050

5151
t.Run("HTTPRoute with a cross-namespace BackendRef and no ReferenceGrant has a ResolvedRefs Condition with status False and Reason RefNotPermitted", func(t *testing.T) {
52-
5352
resolvedRefsCond := metav1.Condition{
5453
Type: string(v1beta1.RouteConditionResolvedRefs),
5554
Status: metav1.ConditionFalse,
@@ -68,6 +67,5 @@ var HTTPRouteInvalidCrossNamespaceBackendRef = suite.ConformanceTest{
6867
Response: http.Response{StatusCode: 500},
6968
})
7069
})
71-
7270
},
7371
}

0 commit comments

Comments
 (0)