Skip to content

Commit

Permalink
Use staticcheck that goes as part of golangci-lint
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
msugakov committed Sep 21, 2021
1 parent e1c261a commit 4646add
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
15 changes: 12 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,22 @@ linters-settings:
- emptyStringTest
- hugeParam
- rangeValCopy
gosimple:
go: "1.16"
checks: ["all"]
nolintlint:
allow-leading-space: false # require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
revive:
min-confidence: 0
staticcheck:
go: "1.16"
checks: ["all"]
stylecheck:
go: "1.16"
checks: ["all", "-ST1000"]

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
Expand Down Expand Up @@ -91,14 +100,14 @@ linters:
- revive
- rowserrcheck
# - scopelint
# - staticcheck
- staticcheck
# - structcheck
# - stylecheck
- stylecheck
# - testpackage
# - typecheck
- unconvert
- unparam
# - unused
- unused
# - varcheck
# - whitespace
# - wsl
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ $(GOLANGCILINT_BIN): deps
@echo "+ $@"
go install github.com/golangci/golangci-lint/cmd/golangci-lint

STATICCHECK_BIN := $(GOBIN)/staticcheck
$(STATICCHECK_BIN): deps
@echo "+ $@"
go install honnef.co/go/tools/cmd/staticcheck

###########
## Lint ##
###########
Expand All @@ -60,12 +55,8 @@ else
golangci-lint run --fix
endif

.PHONY: staticcheck
staticcheck: $(STATICCHECK_BIN)
staticcheck -checks=all,-ST1000 ./...

.PHONY: lint
lint: golangci-lint staticcheck
lint: golangci-lint

####################
## Code generation #
Expand Down

0 comments on commit 4646add

Please sign in to comment.