Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 11c4b37

Browse files
authored
Merge pull request #537 from cprivitere/lintupdates
🐛 Linting Updates
2 parents 73f4046 + ccdb6e0 commit 11c4b37

File tree

4 files changed

+59
-117
lines changed

4 files changed

+59
-117
lines changed

.golangci.yml

Lines changed: 52 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,47 @@
11
linters:
2-
enable:
3-
- asciicheck
4-
- bidichk
5-
- bodyclose
6-
- containedctx
7-
- contextcheck
8-
# - cyclop
9-
- decorder
10-
- depguard
11-
- dogsled
12-
- dupl
13-
- durationcheck
14-
- errchkjson
15-
# - errname
16-
- errorlint
17-
# - exhaustive
18-
# - exhaustivestruct
19-
- exportloopref
20-
# - forbidigo
21-
- forcetypeassert
22-
# - funlen
23-
- gci
24-
# - gochecknoglobals
25-
# - gochecknoinits
26-
# - gocognit
27-
- goconst
28-
- gocritic
29-
- gocyclo
30-
# - godot
31-
# - godox
32-
- goerr113
33-
- gofmt
34-
# - gofumpt
35-
- goheader
36-
- goimports
37-
# - gomnd
38-
- gomoddirectives
39-
- gomodguard
40-
- goprintffuncname
41-
- gosec
42-
- grouper
43-
- ifshort
44-
- importas
45-
- ireturn
46-
# - lll
47-
- maintidx
48-
- makezero
49-
- misspell
50-
- nakedret
51-
# - nestif
52-
- nilerr
53-
# - nilnil
54-
# - nlreturn
55-
- noctx
56-
- nolintlint
57-
# - paralleltest
58-
- prealloc
59-
- predeclared
60-
- promlinter
61-
- revive
62-
- rowserrcheck
63-
- sqlclosecheck
64-
- stylecheck
65-
# - tagliatelle
66-
- tenv
67-
# - testpackage
68-
# - thelper
69-
# - tparallel
70-
- unconvert
71-
- unparam
72-
# - varnamelen
73-
- wastedassign
74-
- whitespace
75-
# - wrapcheck
76-
# - wsl
2+
enable-all: true
3+
disable:
4+
- cyclop
5+
- deadcode
6+
- errname
7+
- exhaustive
8+
- exhaustruct
9+
- exhaustivestruct
10+
- forbidigo
11+
- funlen
12+
- gci
13+
- gochecknoglobals
14+
- gochecknoinits
15+
- gocognit
16+
- godot
17+
- godox
18+
- golint
19+
- gofumpt
20+
- gomnd
21+
- ifshort
22+
- interfacer
23+
- lll
24+
- maligned
25+
- nestif
26+
- nilnil
27+
- nlreturn
28+
- nosnakecase
29+
- paralleltest
30+
- scopelint
31+
- structcheck
32+
- tagliatelle
33+
- testpackage
34+
- thelper
35+
- tparallel
36+
- varcheck
37+
- varnamelen
38+
- wrapcheck
39+
- wsl
7740

7841
linters-settings:
7942
importas:
43+
# Do not allow unaliased imports of aliased packages.
44+
# Default: false
8045
no-unaliased: true
8146
alias:
8247
# Kubernetes
@@ -93,60 +58,34 @@ linters-settings:
9358
# Controller Runtime
9459
- pkg: sigs.k8s.io/controller-runtime
9560
alias: ctrl
96-
gosimple:
97-
go: "1.17"
98-
staticcheck:
99-
go: "1.17"
100-
stylecheck:
101-
go: "1.17"
102-
unused:
103-
go: "1.17"
10461
tagliatelle:
10562
case:
106-
# use-field-name: true
10763
rules:
64+
# Any struct tag type can be used.
65+
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`
10866
json: goCamel
10967
gomoddirectives:
110-
# Allow local `replace` directives. Default is false.
111-
replace-local: false
112-
# List of allowed `replace` directives. Default is empty.
68+
# List of allowed `replace` directives.
69+
# Default: []
11370
replace-allow-list:
11471
- sigs.k8s.io/cluster-api
115-
# Allow to not explain why the version has been retracted in the `retract` directives. Default is false.
116-
retract-allow-no-explanation: false
117-
# Forbid the use of the `exclude` directives. Default is false.
118-
exclude-forbidden: false
119-
gci:
120-
# put imports beginning with prefix after 3rd-party packages;
121-
# only support one prefix
122-
# if not set, use goimports.local-prefixes
123-
local-prefixes: sigs.k8s.io/cluster-api-provider-packet
12472
goimports:
12573
# put imports beginning with prefix after 3rd-party packages;
12674
# it's a comma-separated list of prefixes
12775
local-prefixes: sigs.k8s.io/cluster-api-provider-packet
12876
nolintlint:
129-
# Enable to ensure that nolint directives are all used. Default is true.
130-
allow-unused: false
131-
# Disable to ensure that nolint directives don't have a leading space. Default is true.
132-
allow-leading-space: true
133-
# Exclude following linters from requiring an explanation. Default is [].
134-
allow-no-explanation: []
135-
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
136-
require-explanation: false
137-
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
77+
# Enable to require nolint directives to mention the specific linter being suppressed.
78+
# Default: false
13879
require-specific: true
139-
issues:
140-
exclude-rules:
141-
- linters:
142-
- lll
143-
- wsl
144-
source: "^// \\+kubebuilder:"
145-
80+
revive:
81+
rules:
82+
- name: unused-parameter
83+
disabled: true
14684

14785
run:
86+
go: '1.19'
14887
timeout: 10m
14988
skip-files:
15089
- "zz_generated.*\\.go$"
15190
- ".*conversion.*\\.go$"
152-
allow-parallel-runners: true
91+
allow-parallel-runners: true

api/v1alpha3/packetmachine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type PacketMachineSpec struct {
3333
OS string `json:"OS"` //nolint: tagliatelle
3434
BillingCycle string `json:"billingCycle"`
3535
MachineType string `json:"machineType"`
36-
SshKeys []string `json:"sshKeys,omitempty"` //nolint: revive,stylecheck
36+
SshKeys []string `json:"sshKeys,omitempty"` //nolint: stylecheck
3737

3838
// Facility represents the Packet facility for this cluster.
3939
// Override from the PacketCluster spec.

cmd/ci-clean/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
const (
35-
AuthTokenEnvVar = "PACKET_API_KEY" // nolint:gosec
35+
AuthTokenEnvVar = "PACKET_API_KEY" //nolint:gosec
3636
ProjectIDEnvVar = "PROJECT_ID"
3737
)
3838

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ func main() {
8585
}
8686

8787
if profilerAddress != "" {
88-
setupLog.Info("Profiler listening for requests", "profiler-address", profilerAddress)
88+
setupLog.Info(fmt.Sprintf("Profiler listening for requests at %s", profilerAddress))
8989
go func() {
90-
setupLog.Error(http.ListenAndServe(profilerAddress, nil), "listen and serve error")
90+
srv := http.Server{Addr: profilerAddress, ReadHeaderTimeout: 2 * time.Second}
91+
if err := srv.ListenAndServe(); err != nil {
92+
setupLog.Error(err, "problem running profiler server")
93+
}
9194
}()
9295
}
9396

0 commit comments

Comments
 (0)