Skip to content

Commit

Permalink
go/lint: add nilaway as optional linter
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Nov 17, 2023
1 parent 041ffe7 commit dbf81cf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
5 changes: 3 additions & 2 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

### Go Linters

- `DISABLE_GOVULNCHECK`: Set to skip running govulncheck
- `DISABLED_GOLANGCI_LINTERS`: Linters to disable in golangci-lint
- `DISABLE_GOVULNCHECK`: Set to skip running [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck)
- `DISABLED_GOLANGCI_LINTERS`: Linters to disable in [golangci-lint](https://github.com/golangci/golangci-lint)
- `DISABLE_NILAWAY`: Set to skip running [nilaway](https://github.com/uber-go/nilaway)
- `GOLANGCI_LINTERS`: List of additional [Go linters to run with golangci-lint](https://golangci-lint.run/usage/linters/). (Example: `gosec`)
- `SKIP_GOLANGCI`: Don't run the golangci-lint checks
- `STRICT_GOLANGCI_LINTERS`: Enable more linters packaged with golangci-lint
Expand Down
21 changes: 21 additions & 0 deletions go/lint-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,27 @@ if [[ "$run_xmlencoderclose" == "true" ]]; then
fi
fi

if [[ "$EXPERIMENTAL" == *"nilaway"* ]];
then
# nilaway can deliver false positives so it's not currently allowed inside of golangci-lint,
# however this linter is useful so we offer it.
#
# https://github.com/golangci/golangci-lint/issues/4045

# Install nilaway
go install go.uber.org/nilaway/cmd/nilaway@latest

# Find the linter
bin=""
if which -s nilaway > /dev/null;
then
bin=$(which nilaway 2>&1 | head -n1)
fi

# Run nilaway
"$bin" -test=false ./...
fi

# golangci-lint
if [[ "$org" == "moov-io" ]];
then
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PLATFORM=$(shell uname -s | tr '[:upper:]' '[:lower:]')

.PHONY: check
check:
EXPERIMENTAL=gitleaks,govulncheck,shuffle \
EXPERIMENTAL=gitleaks,govulncheck,nilaway,shuffle \
COVER_THRESHOLD=80.0 \
GOCYCLO_LIMIT=15 \
GOLANGCI_FLAGS="--exclude-use-default=false" \
Expand Down

0 comments on commit dbf81cf

Please sign in to comment.