Skip to content

Commit d540f36

Browse files
authored
Add more linters (#2092)
Problem: We want to catch errors and styling issues as early as possible. Solution: Enable new linters.
1 parent 97fb223 commit d540f36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+130
-106
lines changed

.github/.cache/buster-for-binary

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
touts zoosporangium viner glucolipin galeproof sanctionment siper galeproof glucolipin fructiculture

.github/.cache/buster-for-unit-tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tzolkin sacristy hymnwise curative debris preachification suscept spongiculture medicably craniomete

.github/.cache/buster-for-vars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
brandenburgs singleheartedly coal-whipper transmutations Tarandian arquebus cropland drumskin intern

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
4444
with:
4545
go-version: stable
46+
cache-dependency-path: |
47+
go.sum
48+
.github/.cache/buster-for-vars
4649
4750
- name: Check for changes
4851
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -81,6 +84,9 @@ jobs:
8184
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
8285
with:
8386
go-version: stable
87+
cache-dependency-path: |
88+
go.sum
89+
.github/.cache/buster-for-unit-tests
8490
8591
- name: Run Tests
8692
run: make unit-test
@@ -136,6 +142,9 @@ jobs:
136142
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
137143
with:
138144
go-version: stable
145+
cache-dependency-path: |
146+
go.sum
147+
.github/.cache/buster-for-binary
139148
140149
- name: Create/Update Draft
141150
uses: lucacome/draft-release@8a63d32c79a171ae6048e614a8988f0ac3ed56d4 # v1.1.0

.golangci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,55 @@ linters-settings:
3737
- fieldalignment
3838
lll:
3939
line-length: 120
40+
dupword:
41+
ignore:
42+
- "test"
4043
linters:
4144
enable:
45+
- asasalint
4246
- asciicheck
47+
- dupword
4348
- errcheck
49+
- errname
4450
- errorlint
51+
- exportloopref
52+
- fatcontext
4553
- ginkgolinter
54+
- gocheckcompilerdirectives
4655
- gocyclo
56+
- godot
4757
- gofmt
4858
- gofumpt
4959
- goimports
5060
- gosec
5161
- gosimple
62+
- gosmopolitan
5263
- govet
5364
- ineffassign
65+
- intrange
5466
- lll
67+
- loggercheck
5568
- makezero
5669
- misspell
5770
- nilerr
5871
- noctx
72+
- nolintlint
5973
- predeclared
74+
- promlinter
75+
- reassign
6076
- revive
77+
- spancheck
6178
- staticcheck
79+
- stylecheck
80+
- tenv
81+
- thelper
6282
- typecheck
6383
- unconvert
6484
- unparam
6585
- unused
86+
- usestdlibvars
6687
- wastedassign
88+
- whitespace
6789
disable-all: true
6890
issues:
6991
max-issues-per-linter: 0

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ check-golangci-lint:
188188

189189
.PHONY: lint
190190
lint: check-golangci-lint ## Run golangci-lint against code
191-
golangci-lint run
191+
golangci-lint run --fix
192192

193193
.PHONY: unit-test
194194
unit-test: ## Run unit tests for the go code

apis/v1alpha1/clientsettingspolicy_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type ClientKeepAlive struct {
108108
}
109109

110110
// ClientKeepAliveTimeout defines the timeouts related to keep-alive client connections.
111-
// Default: Default: https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout.
111+
// Default: https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout.
112112
type ClientKeepAliveTimeout struct {
113113
// Server sets the timeout during which a keep-alive client connection will stay open on the server side.
114114
// Setting this value to 0 disables keep-alive client connections.

apis/v1alpha1/register.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
// GroupName specifies the group name used to register the objects.
1010
const GroupName = "gateway.nginx.org"
1111

12-
// SchemeGroupVersion is group version used to register these objects
12+
// SchemeGroupVersion is group version used to register these objects.
1313
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
1414

15-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
15+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
1616
func Resource(resource string) schema.GroupResource {
1717
return SchemeGroupVersion.WithResource(resource).GroupResource()
1818
}

cmd/gateway/commands.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,9 @@ func createProvisionerModeCommand() *cobra.Command {
444444

445445
// FIXME(pleshakov): Remove this command once NGF min supported Kubernetes version supports sleep action in
446446
// preStop hook.
447-
// nolint:lll
448447
// See https://github.com/kubernetes/enhancements/tree/4ec371d92dcd4f56a2ab18c8ba20bb85d8d20efe/keps/sig-node/3960-pod-lifecycle-sleep-action
448+
//
449+
//nolint:lll
449450
func createSleepCommand() *cobra.Command {
450451
// flag names
451452
const durationFlag = "duration"

cmd/gateway/commands_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type flagTestCase struct {
1818
}
1919

2020
func testFlag(t *testing.T, cmd *cobra.Command, test flagTestCase) {
21+
t.Helper()
2122
g := NewWithT(t)
2223
// discard any output generated by cobra
2324
cmd.SetOut(io.Discard)

0 commit comments

Comments
 (0)