Skip to content

Commit

Permalink
Run revive linter in CI (influxdata#8798)
Browse files Browse the repository at this point in the history
* Run revive linter in CI
Just output the results, don't fail on it
Removed the rule.exported rule

* Move revive install to CI

* new line

* Use golangci-lint

* Get v1.37

* increase timeout by a minute

* try five minutes

* newline missing

* Update config
  • Loading branch information
sspaink authored Feb 18, 2021
1 parent b6b5d34 commit 660eb5b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ commands:
paths:
- 'dist'
jobs:
linter:
executor: go-1_15
steps:
- checkout
- restore_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
- run: wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.37.0
- run: make lint
deps:
executor: go-1_15
steps:
Expand Down Expand Up @@ -178,6 +186,7 @@ workflows:
version: 2
check:
jobs:
- 'linter'
- 'macdeps':
filters:
tags:
Expand Down Expand Up @@ -246,6 +255,7 @@ workflows:
- 'release'
nightly:
jobs:
- 'linter'
- 'deps'
- 'macdeps'
- 'test-go-1_14':
Expand Down
44 changes: 44 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
linters:
enable:
- revive

linters-settings:
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id

run:
skip-dirs:
- scripts
- docs
- etc
skip-files:
- plugins/parsers/influx/machine.go*

issues:
exclude:
- don't use an underscore in package name
- exported.*should have comment.*or be unexported
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ help:
@echo ' test - run short unit tests'
@echo ' fmt - format source files'
@echo ' tidy - tidy go modules'
@echo ' lint - run linter'
@echo ' check-deps - check docs/LICENSE_OF_DEPENDENCIES.md'
@echo ' clean - delete build artifacts'
@echo ''
Expand Down Expand Up @@ -130,6 +131,15 @@ vet:
exit 1; \
fi

.PHONY: lint
lint:
ifeq (, $(shell which golangci-lint))
$(info golangci-lint can't be found, please install it: https://golangci-lint.run/usage/install/)
exit 1
endif

golangci-lint run --timeout 5m0s --issues-exit-code 0

.PHONY: tidy
tidy:
go mod verify
Expand Down

0 comments on commit 660eb5b

Please sign in to comment.