From 9c54c8e233f09c0c011fcfd4a8de67ec0a47a428 Mon Sep 17 00:00:00 2001 From: Steven Soroka Date: Tue, 30 Mar 2021 14:11:31 -0400 Subject: [PATCH] new linter commands (#9020) --- .golangci.yml | 4 ++-- Makefile | 38 +++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9f01ba6881010..ffef28f505900 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,7 +16,6 @@ linters: - staticcheck - typecheck - unconvert - - unparam - unused - varcheck @@ -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 @@ -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 diff --git a/Makefile b/Makefile index 992ddb18993f1..7f090ca574514 100644 --- a/Makefile +++ b/Makefile @@ -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)";) @@ -131,14 +133,28 @@ vet: exit 1; \ fi +.PHONY: lint-install +lint-install: + + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.38.0 + .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: