Skip to content

Commit 6e80c39

Browse files
committed
Linter: do not analyze ignored directories
After changing some linter settings, we began seeing that the linter was failing to run on v6 (when the "V7" build tag was not given). The errors were complaining about duplicate declarations in the "fixtures/plugins" directory (which was meant to be ignored by the linter, via the "skip-dirs" option). After investigating, I learned that Golangci-lint will still try to parse and analyze directories that are skipped in this way - it only uses the "skip-dirs" option to filter out any lint errors that are found after analysis is complete. Here's an open GitHub issue about this: golangci/golangci-lint#301 This means that if there are compilation errors in these skipped dirs, they will fail the linter, even though we want to skip them. I'm fixing this with a workaround suggested in that issue. Something like: ``` go list ./... | (grep for dirs you care to lint) | xargs golangci-lint run ``` A nice side effect is that, by truly skipping analysis of these dirs, the linter runs faster. [#172389465] Authored-by: Reid Mitchell <[email protected]>
1 parent 78b4870 commit 6e80c39

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

.golangci.json

-20
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,6 @@
22
"run": {
33
"concurrency": 4,
44
"timeout": "20m",
5-
"skip-dirs": [
6-
"^cf",
7-
"^ci",
8-
"^doc",
9-
"^fixtures",
10-
"^i18n",
11-
"^plugin",
12-
"^vendor",
13-
"^actor/cfnetworkingaction",
14-
"^actor/pluginaction",
15-
"^actor/pushaction",
16-
"^actor/v2.*",
17-
"^actor/v3.*",
18-
"^api/cloudcontroller/ccv2",
19-
"^api/plugin",
20-
"^api/router",
21-
"^integration/assets",
22-
"^integration/v6",
23-
".*fake.*"
24-
],
255
"skip-files": [
266
"integration/helpers/fake_server.go"
277
]

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ integration-tests-full: build integration-cleanup integration-isolated integrati
149149

150150
lint: custom-lint ## Runs all linters and formatters
151151
@echo "Running linters..."
152-
golangci-lint run $(LINT_FLAGS)
152+
go list -f "{{.Dir}}" ./... \
153+
| grep -v -e "/cf/" -e "/fixtures/" -e "/assets/" -e "/plugin/" -e "fakes" \
154+
| xargs golangci-lint run $(LINT_FLAGS)
153155
@echo "No lint errors!"
154156

155157
ifeq ($(TARGET),v6)

0 commit comments

Comments
 (0)