From ac3ec4fa032f641005be6eb8b15c7f321f01caec Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 24 Mar 2021 13:49:55 +0100 Subject: [PATCH] lint: add new linter configuration We use the golangci-lint in lnd and it has quite a few more detections enabled than what's in the current gotest.sh script. We don't start with a given base commit on purpose but instead fix everything the linter finds in the following commits. --- .golangci.yml | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..4c7f466 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,54 @@ +run: + # timeout for analysis + deadline: 10m + +linters-settings: + govet: + # Don't report about shadowed variables + check-shadowing: false + gofmt: + # simplify code: gofmt with `-s` option, true by default + simplify: true + +linters: + enable-all: true + disable: + # Global variables are used in many places throughout the code base. + - gochecknoglobals + + # Some lines are over 80 characters on purpose and we don't want to make them + # even longer by marking them as 'nolint'. + - lll + + # We don't care (enough) about misaligned structs to lint that. + - maligned + + # 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 + + # Instances of table driven tests that don't pre-allocate shouldn't trigger + # the linter. + - prealloc + + # Init functions are used by loggers throughout the codebase. + - gochecknoinits + + # Explicit types are okay. + - interfacer + +issues: + exclude-rules: + # Exclude gosec from running for tests so that tests with weak randomness + # (math/rand) will pass the linter. + - path: _test\.go + linters: + - gosec + - errcheck + - dupl