Skip to content

Commit fd99d3f

Browse files
committed
chore: update golangci-lint
1 parent 6e3ceed commit fd99d3f

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

.golangci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ formatters:
55
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
66
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
77
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
8+
settings:
9+
gofmt:
10+
rewrite-rules:
11+
- pattern: interface{}
12+
replacement: any
813

914
issues:
1015
# List of regexps of issue texts to exclude, empty list by default.
@@ -68,6 +73,11 @@ linters:
6873
- name: package-comments
6974
disabled: true
7075

76+
wsl_v5:
77+
allow-first-in-block: true
78+
allow-whole-block: false
79+
branch-max-lines: 2
80+
7181
enable:
7282
- asasalint # check for pass []any as any in variadic func(...any) [fast: false, auto-fix: false]
7383
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
@@ -140,7 +150,7 @@ linters:
140150
- usetesting # Reports uses of functions with replacement inside the testing package. [auto-fix]
141151
- wastedassign # wastedassign finds wasted assignment statements. [fast: false, auto-fix: false]
142152
- whitespace # Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
143-
- wsl # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
153+
- wsl_v5 # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
144154
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]
145155

146156
disable:

builder/scaleway/artifact.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Artifact struct {
3838

3939
// StateData should store data such as GeneratedData
4040
// to be shared with post-processors
41-
StateData map[string]interface{}
41+
StateData map[string]any
4242
}
4343

4444
func (*Artifact) BuilderId() string {
@@ -59,7 +59,7 @@ func (a *Artifact) String() string {
5959
a.ImageName, a.ImageID, a.ZoneName, a.Snapshots)
6060
}
6161

62-
func (a *Artifact) State(name string) interface{} {
62+
func (a *Artifact) State(name string) any {
6363
if name == registryimage.ArtifactStateURI {
6464
img, err := registryimage.FromArtifact(a,
6565
registryimage.WithID(a.ImageID),

builder/scaleway/artifact_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
func TestArtifact_Impl(t *testing.T) {
11-
var raw interface{} //nolint:staticcheck
11+
var raw any //nolint:staticcheck
1212

1313
raw = &scaleway.Artifact{}
1414
if _, ok := raw.(packersdk.Artifact); !ok {
@@ -17,7 +17,7 @@ func TestArtifact_Impl(t *testing.T) {
1717
}
1818

1919
func TestArtifactId(t *testing.T) {
20-
generatedData := make(map[string]interface{})
20+
generatedData := make(map[string]any)
2121
a := &scaleway.Artifact{
2222
"packer-foobar-image",
2323
"cc586e45-5156-4f71-b223-cf406b10dd1d",
@@ -37,7 +37,7 @@ func TestArtifactId(t *testing.T) {
3737
}
3838

3939
func TestArtifactString(t *testing.T) {
40-
generatedData := make(map[string]interface{})
40+
generatedData := make(map[string]any)
4141
a := &scaleway.Artifact{
4242
"packer-foobar-image",
4343
"cc586e45-5156-4f71-b223-cf406b10dd1d",
@@ -65,7 +65,7 @@ func TestArtifactString(t *testing.T) {
6565
func TestArtifactState_StateData(t *testing.T) {
6666
expectedData := "this is the data"
6767
artifact := &scaleway.Artifact{
68-
StateData: map[string]interface{}{"state_data": expectedData},
68+
StateData: map[string]any{"state_data": expectedData},
6969
}
7070

7171
// Valid state

builder/scaleway/builder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Builder struct {
3232

3333
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.Config.FlatMapstructure().HCL2Spec() }
3434

35-
func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
35+
func (b *Builder) Prepare(raws ...any) ([]string, []string, error) {
3636
warnings, errs := b.Config.Prepare(raws...)
3737
if errs != nil {
3838
return nil, warnings, errs
@@ -145,7 +145,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
145145
Snapshots: state.Get("snapshots").([]ArtifactSnapshot),
146146
ZoneName: b.Config.Zone,
147147
Client: client,
148-
StateData: map[string]interface{}{"generated_data": state.Get("generated_data")},
148+
StateData: map[string]any{"generated_data": state.Get("generated_data")},
149149
}
150150

151151
return artifact, nil

builder/scaleway/builder_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/scaleway/packer-plugin-scaleway/builder/scaleway"
99
)
1010

11-
func testConfig() map[string]interface{} {
12-
return map[string]interface{}{
11+
func testConfig() map[string]any {
12+
return map[string]any{
1313
"project_id": "00000000-1111-2222-3333-444444444444",
1414
"access_key": "SCWABCXXXXXXXXXXXXXX",
1515
"secret_key": "00000000-1111-2222-3333-444444444444",
@@ -21,7 +21,7 @@ func testConfig() map[string]interface{} {
2121
}
2222

2323
func TestBuilder_ImplementsBuilder(t *testing.T) {
24-
var raw interface{} //nolint:staticcheck
24+
var raw any //nolint:staticcheck
2525

2626
raw = &scaleway.Builder{}
2727
if _, ok := raw.(packersdk.Builder); !ok {
@@ -31,7 +31,7 @@ func TestBuilder_ImplementsBuilder(t *testing.T) {
3131

3232
func TestBuilder_Prepare_BadType(t *testing.T) {
3333
b := &scaleway.Builder{}
34-
c := map[string]interface{}{
34+
c := map[string]any{
3535
"api_token": []string{},
3636
}
3737

builder/scaleway/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ type Config struct {
152152
Region string `mapstructure:"region" required:"false"`
153153
}
154154

155-
func (c *Config) Prepare(raws ...interface{}) ([]string, error) { //nolint:gocyclo
155+
func (c *Config) Prepare(raws ...any) ([]string, error) { //nolint:gocyclo
156156
var md mapstructure.Metadata
157157

158158
err := config.Decode(c, &config.DecodeOpts{

internal/tester/tester.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type TestConfig struct {
7070
func Test(t *testing.T, config *TestConfig) {
7171
httpClient, cleanup, err := vcr.GetHTTPRecorder(vcr.GetTestFilePath(t, "."), vcr.UpdateCassettes)
7272
require.NoError(t, err)
73+
7374
defer cleanup()
7475

7576
ctx := t.Context()

0 commit comments

Comments
 (0)