Skip to content

Commit

Permalink
new linter commands (influxdata#9020)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssoroka authored Mar 30, 2021
1 parent 7d66590 commit 9c54c8e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ linters:
- staticcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck

Expand Down Expand Up @@ -73,7 +72,7 @@ linters-settings:
- name: unhandled-error
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
# - name: unused-parameter
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
Expand All @@ -96,6 +95,7 @@ run:
- docs
- etc
- scripts
# - plugins/parsers/influx/machine.go

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
Expand Down
38 changes: 27 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@ all:
.PHONY: help
help:
@echo 'Targets:'
@echo ' all - download dependencies and compile telegraf binary'
@echo ' deps - download dependencies'
@echo ' telegraf - compile telegraf binary'
@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 ' all - download dependencies and compile telegraf binary'
@echo ' deps - download dependencies'
@echo ' telegraf - compile telegraf binary'
@echo ' test - run short unit tests'
@echo ' fmt - format source files'
@echo ' tidy - tidy go modules'
@echo ' lint - run linter'
@echo ' lint-branch - run linter on changes in current branch since master'
@echo ' lint-install - install linter'
@echo ' check-deps - check docs/LICENSE_OF_DEPENDENCIES.md'
@echo ' clean - delete build artifacts'
@echo ''
@echo 'Package Targets:'
@$(foreach dist,$(dists),echo " $(dist)";)
Expand Down Expand Up @@ -131,14 +133,28 @@ vet:
exit 1; \
fi

.PHONY: lint-install
lint-install:

go install github.com/golangci/golangci-lint/cmd/[email protected]

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

golangci-lint run

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

golangci-lint -v run
golangci-lint run --new-from-rev master

.PHONY: tidy
tidy:
Expand Down

0 comments on commit 9c54c8e

Please sign in to comment.