Skip to content

Commit 437cc6d

Browse files
marckhouzamvuil
authored andcommitted
Update golangci-lint to 1.52.2 (#56)
Some of the updated linters require go 1.19 so this commit updates the github workflow to use go 1.19 for the "check" section. Note that "allow-leading-space" is no longer supported as mentioned in golangci/golangci-lint#3063 (comment) Fix new warnings that are now reported. Signed-off-by: Marc Khouzam <[email protected]>
1 parent 0662d8d commit 437cc6d

File tree

15 files changed

+32
-32
lines changed

15 files changed

+32
-32
lines changed

Diff for: .github/workflows/main.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
- name: Set up Go 1.x
5858
uses: actions/setup-go@v3
5959
with:
60-
go-version: 1.18
60+
go-version: 1.19
6161
id: go
6262

6363
- name: go cache

Diff for: .golangci.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ linters-settings:
4040
misspell:
4141
locale: US
4242
nolintlint:
43-
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
4443
allow-unused: false # report any unused nolint directives
4544
require-explanation: false # don't require an explanation for nolint directives
4645
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

Diff for: component/output.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ func NewObjectWriter(output io.Writer, outputFormat string, data interface{}) Ou
130130
}
131131

132132
// SetKeys sets the values to use as the keys for the output values.
133-
func (obw *objectwriter) SetKeys(headerKeys ...string) {
133+
func (obw *objectwriter) SetKeys(_ ...string) {
134134
// Object writer does not have the concept of keys
135135
fmt.Fprintln(obw.out, "Programming error, attempt to add headers to object output")
136136
}
137137

138138
// AddRow appends a new row to our table.
139-
func (obw *objectwriter) AddRow(items ...interface{}) {
139+
func (obw *objectwriter) AddRow(_ ...interface{}) {
140140
// Object writer does not have the concept of keys
141141
fmt.Fprintln(obw.out, "Programming error, attempt to add rows to object output")
142142
}

Diff for: config/contexts.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func SetContext(c *configtypes.Context, setCurrent bool) error {
8080
}
8181

8282
// Set current server
83-
if setCurrent && s.Type == configtypes.ManagementClusterServerType { // nolint:staticcheck
83+
if setCurrent && s.Type == configtypes.ManagementClusterServerType { //nolint:staticcheck
8484
persist, err = setCurrentServer(node, s.Name)
8585
if err != nil {
8686
return err

Diff for: config/discovery_sources_node.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ func setDiscoverySource(discoverySourcesNode *yaml.Node, discoverySource configt
135135
}
136136

137137
func getDiscoverySourceTypeAndName(discoverySource configtypes.PluginDiscovery) (string, string) {
138-
if discoverySource.GCP != nil && discoverySource.GCP.Name != "" { // nolint:staticcheck
139-
return DiscoveryTypeGCP, discoverySource.GCP.Name // nolint:staticcheck
138+
if discoverySource.GCP != nil && discoverySource.GCP.Name != "" { //nolint:staticcheck
139+
return DiscoveryTypeGCP, discoverySource.GCP.Name //nolint:staticcheck
140140
} else if discoverySource.OCI != nil && discoverySource.OCI.Name != "" {
141141
return DiscoveryTypeOCI, discoverySource.OCI.Name
142142
} else if discoverySource.Local != nil && discoverySource.Local.Name != "" {

Diff for: config/fileutil.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ func copyFile(src, dst string) error {
3737
if err != nil {
3838
return err
3939
}
40-
if err := os.Chmod(dst, sf.Mode()); err != nil {
41-
return err
42-
}
43-
return nil
40+
return os.Chmod(dst, sf.Mode())
4441
}
4542

4643
// copyDir copies a directory tree recursively. Source directory must exist and destination directory must *not*

Diff for: hack/tools/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BIN_DIR := bin
2121

2222
GOIMPORTS_VERSION=0.1.12
2323
VALE_VERSION=2.20.1
24-
GOLANGCI_LINT_VERSION=1.46.0
24+
GOLANGCI_LINT_VERSION=1.52.2
2525
MISSPELL_VERSION=0.3.4
2626
GINKGO_VERSION=2.9.0
2727

Diff for: log/logger.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (l *logger) Print(msg string, err error, logType string, kvs ...interface{}
182182
if err != nil {
183183
values = append(values, "error", err)
184184
}
185-
header := []byte(l.header(logType, l.callDepth))
185+
header := []byte(l.header(l.callDepth))
186186
_, _ = logWriter.Write(header, []byte(l.getLogString(values)), l.Enabled(), l.level, logType)
187187
}
188188

@@ -228,7 +228,7 @@ func copySlice(in []interface{}) []interface{} {
228228
// - Variables name are not quoted, eg.
229229
// This is a message "Var1"="value" --> This is a message Var1="value"
230230
// - Variables are not sorted, thus allowing full control to the developer on the output.
231-
func flatten(entry logEntry) (string, error) { // nolint:gocyclo
231+
func flatten(entry logEntry) (string, error) { //nolint:gocyclo
232232
var msgValue string
233233
var errorValue error
234234
if len(entry.Values)%2 == 1 {
@@ -297,7 +297,7 @@ func pretty(value interface{}) (string, error) {
297297
return string(jb), nil
298298
}
299299

300-
func (l *logger) header(logType string, depth int) string {
300+
func (l *logger) header(depth int) string {
301301
_, file, line, ok := runtime.Caller(3 + depth)
302302
if !ok {
303303
file = "???"

Diff for: test/compatibility/framework/context_commands.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import (
1717
// Return: command to execute or error if any validations fails for SetContextInputOptions or SetContextOutputOptions
1818
// This method does validate the input parameters SetContextInputOptions or SetContextOutputOptions based on Runtime API Version
1919
// For more details about supported parameters refer to SetContextInputOptions or SetContextOutputOptions definition(and ContextOpts struct, which is embedded)
20-
// nolint:dupl
20+
//
21+
//nolint:dupl
2122
func NewSetContextCommand(inputOpts *SetContextInputOptions, outputOpts *SetContextOutputOptions) (*core.Command, error) {
2223
// Init the Command object
2324
c := &core.Command{}
@@ -146,7 +147,8 @@ func NewGetContextCommand(inputOpts *GetContextInputOptions, outputOpts *GetCont
146147
// Return: command to execute or error if any validations fails for DeleteContextInputOptions or DeleteContextOutputOptions
147148
// This method does validate the input parameters DeleteContextInputOptions or DeleteContextOutputOptions based on Runtime API Version
148149
// For more details about supported parameters refer to DeleteContextInputOptions or DeleteContextOutputOptions definition(and ContextOpts struct, which is embedded)
149-
// nolint: dupl
150+
//
151+
//nolint:dupl
150152
func NewDeleteContextCommand(inputOpts *DeleteContextInputOptions, outputOpts *DeleteContextOutputOptions) (*core.Command, error) {
151153
// Init the Command object
152154
c := &core.Command{}

Diff for: test/compatibility/framework/server_commands.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
// Return: command to execute or error if any validations fails for SetServerInputOptions or SetServerOutputOptions
1616
// This method does validate the input parameters SetServerInputOptions or SetServerOutputOptions based on Runtime API Version
1717
// For more details about supported parameters refer to SetServerInputOptions or SetServerOutputOptions definition(and ServerOpts struct, which is embedded)
18-
// nolint:dupl
18+
//
19+
//nolint:dupl
1920
func NewSetServerCommand(inputOpts *SetServerInputOptions, outputOpts *SetServerOutputOptions) (*core.Command, error) {
2021
// Init the Command object
2122
c := &core.Command{}
@@ -146,7 +147,8 @@ func NewGetServerCommand(inputOpts *GetServerInputOptions, outputOpts *GetServer
146147
// Return: command to execute or error if any validations fails for DeleteServerInputOptions or DeleteServerOutputOptions
147148
// This method does validate the input parameters DeleteServerInputOptions or DeleteServerOutputOptions based on Runtime API Version
148149
// For more details about supported parameters refer to DeleteServerInputOptions or DeleteServerOutputOptions definition(and ServerOpts struct, which is embedded)
149-
// nolint: dupl
150+
//
151+
//nolint:dupl
150152
func NewDeleteServerCommand(inputOpts *DeleteServerInputOptions, outputOpts *DeleteServerOutputOptions) (*core.Command, error) {
151153
// Init the Command object
152154
c := &core.Command{}

Diff for: test/compatibility/testplugins/runtime-test-plugin-latest/cmd/parser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func parseContext(context string) (*configtypes.Context, error) {
2020
}
2121

2222
// parseServer unmarshalls string to Server struct
23-
func parseServer(server string) (*configtypes.Server, error) { // nolint:staticcheck // Deprecated
24-
var s configtypes.Server // nolint:staticcheck // Deprecated
23+
func parseServer(server string) (*configtypes.Server, error) { //nolint:staticcheck // Deprecated
24+
var s configtypes.Server //nolint:staticcheck // Deprecated
2525
err := yaml.Unmarshal([]byte(server), &s)
2626
if err != nil {
2727
return nil, err

Diff for: test/compatibility/testplugins/runtime-test-plugin-latest/cmd/trigger_server_apis.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func triggerRemoveCurrentServerAPI(api *core.API) *core.APIResponse {
8686

8787
func getServer(serverName string) *core.APIResponse {
8888
// Call runtime GetServer API
89-
server, err := configlib.GetServer(serverName) // nolint:staticcheck // Deprecated
89+
server, err := configlib.GetServer(serverName) //nolint:staticcheck // Deprecated
9090
if err != nil {
9191
return &core.APIResponse{
9292
ResponseType: core.ErrorResponse,
@@ -105,9 +105,9 @@ func getServer(serverName string) *core.APIResponse {
105105
}
106106
}
107107

108-
func setServer(server *configtypes.Server, setCurrent bool) *core.APIResponse { // nolint:staticcheck // Deprecated
108+
func setServer(server *configtypes.Server, setCurrent bool) *core.APIResponse { //nolint:staticcheck // Deprecated
109109
// Call runtime SetServer API
110-
err := configlib.AddServer(server, setCurrent) // nolint:staticcheck // Deprecated
110+
err := configlib.AddServer(server, setCurrent) //nolint:staticcheck // Deprecated
111111
if err != nil {
112112
return &core.APIResponse{
113113
ResponseType: core.ErrorResponse,
@@ -122,7 +122,7 @@ func setServer(server *configtypes.Server, setCurrent bool) *core.APIResponse {
122122

123123
func removeServer(serverName string) *core.APIResponse {
124124
// Call runtime RemoveServer API
125-
err := configlib.RemoveServer(serverName) // nolint:staticcheck // Deprecated
125+
err := configlib.RemoveServer(serverName) //nolint:staticcheck // Deprecated
126126

127127
if err != nil {
128128
return &core.APIResponse{
@@ -138,7 +138,7 @@ func removeServer(serverName string) *core.APIResponse {
138138

139139
func setCurrentServer(serverName string) *core.APIResponse {
140140
// Call runtime SetCurrentServer API
141-
err := configlib.SetCurrentServer(serverName) // nolint:staticcheck // Deprecated
141+
err := configlib.SetCurrentServer(serverName) //nolint:staticcheck // Deprecated
142142
if err != nil {
143143
return &core.APIResponse{
144144
ResponseType: core.ErrorResponse,
@@ -152,7 +152,7 @@ func setCurrentServer(serverName string) *core.APIResponse {
152152
}
153153

154154
func getCurrentServer() *core.APIResponse {
155-
server, err := configlib.GetCurrentServer() // nolint:staticcheck // Deprecated
155+
server, err := configlib.GetCurrentServer() //nolint:staticcheck // Deprecated
156156
if err != nil {
157157
return &core.APIResponse{
158158
ResponseType: core.ErrorResponse,
@@ -172,7 +172,7 @@ func getCurrentServer() *core.APIResponse {
172172
}
173173

174174
func removeCurrentServer(serverName string) *core.APIResponse {
175-
err := configlib.RemoveCurrentServer(serverName) // nolint:staticcheck // Deprecated
175+
err := configlib.RemoveCurrentServer(serverName) //nolint:staticcheck // Deprecated
176176
if err != nil {
177177
return &core.APIResponse{
178178
ResponseType: core.ErrorResponse,

Diff for: test/exec/command.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func WithEnv(args ...string) Option {
7373

7474
// Run executes the command and returns stdout, stderr and the error if there is any.
7575
func (c *Command) Run(ctx context.Context) ([]byte, []byte, error) {
76-
cmd := exec.CommandContext(ctx, c.Cmd, c.Args...) // nolint:gosec
76+
cmd := exec.CommandContext(ctx, c.Cmd, c.Args...) //nolint:gosec
7777
if len(c.Env) != 0 {
7878
cmd.Env = os.Environ()
7979
cmd.Env = append(cmd.Env, c.Env...)
@@ -109,7 +109,7 @@ func (c *Command) Run(ctx context.Context) ([]byte, []byte, error) {
109109

110110
// RunAndRedirectOutput executes command and redirects output
111111
func (c *Command) RunAndRedirectOutput(ctx context.Context) error {
112-
cmd := exec.CommandContext(ctx, c.Cmd, c.Args...) // nolint:gosec
112+
cmd := exec.CommandContext(ctx, c.Cmd, c.Args...) //nolint:gosec
113113

114114
if len(c.Env) != 0 {
115115
cmd.Env = os.Environ()

Diff for: test/framework/framework.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func copyAndCapture(w io.Writer, r io.Reader) ([]byte, error) {
387387
var out []byte
388388
buf := make([]byte, 1024)
389389
for {
390-
// nolint:gocritic
390+
//nolint:gocritic
391391
n, err := r.Read(buf[:])
392392
if n > 0 {
393393
d := buf[:n]

Diff for: test/plugins/helloworld/print.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var PrintCmd = &cobra.Command{
2020
RunE: printHelloWorld,
2121
}
2222

23-
func printHelloWorld(cmd *cobra.Command, args []string) error {
23+
func printHelloWorld(_ *cobra.Command, _ []string) error {
2424
fmt.Printf("Hello world from test plugin")
2525
return nil
2626
}

0 commit comments

Comments
 (0)