Skip to content

Commit e7a6587

Browse files
authored
chore: upgrade to golangci-lint v2 (#1605)
- Upgrades to golangci-lint configuration to support v2. - Updates workflow to v7 that supports v2. Signed-off-by: Ryan Johnson <[email protected]>
1 parent 2ff49ac commit e7a6587

File tree

2 files changed

+77
-46
lines changed

2 files changed

+77
-46
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
---
12
name: golangci-lint
23

34
on:
45
pull_request:
56
paths-ignore:
6-
- 'README.md'
7+
- README.md
78
push:
89
paths-ignore:
9-
- 'README.md'
10+
- README.md
1011

1112
permissions:
1213
contents: read
@@ -15,20 +16,19 @@ jobs:
1516
build:
1617
name: Build
1718
runs-on: ubuntu-latest
18-
timeout-minutes: 5
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
2222
- name: Setup Go
2323
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
2424
with:
25-
go-version-file: 'go.mod'
25+
go-version-file: go.mod
2626
cache: false
2727
- run: go mod download
2828
- run: go build -v .
2929
- name: Run Linters
30-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
30+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
3131
with:
32-
version: v1.64.8
32+
version: latest
3333
args: --issues-exit-code=1 --timeout 10m
3434
only-new-issues: true

.golangci.yml

Lines changed: 71 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,84 @@
1-
# © Broadcom. All Rights Reserved.
2-
# The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
3-
# SPDX-License-Identifier: MPL-2.0
1+
---
2+
version: "2"
43

5-
# For more information about the golangci-lint configuration file, refer to:
6-
# https://golangci-lint.run/usage/configuration/
7-
8-
issues:
9-
exclude-rules:
10-
# Exclude specific staticcheck rules to suppress false positives or acceptable issues.
11-
- linters: [staticcheck]
12-
text: "SA4004|SA1019|GetOkExists"
13-
# Exclude specific gosec rules to suppress warnings about issues deemed acceptable.
14-
- linters: [gosec]
15-
text: "G402|G404|G115"
4+
output:
5+
formats:
6+
text:
7+
path: stdout
168

179
linters:
18-
disable-all: true # Disable all linters by default and enable only the ones required.
10+
default: none
1911
enable:
20-
- gofmt # Checks Go code formatting.
21-
- goimports # Ensures proper import formatting.
22-
- gosimple # Reports simplifications in code.
23-
- govet # Examines code for possible mistakes.
2412
- gosec # Checks for security issues in code.
13+
- govet # Examines code for possible mistakes.
2514
- ineffassign # Detects inefficient assignments.
2615
- misspell # Finds and fixes typos.
2716
- staticcheck # Reports bugs, code smells, and deprecated practices.
2817
- unused # Detects unused variables, constants, etc.
18+
settings:
19+
errcheck:
20+
exclude-functions:
21+
- github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set
22+
- fmt:.*
23+
- io:Close
24+
revive:
25+
rules:
26+
- name: unreachable-code # Detect code that will never be executed.
27+
- name: errorf # Avoid string formatting in error messages.
28+
- name: range # Improve range loop usage.
29+
- name: superfluous-else # Eliminate unnecessary else statements.
30+
- name: var-declaration # Simplify variable declaration.
31+
- name: duplicated-imports # Detect and remove duplicate imports.-imports
32+
exclusions:
33+
generated: lax
34+
presets:
35+
- comments
36+
- common-false-positives
37+
- legacy
38+
- std-error-handling
39+
rules:
40+
# Exclude specific staticcheck rules to suppress false positives or acceptable issues.
41+
- linters:
42+
- staticcheck
43+
text: SA4004|SA1019|GetOkExists
44+
# Exclude specific gosec rules to suppress warnings about issues deemed acceptable.
45+
- linters:
46+
- gosec
47+
text: G402|G404|G115
48+
# TODO: Setting temporary exclusions.
49+
- linters:
50+
- staticcheck
51+
text: QF1001
52+
- linters:
53+
- staticcheck
54+
text: QF1003
55+
- linters:
56+
- staticcheck
57+
text: QF1004
58+
- linters:
59+
- staticcheck
60+
text: QF1007
61+
- linters:
62+
- staticcheck
63+
text: QF1011
64+
- linters:
65+
- staticcheck
66+
text: ST1005
67+
paths:
68+
- third_party$
69+
- builtin$
70+
- examples$
2971

3072
run:
3173
timeout: 30m # Sets the maximum time limit for the linter run.
3274

33-
output:
34-
formats:
35-
- format: colored-line-number # Allows colored output with line numbers when errors are reported.
36-
37-
linters-settings:
38-
errcheck:
39-
# Exclude specific functions from errcheck warnings, as errors are intentionally ignored in these cases.
40-
exclude-functions:
41-
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set"
42-
- "fmt:.*"
43-
- "io:Close"
44-
45-
revive:
46-
# Enable specific rules for the revive linter for improved code quality and readability.
47-
rules:
48-
- name: unreachable-code # Detect code that will never be executed.
49-
- name: errorf # Avoid string formatting in error messages.
50-
- name: range # Improve range loop usage.
51-
- name: superfluous-else # Eliminate unnecessary else statements.
52-
- name: var-declaration # Simplify variable declaration.
53-
- name: duplicated-imports # Detect and remove duplicate imports.-imports
75+
formatters:
76+
enable:
77+
- gofmt
78+
- goimports
79+
exclusions:
80+
generated: lax
81+
paths:
82+
- third_party$
83+
- builtin$
84+
- examples$

0 commit comments

Comments
 (0)