Skip to content

Commit 1cf9aa6

Browse files
authored
Merge pull request #134 from ekristen/chore-golangci-linting
chore: golangci-lint updates
2 parents dbfbf88 + fc2aafc commit 1cf9aa6

7 files changed

Lines changed: 71 additions & 66 deletions

File tree

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
name: golangci-lint
22

33
on:
4-
push:
5-
branches:
6-
- main
74
pull_request:
85
branches:
96
- main
7+
- next
108

119
permissions:
1210
contents: read
1311

1412
jobs:
15-
lint:
16-
name: lint
13+
golangci-lint:
14+
name: golangci-lint
1715
runs-on: ubuntu-latest
1816
steps:
19-
- uses: actions/checkout@v4
20-
- uses: actions/setup-go@v5
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
18+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
2119
with:
22-
go-version: '1.21.x'
20+
go-version: "1.24.x"
2321
cache: false
2422
- name: golangci-lint
25-
uses: golangci/golangci-lint-action@v6
23+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8

.golangci.yaml

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,17 @@
1-
linters-settings:
2-
dupl:
3-
threshold: 100
4-
funlen:
5-
lines: 100
6-
statements: 50
7-
goconst:
8-
min-len: 2
9-
min-occurrences: 3
10-
gocritic:
11-
enabled-tags:
12-
- diagnostic
13-
- experimental
14-
- opinionated
15-
- performance
16-
- style
17-
disabled-checks:
18-
- dupImport # https://github.com/go-critic/go-critic/issues/845
19-
- ifElseChain
20-
- octalLiteral
21-
- whyNoLint
22-
gocyclo:
23-
min-complexity: 15
24-
golint:
25-
min-confidence: 0
26-
lll:
27-
line-length: 140
28-
maligned:
29-
suggest-new: true
30-
misspell:
31-
locale: US
32-
1+
version: "2"
332
linters:
34-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
35-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
36-
disable-all: true
3+
default: none
374
enable:
385
- bodyclose
6+
- copyloopvar
397
- dogsled
408
- errcheck
41-
- copyloopvar
429
- funlen
4310
- goconst
4411
- gocritic
4512
- gocyclo
46-
- gofmt
47-
- goimports
4813
- goprintffuncname
4914
- gosec
50-
- gosimple
5115
- govet
5216
- ineffassign
5317
- lll
@@ -57,18 +21,59 @@ linters:
5721
- noctx
5822
- nolintlint
5923
- staticcheck
60-
- stylecheck
61-
- typecheck
6224
- unconvert
6325
- unparam
6426
- unused
6527
- whitespace
66-
67-
issues:
68-
exclude-rules:
69-
- path: _test\.go
70-
linters:
71-
- funlen
72-
73-
run:
74-
timeout: 2m
28+
settings:
29+
dupl:
30+
threshold: 100
31+
funlen:
32+
lines: 100
33+
statements: 50
34+
goconst:
35+
min-len: 2
36+
min-occurrences: 3
37+
gocritic:
38+
disabled-checks:
39+
- dupImport
40+
- ifElseChain
41+
- octalLiteral
42+
- whyNoLint
43+
enabled-tags:
44+
- diagnostic
45+
- experimental
46+
- opinionated
47+
- performance
48+
- style
49+
gocyclo:
50+
min-complexity: 15
51+
lll:
52+
line-length: 140
53+
misspell:
54+
locale: US
55+
exclusions:
56+
generated: lax
57+
presets:
58+
- comments
59+
- common-false-positives
60+
- legacy
61+
- std-error-handling
62+
rules:
63+
- linters:
64+
- funlen
65+
path: _test\.go
66+
paths:
67+
- third_party$
68+
- builtin$
69+
- examples$
70+
formatters:
71+
enable:
72+
- gofmt
73+
- goimports
74+
exclusions:
75+
generated: lax
76+
paths:
77+
- third_party$
78+
- builtin$
79+
- examples$

pkg/commands/list/list.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ func execute(c *cli.Context) error {
2929
} else {
3030
_, _ = color.New(color.Bold).Printf("%-55s", name)
3131
c := color.FgGreen
32-
if reg.Scope == azure.TenantScope {
32+
switch reg.Scope {
33+
case azure.TenantScope:
3334
c = color.FgHiGreen
34-
} else if reg.Scope == azure.SubscriptionScope {
35+
case azure.SubscriptionScope:
3536
c = color.FgHiBlue
36-
} else if reg.Scope == azure.ResourceGroupScope {
37+
case azure.ResourceGroupScope:
3738
c = color.FgHiMagenta
3839
}
40+
3941
_, _ = color.New(c).Printf("%s\n", string(reg.Scope))
4042
}
4143
}

resources/disk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (l DiskLister) List(ctx context.Context, o interface{}) ([]resource.Resourc
8888
client: client,
8989
Name: r.Name,
9090
Tags: r.Tags,
91-
CreationDate: ptr.Time(r.DiskProperties.TimeCreated.Time),
91+
CreationDate: ptr.Time(r.TimeCreated.Time),
9292
})
9393
}
9494

resources/security-alert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (l SecurityAlertsLister) List(ctx context.Context, o interface{}) ([]resour
106106
ID: *g.ID,
107107
Name: *g.Name,
108108
DisplayName: ptr.ToString(g.AlertDisplayName),
109-
Status: string(g.AlertProperties.Status),
109+
Status: string(g.Status),
110110
})
111111
}
112112

resources/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (l ComputeSnapshotLister) List(ctx context.Context, o interface{}) ([]resou
8888
client: client,
8989
Name: r.Name,
9090
Tags: r.Tags,
91-
CreationDate: ptr.Time(r.SnapshotProperties.TimeCreated.Time),
91+
CreationDate: ptr.Time(r.TimeCreated.Time),
9292
})
9393
}
9494

resources/subscription-role-assignment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (l *SubscriptionRoleAssignmentLister) List(ctx context.Context, o interface
127127
}
128128

129129
if _, ok := l.roleNameCache[t.Properties.RoleDefinitionID]; !ok {
130-
l.roleNameCache[t.Properties.RoleDefinitionID] = rel.RoleDefinition.Properties.RoleName
130+
l.roleNameCache[t.Properties.RoleDefinitionID] = rel.Properties.RoleName
131131
}
132132

133133
var principalName = ptr.String("unknown")

0 commit comments

Comments
 (0)