From 8e811702b73d29edfa785a88a6a57e930d27ce54 Mon Sep 17 00:00:00 2001 From: Victor Castell <0x@vcastellm.xyz> Date: Thu, 20 Jun 2024 10:10:55 +0000 Subject: [PATCH] build: add golang linter According to the quality gate requirements. --- .golangci.yml | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..77bc1aa8 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,77 @@ +# This file configures github.com/golangci/golangci-lint. + +run: + timeout: 3m + tests: true + # default is true. Enables skipping of directories: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs-use-default: true + skip-dirs: + - tests + +service: + golangci-lint-version: 1.59.1 + +linters: + disable-all: true + enable: + - whitespace # Tool for detection of leading and trailing whitespace + - wsl # Forces you to use empty lines + - wastedassign # Finds wasted assignment statements + - unconvert # Unnecessary type conversions + - tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes + - thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers + - stylecheck # Stylecheck is a replacement for golint + - prealloc # Finds slice declarations that could potentially be pre-allocated + - predeclared # Finds code that shadows one of Go's predeclared identifiers + - nolintlint # Ill-formed or insufficient nolint directives + - nlreturn # Checks for a new line before return and branch statements to increase code clarity + - misspell # Misspelled English words in comments + - makezero # Finds slice declarations with non-zero initial length + - lll # Long lines + - importas # Enforces consistent import aliases + - gosec # Security problems + - gofmt # Whether the code was gofmt-ed + - goimports # Unused imports + - goconst # Repeated strings that could be replaced by a constant + - forcetypeassert # Finds forced type assertions + - dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f()) + - dupl # Code clone detection + - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error + - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13 + - gocritic + - errcheck # Errcheck is a go lint rule for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases + - godox # Godox is a linter for TODOs and FIXMEs left in the code + +linters-settings: + gofmt: + simplify: true + goconst: + min-len: 3 + min-occurrences: 3 + gocritic: + enabled-checks: + - ruleguard + settings: + ruleguard: + rules: "./gorules/rules.go" + +issues: + new-from-rev: origin/develop # report only new issues with reference to develop branch + whole-files: true + exclude-rules: + - path: _test\.go + linters: + - gosec + - unparam + - lll + - path: gen_sc_data\.go + linters: + - wsl + - lll + - stylecheck + include: + - EXC0012 # Exported (.+) should have comment( \(or a comment on this block\))? or be unexported + - EXC0013 # Package comment should be of the form "(.+)... + - EXC0014 # Comment on exported (.+) should be of the form "(.+)..." + - EXC0015 # Should have a package comment