From 2fa2f24700b005b018db3c157047756fddbfde55 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 20 Oct 2022 16:48:40 +0800 Subject: [PATCH] golangci: enable new linters Only newly added code will trigger these linter checks. --- .golangci.yml | 69 ++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 879d1daf9..c8171b0d2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -53,6 +53,16 @@ linters-settings: # Tab width in spaces. tab-width: 8 + funlen: + # Checks the number of lines in a function. + # If lower than 0, disable the check. + # Default: 60 + lines: 60 + # Checks the number of statements in a function. + # Default: 40 + statements: 40 + + linters: enable-all: true disable: @@ -65,18 +75,6 @@ linters: # We want to allow TODOs. - godox - # We have long functions, especially in tests. Moving or renaming those would - # trigger funlen problems that we may not want to solve at that time. - - funlen - - # Disable for now as we haven't yet tuned the sensitivity to our codebase - # yet. Enabling by default for example, would also force new contributors to - # potentially extensively refactor code, when they want to smaller change to - # land. - - gocyclo - - gocognit - - cyclop - # Instances of table driven tests that don't pre-allocate shouldn't trigger # the linter. - prealloc @@ -84,46 +82,23 @@ linters: # Init functions are used by loggers throughout the codebase. - gochecknoinits - # Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19. - - errorlint - # Deprecated linters. See https://golangci-lint.run/usage/linters/. - interfacer - golint - maligned - scopelint - - # New linters that need a code adjustment first. - - wrapcheck - - nolintlint - - paralleltest - - tparallel - - testpackage - - gofumpt - - gomoddirectives - - ireturn - - maintidx - - nlreturn - - dogsled - - gci - - containedctx - - contextcheck - - errname - exhaustivestruct - - exhaustruct - - goerr113 - - gomnd - - ifshort - - noctx - - nestif - - wsl - - exhaustive - - forcetypeassert + - bodyclose + - contextcheck - nilerr - - nilnil - - stylecheck - - thelper - + - noctx + - rowserrcheck + - sqlclosecheck + - structcheck + - tparallel + - unparam + - wastedassign + issues: # Only show newly introduced problems. new-from-rev: 8c66353e4c02329abdacb5a8df29998035ec2e24 @@ -134,9 +109,11 @@ issues: - path: _test\.go linters: - gosec + - funlen - path: test* linters: - gosec + - funlen # Allow duplicated code and fmt.Printf() in DB migrations. - path: channeldb/migration* @@ -172,3 +149,5 @@ issues: - deadcode - unparam - govet + # itest case can be very long so we disable long function check. + - funlen