Skip to content

lint: update golangci-lint to v1.63.4 #13279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 17 additions & 31 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
# SPDX-License-Identifier: BUSL-1.1

issues:

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
exclude-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
exclude-files:
- ".*\\.hcl2spec\\.go$"

# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
Expand Down Expand Up @@ -30,6 +42,9 @@ issues:
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

# make issues output unique by line, default is true
uniq-by-line: true

linters:
disable-all: true
enable:
Expand Down Expand Up @@ -57,30 +72,6 @@ run:
# include test files or not, default is true
tests: true

# list of build tags, all linters use it. Default is empty list.
#build-tags:
# - mytag

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
#skip-dirs:
# - src/external_libs
# - autogenerated_by_my_lib

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files:
- ".*\\.hcl2spec\\.go$"
# - lib/bad.go

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand All @@ -94,16 +85,15 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
formats:
- format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

# make issues output unique by line, default is true
uniq-by-line: true


# all available settings of specific linters
Expand All @@ -121,7 +111,3 @@ linters-settings:
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,io/ioutil:^Read.*,io:Close

# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
#exclude: /path/to/file.txt
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ install-gen-deps: ## Install dependencies for code generation

install-lint-deps: ## Install linter dependencies
@echo "==> Updating linter dependencies..."
@curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.54.0
@curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.63.4

dev: ## Build and install a development build
@grep 'const VersionPrerelease = ""' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \
Expand Down
2 changes: 1 addition & 1 deletion datasource/hcp-packer-iteration/data_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var testHCPBuild string
// environment because the template this test uses does not set them.
func TestAccDatasource_HCPPackerIteration(t *testing.T) {
if os.Getenv(env.HCPClientID) == "" && os.Getenv(env.HCPClientSecret) == "" {
t.Skipf(fmt.Sprintf("Acceptance tests skipped unless envs %q and %q are set", env.HCPClientID, env.HCPClientSecret))
t.Skipf("Acceptance tests skipped unless envs %q and %q are set", env.HCPClientID, env.HCPClientSecret)
return
}

Expand Down
2 changes: 1 addition & 1 deletion datasource/hcp-packer-version/data_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var testHCPBuild string
// environment because the template this test uses does not set them.
func TestAccDatasource_HCPPackerVersion(t *testing.T) {
if os.Getenv(env.HCPClientID) == "" && os.Getenv(env.HCPClientSecret) == "" {
t.Skipf(fmt.Sprintf("Acceptance tests skipped unless envs %q and %q are set", env.HCPClientID, env.HCPClientSecret))
t.Skipf("Acceptance tests skipped unless envs %q and %q are set", env.HCPClientID, env.HCPClientSecret)
return
}

Expand Down
12 changes: 0 additions & 12 deletions hcl2template/types.packer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,6 @@ func parseLocalVariableBlocks(f *hcl.File) ([]*LocalBlock, hcl.Diagnostics) {
return locals, diags
}

func (c *PackerConfig) localByName(local string) (*LocalBlock, error) {
for _, loc := range c.LocalBlocks {
if loc.LocalName != local {
continue
}

return loc, nil
}

return nil, fmt.Errorf("local %s not found", local)
}

func (c *PackerConfig) evaluateLocalVariables(locals []*LocalBlock) hcl.Diagnostics {
var diags hcl.Diagnostics

Expand Down
4 changes: 2 additions & 2 deletions internal/hcp/api/errors_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api

import (
"fmt"
"errors"
"testing"

"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestCheckErrorCode(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
found := CheckErrorCode(fmt.Errorf(tt.codeString), tt.expectCode)
found := CheckErrorCode(errors.New(tt.codeString), tt.expectCode)
if found != tt.expectSuccess {
t.Errorf("check error code returned %t, expected %t", found, tt.expectSuccess)
}
Expand Down
2 changes: 1 addition & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func logOutput() (logOutput io.Writer, err error) {
if strings.Contains(scanner.Text(), "ui error:") {
continue
}
fmt.Fprintf(os.Stderr, scanner.Text()+"\n")
fmt.Fprintf(os.Stderr, "%s\n", scanner.Text())
}
if err := scanner.Err(); err != nil {
fmt.Fprintf(os.Stderr, "log output filter failed: %s\n", err)
Expand Down
2 changes: 1 addition & 1 deletion packer/plugin_discover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func createMockChecksumFile(t testing.TB, filePath string) {
t.Helper()
cs, err := generateMockChecksumFile(filePath)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err)
}
t.Logf("created fake plugin checksum file %s", cs)
}
Expand Down
2 changes: 1 addition & 1 deletion packer_test/common/check/pipe_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func LineCount() Pipe {
// This is useful typically for troubleshooting a pipe that misbehaves
func Tee(t *testing.T) Pipe {
return CustomPipe(func(s string) (string, error) {
t.Logf(s)
t.Log(s)
return s, nil
})
}
Expand Down
2 changes: 1 addition & 1 deletion packer_test/common/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func WriteFile(t *testing.T, dest string, content string) {
}
defer outFile.Close()

_, err = fmt.Fprintf(outFile, content)
_, err = fmt.Fprint(outFile, content)
if err != nil {
t.Fatalf("failed to write to file %q: %s", dest, err)
}
Expand Down
2 changes: 1 addition & 1 deletion panic.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func panicHandler(logF *os.File) panicwrap.HandlerFunc {
return func(m string) {
// Write away just output this thing on stderr so that it gets
// shown in case anything below fails.
fmt.Fprintf(os.Stderr, fmt.Sprintf("%s\n", m))
fmt.Fprintf(os.Stderr, "%s\n", m)

if err := packer.CheckpointReporter.ReportPanic(m); err != nil {
fmt.Fprintf(os.Stderr, "Failed to report panic. This is safe to ignore: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion provisioner/powershell/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestProvisionerPrepare_DebugMode(t *testing.T) {

command := `powershell -executionpolicy bypass "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};Set-PsDebug -Trace 1;. {{.Vars}}; &'{{.Path}}'; exit $LastExitCode }"`
if p.config.ExecuteCommand != command {
t.Fatalf(fmt.Sprintf(`Expected command should be '%s' but got '%s'`, command, p.config.ExecuteCommand))
t.Fatalf(`Expected command should be '%s' but got '%s'`, command, p.config.ExecuteCommand)
}
}

Expand Down