Skip to content

Commit 4646add

Browse files
committed
Use staticcheck that goes as part of golangci-lint
This one turned a bit more involved. Apparently, per golangci/golangci-lint#2017 staticcheck is split into four (!) linters under golangci-lit. These are: `staticcheck`, `gosimple`, `stylecheck` and `unused`. Using the same name `staticcheck` for one of linters is not confusing at all. Anyway, to get full staiccheck's power, one must enable all four linters in `.golangci.yml`. With that we can throw staticcheck target away from `Makefile`. Verified by omitting `"-ST1000"` in `stylecheck.checks` list and seeing how `make lint` fails with ST1000 findings. Unfortunately, I found no way to see log of each linter when it is executed in golangci-lint context to be able to confirm things more precisely. :-( Looks like golangci-lint simply does not support that.
1 parent e1c261a commit 4646add

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

.golangci.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,22 @@ linters-settings:
4141
- emptyStringTest
4242
- hugeParam
4343
- rangeValCopy
44+
gosimple:
45+
go: "1.16"
46+
checks: ["all"]
4447
nolintlint:
4548
allow-leading-space: false # require machine-readable nolint directives (i.e. with no leading space)
4649
allow-unused: false # report any unused nolint directives
4750
require-explanation: false # don't require an explanation for nolint directives
4851
require-specific: true # require nolint directives to be specific about which linter is being skipped
4952
revive:
5053
min-confidence: 0
54+
staticcheck:
55+
go: "1.16"
56+
checks: ["all"]
57+
stylecheck:
58+
go: "1.16"
59+
checks: ["all", "-ST1000"]
5160

5261
linters:
5362
# please, do not use `enable-all`: it's deprecated and will be removed soon.
@@ -91,14 +100,14 @@ linters:
91100
- revive
92101
- rowserrcheck
93102
# - scopelint
94-
# - staticcheck
103+
- staticcheck
95104
# - structcheck
96-
# - stylecheck
105+
- stylecheck
97106
# - testpackage
98107
# - typecheck
99108
- unconvert
100109
- unparam
101-
# - unused
110+
- unused
102111
# - varcheck
103112
# - whitespace
104113
# - wsl

Makefile

+1-10
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ $(GOLANGCILINT_BIN): deps
4040
@echo "+ $@"
4141
go install github.com/golangci/golangci-lint/cmd/golangci-lint
4242

43-
STATICCHECK_BIN := $(GOBIN)/staticcheck
44-
$(STATICCHECK_BIN): deps
45-
@echo "+ $@"
46-
go install honnef.co/go/tools/cmd/staticcheck
47-
4843
###########
4944
## Lint ##
5045
###########
@@ -60,12 +55,8 @@ else
6055
golangci-lint run --fix
6156
endif
6257

63-
.PHONY: staticcheck
64-
staticcheck: $(STATICCHECK_BIN)
65-
staticcheck -checks=all,-ST1000 ./...
66-
6758
.PHONY: lint
68-
lint: golangci-lint staticcheck
59+
lint: golangci-lint
6960

7061
####################
7162
## Code generation #

0 commit comments

Comments
 (0)