From 5100c7ce775fa403bf66342307f0ef45fc5231c1 Mon Sep 17 00:00:00 2001 From: Alex Senger Date: Wed, 10 Apr 2024 16:45:57 +0200 Subject: [PATCH] #9 introduces linter --- .gitignore | 4 ++++ .golangci.yml | 33 +++++++++++++++++++++++++++++++++ Makefile | 8 ++++++++ 3 files changed, 45 insertions(+) create mode 100644 .golangci.yml create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 2f44e58..ddbc175 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,7 @@ prof.mem # Goland files .idea/ tmp/** + +# Coverage Reports +coverage_unit.out +coverage_integration.out \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..64a0900 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,33 @@ +output: + # sorts results by: filepath, line and column + sort-results: true + +linters: + enable: + - revive # general purpose linter, drop-in replacement for golint + some extra + - whitespace # checks for unnecessary newlines and trailing spaces + - unconvert # check for unnecessary type conversions + - promlinter # checks that prometheus metrics follow prometheus naming conventions, see https://prometheus.io/docs/practices/naming/ + - nilerr # checks for cases where a nil value is returned even though a checked error is non-nil + - gofmt # basic gofmt + the simplification flag "-s" + - unparam # reports unused function parameters + - goimports # checks import statements are formatted according to the 'goimport' command + +linters-settings: + errcheck: + ignore: Close + +issues: + exclude-use-default: false + exclude-rules: + - linters: + - revive + text: package-comments + +run: + + build-tags: + - unit + - integration + + timeout: 2m diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9cd2545 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +test.lint: + golangci-lint run --config .golangci.yml --verbose ./... + +test.unit: + go test -coverprofile=coverage_unit.out -tags=unit ./... + +test.integration: + go test -coverprofile=coverage_integration.out -tags=integration ./... \ No newline at end of file