Skip to content

Commit 52e4b78

Browse files
authored
Improve linting configuration (#27)
* Enabled more static checks * Switched to `gomodguard` instead of `revive` for better error messages
1 parent b3eddb3 commit 52e4b78

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

.golangci.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ linters:
6464
- unconvert # Remove unnecessary type conversions
6565
- wastedassign # wastedassign finds wasted assignment statements.
6666
- godox # tool for detection of FIXME, TODO and other comment keywords
67-
- revive # avoid bad imports
67+
- gomodguard # check for blocked dependencies
6868

6969
# all available settings of specific linters
7070
linters-settings:
@@ -137,22 +137,31 @@ linters-settings:
137137
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
138138
require-specific: true
139139

140-
revive:
141-
enable-all-rules: false
142-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
143-
rules:
144-
- name: imports-blacklist
145-
arguments:
146-
- github.com/pkg/errors
147-
- github.com/elastic/beats/v7
140+
gomodguard:
141+
blocked:
142+
# List of blocked modules.
143+
modules:
144+
# Blocked module.
145+
- github.com/pkg/errors:
146+
# Recommended modules that should be used instead. (Optional)
147+
recommendations:
148+
- errors
149+
- fmt
150+
reason: "This package is deprecated"
151+
- github.com/elastic/beats/v7:
152+
reason: "There must be no Beats dependency"
148153

149154
staticcheck:
150155
# Select the Go version to target. The default is '1.13'.
151156
go: "1.17.6"
157+
# https://staticcheck.io/docs/options#checks
158+
checks: ["all"]
152159

153160
stylecheck:
154161
# Select the Go version to target. The default is '1.13'.
155162
go: "1.17.6"
163+
# https://staticcheck.io/docs/options#checks
164+
checks: ["all"]
156165

157166
unparam:
158167
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.

dev-tools/templates/.golangci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ linters:
6161
- unconvert # Remove unnecessary type conversions
6262
- wastedassign # wastedassign finds wasted assignment statements.
6363
- godox # tool for detection of FIXME, TODO and other comment keywords
64+
- gomodguard # check for blocked dependencies
6465

6566
# all available settings of specific linters
6667
linters-settings:
@@ -133,13 +134,31 @@ linters-settings:
133134
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
134135
require-specific: true
135136

137+
gomodguard:
138+
blocked:
139+
# List of blocked modules.
140+
modules:
141+
# Blocked module.
142+
- github.com/pkg/errors:
143+
# Recommended modules that should be used instead. (Optional)
144+
recommendations:
145+
- errors
146+
- fmt
147+
reason: "This package is deprecated"
148+
- github.com/elastic/beats/v7:
149+
reason: "There must be no Beats dependency"
150+
136151
staticcheck:
137152
# Select the Go version to target. The default is '1.13'.
138153
go: "{{.GoVersion}}"
154+
# https://staticcheck.io/docs/options#checks
155+
checks: ["all"]
139156

140157
stylecheck:
141158
# Select the Go version to target. The default is '1.13'.
142159
go: "{{.GoVersion}}"
160+
# https://staticcheck.io/docs/options#checks
161+
checks: ["all"]
143162

144163
unparam:
145164
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.

0 commit comments

Comments
 (0)