From 56bf4df31080b5706c1479ad504cbda036c74940 Mon Sep 17 00:00:00 2001 From: Ruslan Efanov Date: Fri, 30 Dec 2022 10:42:29 +0300 Subject: [PATCH] update linter and it's rules --- .github/workflows/ci.yml | 2 +- .golangci.yml | 58 +++++++++++++++++++++++++--------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b6d49f..48b3ebf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: - name: Lint code with golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.36 + version: v1.50.1 only-new-issues: true tests: name: Tests diff --git a/.golangci.yml b/.golangci.yml index 4c632cb..27d773f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,20 +6,33 @@ output: format: colored-line-number sort-results: true +# Linters below do not support go1.18 yet because of generics. +# See https://github.com/golangci/golangci-lint/issues/2649 +# - bodyclose +# - sqlclosecheck + linters: disable-all: true enable: - - deadcode + - paralleltest + - tparallel + - asciicheck + - asasalint + - varnamelen + - reassign + - nilnil + - nilerr + - nakedret + - goprintffuncname + - typecheck + - errchkjson - errcheck - gosimple - govet - ineffassign - staticcheck - - structcheck - unused - unparam - - varcheck - - bodyclose - dogsled - dupl - errorlint @@ -32,20 +45,15 @@ linters: - gocyclo - godot - goimports - - golint - - gomnd + - revive - gosec - - ifshort - - interfacer - lll - makezero - - maligned - misspell - nestif - prealloc - predeclared - - scopelint - - sqlclosecheck + - exportloopref - unconvert - whitespace @@ -56,9 +64,11 @@ linters-settings: enable: - assign - atomic + - atomicalign - bools - buildtag - copylocks + - fieldalignment - httpresponse - loopclosure - lostcancel @@ -70,7 +80,6 @@ linters-settings: - unmarshal - unreachable - unsafeptr - - unused settings: printf: funcs: @@ -129,11 +138,13 @@ linters-settings: threshold: 200 errorlint: errorf: true + asserts: false + comparison: false exhaustive: check-generated: false default-signifies-exhaustive: false funlen: - lines: 60 + lines: 90 statements: 40 gocognit: min-complexity: 25 @@ -143,8 +154,6 @@ linters-settings: local-prefixes: github.com/retailcrm/mg-bot-api-client-go lll: line-length: 120 - maligned: - suggest-new: true misspell: locale: US nestif: @@ -152,22 +161,25 @@ linters-settings: whitespace: multi-if: false multi-func: false - + varnamelen: + max-distance: 10 + ignore-map-index-ok: true + ignore-type-assert-ok: true + ignore-chan-recv-ok: true + ignore-decls: + - t *testing.T + - e error + - i int issues: exclude-rules: - path: _test\.go linters: - - gomnd - lll - - bodyclose - errcheck - - sqlclosecheck - misspell - ineffassign - whitespace - makezero - - maligned - - ifshort - errcheck - funlen - goconst @@ -175,6 +187,8 @@ issues: - gocyclo - godot - unused + - errchkjson + - varnamelen exclude-use-default: true exclude-case-sensitive: false max-issues-per-linter: 0 @@ -186,4 +200,4 @@ severity: case-sensitive: false service: - golangci-lint-version: 1.36.x + golangci-lint-version: 1.50.x