tools: update golangci-lint to v2
The config file format changed. The tool golangci-lint migrate was used to migrate the old config. However old comments and also the structure of the disabled linters was preserved. Moreover the new v2 version introduced new linters, we disable 3 of them because they are very noise and we do not really want to check for them: funcorder, noinlineerr, embeddedstructfieldcheck.
This commit is contained in:
1 parent
f9dccd3e20
commit
13e7a6e782
5 files changed
+549
-463
No files matched your search
+204
-171
@@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
run:
|
||||
# If you change this please also update GO_VERSION in Makefile (then run
|
||||
# `make lint` to see where else it needs to be updated as well).
|
||||
@@ -21,95 +23,8 @@ run:
|
||||
- kvdb_sqlite
|
||||
- integration
|
||||
|
||||
linters-settings:
|
||||
custom:
|
||||
ll:
|
||||
type: "module"
|
||||
description: "Custom lll linter with 'S' log line exclusion."
|
||||
settings:
|
||||
# Max line length, lines longer will be reported.
|
||||
line-length: 80
|
||||
# Tab width in spaces.
|
||||
tab-width: 8
|
||||
# The regex that we will use to detect the start of an `S` log line.
|
||||
log-regex: "^\\s*.*(L|l)og\\.(Info|Debug|Trace|Warn|Error|Critical)S\\("
|
||||
|
||||
errorlint:
|
||||
# Check for incorrect fmt.Errorf error wrapping.
|
||||
errorf: true
|
||||
|
||||
gofmt:
|
||||
# simplify code: gofmt with `-s` option, true by default
|
||||
simplify: true
|
||||
|
||||
tagliatelle:
|
||||
case:
|
||||
rules:
|
||||
json: snake
|
||||
|
||||
whitespace:
|
||||
multi-func: true
|
||||
multi-if: true
|
||||
|
||||
gosec:
|
||||
excludes:
|
||||
- G402 # Look for bad TLS connection settings.
|
||||
- G306 # Poor file permissions used when writing to a new file.
|
||||
- G601 # Implicit memory aliasing in for loop.
|
||||
- G115 # Integer overflow in conversion.
|
||||
|
||||
staticcheck:
|
||||
checks: ["-SA1019"]
|
||||
|
||||
funlen:
|
||||
# Checks the number of lines in a function.
|
||||
# If lower than 0, disable the check.
|
||||
lines: 200
|
||||
# Checks the number of statements in a function.
|
||||
statements: 80
|
||||
|
||||
dupl:
|
||||
# Tokens count to trigger issue.
|
||||
threshold: 200
|
||||
|
||||
nestif:
|
||||
# Minimal complexity of if statements to report.
|
||||
min-complexity: 10
|
||||
|
||||
nlreturn:
|
||||
# Size of the block (including return statement that is still "OK")
|
||||
# so no return split required.
|
||||
block-size: 3
|
||||
|
||||
gomnd:
|
||||
# List of numbers to exclude from analysis.
|
||||
# The numbers should be written as string.
|
||||
# Values always ignored: "1", "1.0", "0" and "0.0"
|
||||
# Default: []
|
||||
ignored-numbers:
|
||||
- '0666'
|
||||
- '0755'
|
||||
|
||||
# List of function patterns to exclude from analysis.
|
||||
# Values always ignored: `time.Date`
|
||||
# Default: []
|
||||
ignored-functions:
|
||||
- 'math.*'
|
||||
- 'strconv.ParseInt'
|
||||
- 'errors.Wrap'
|
||||
|
||||
gomoddirectives:
|
||||
replace-local: true
|
||||
replace-allow-list:
|
||||
# See go.mod for the explanation why these are needed.
|
||||
- github.com/ulikunitz/xz
|
||||
- github.com/gogo/protobuf
|
||||
- google.golang.org/protobuf
|
||||
- github.com/lightningnetwork/lnd/sqldb
|
||||
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
default: all
|
||||
disable:
|
||||
# We instead use our own custom line length linter called `ll` since
|
||||
# then we can ignore log lines.
|
||||
@@ -142,14 +57,10 @@ linters:
|
||||
- unparam
|
||||
- wastedassign
|
||||
|
||||
# Disable gofumpt as it has weird behavior regarding formatting multiple
|
||||
# lines for a function which is in conflict with our contribution
|
||||
# guidelines. See https://github.com/mvdan/gofumpt/issues/235.
|
||||
- gofumpt
|
||||
|
||||
# Disable whitespace linter as it has conflict rules against our
|
||||
# Disable whitespace linters as it has conflict rules against our
|
||||
# contribution guidelines.
|
||||
- wsl
|
||||
- wsl_v5
|
||||
|
||||
# Allow using default empty values.
|
||||
- exhaustruct
|
||||
@@ -211,88 +122,210 @@ linters:
|
||||
- gosmopolitan
|
||||
- intrange
|
||||
- goconst
|
||||
|
||||
# Disable function order linter because we structure exported and unexported
|
||||
# functions differently.
|
||||
- funcorder
|
||||
|
||||
# Disable noinlineerr linter because we use it to inline errors.
|
||||
- noinlineerr
|
||||
|
||||
# Disable embeddedstructfieldcheck linter because we use it to align
|
||||
# structs. Because sometimes we have atomic fields that need to be aligned
|
||||
# with means we need to assure that the field is at the beginning of the
|
||||
# struct.
|
||||
- embeddedstructfieldcheck
|
||||
|
||||
|
||||
# Deprecated linters that have been replaced by newer ones.
|
||||
- tenv
|
||||
settings:
|
||||
dupl:
|
||||
# Tokens count to trigger issue.
|
||||
threshold: 200
|
||||
|
||||
errorlint:
|
||||
# Check for incorrect fmt.Errorf error wrapping.
|
||||
errorf: true
|
||||
|
||||
funlen:
|
||||
# Checks the number of lines in a function.
|
||||
# If lower than 0, disable the check.
|
||||
lines: 200
|
||||
# Checks the number of statements in a function.
|
||||
statements: 80
|
||||
|
||||
gomoddirectives:
|
||||
# See project's go.mod for the explanation why these are needed.
|
||||
replace-allow-list:
|
||||
- github.com/ulikunitz/xz
|
||||
- github.com/gogo/protobuf
|
||||
- google.golang.org/protobuf
|
||||
- github.com/lightningnetwork/lnd/sqldb
|
||||
replace-local: true
|
||||
|
||||
gosec:
|
||||
excludes:
|
||||
- G402 # Look for bad TLS connection settings.
|
||||
- G306 # Poor file permissions used when writing to a new file.
|
||||
- G601 # Implicit memory aliasing in for loop.
|
||||
- G115 # Integer overflow in conversion.
|
||||
|
||||
nestif:
|
||||
# Minimal complexity of if statements to report.
|
||||
min-complexity: 10
|
||||
|
||||
nlreturn:
|
||||
# Size of the block (including return statement that is still "OK")
|
||||
# so no return split required.
|
||||
block-size: 3
|
||||
|
||||
staticcheck:
|
||||
checks:
|
||||
- -SA1019
|
||||
|
||||
tagliatelle:
|
||||
case:
|
||||
rules:
|
||||
json: snake
|
||||
|
||||
whitespace:
|
||||
multi-if: true
|
||||
multi-func: true
|
||||
|
||||
custom:
|
||||
ll:
|
||||
type: module
|
||||
description: Custom lll linter with 'S' log line exclusion.
|
||||
settings:
|
||||
# Max line length, lines longer will be reported.
|
||||
line-length: 80
|
||||
# The regex that we will use to detect the start of an `S` log line.
|
||||
log-regex: ^\s*.*(L|l)og\.(Info|Debug|Trace|Warn|Error|Critical)S\(
|
||||
# Tab width in spaces.
|
||||
tab-width: 8
|
||||
|
||||
exclusions:
|
||||
# Mode of the generated files analysis.
|
||||
#
|
||||
# - `strict`: sources are excluded by strictly following the Go generated file convention.
|
||||
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
|
||||
# This line must appear before the first non-comment, non-blank text in the file.
|
||||
# https://go.dev/s/generatedcode
|
||||
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
|
||||
# - `disable`: disable the generated files exclusion.
|
||||
#
|
||||
# Default: strict
|
||||
generated: lax
|
||||
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
|
||||
rules:
|
||||
- linters:
|
||||
# Allow duplications in tests so it's easier to follow a single unit
|
||||
- dupl
|
||||
- funlen
|
||||
- gosec
|
||||
- revive
|
||||
# Exclude gosec from running for tests so that tests with weak
|
||||
# randomness (math/rand) will pass the linter.
|
||||
path: _test\.go
|
||||
|
||||
- linters:
|
||||
# forcetypeassert is skipped for the mock because the test would fail
|
||||
# if the returned value doesn't match the type, so there's no need to
|
||||
# check the convert.
|
||||
- forcetypeassert
|
||||
- revive
|
||||
path: mock*
|
||||
|
||||
- linters:
|
||||
- funlen
|
||||
- gosec
|
||||
path: test*
|
||||
|
||||
# Allow duplicated code and fmt.Printf() in DB migrations.
|
||||
- linters:
|
||||
- dupl
|
||||
- forbidigo
|
||||
- godot
|
||||
path: channeldb/migration*
|
||||
|
||||
# Allow duplicated code and fmt.Printf() in DB migration tests.
|
||||
- linters:
|
||||
- dupl
|
||||
- forbidigo
|
||||
- godot
|
||||
path: channeldb/migtest
|
||||
|
||||
# Allow fmt.Printf() in commands.
|
||||
- linters:
|
||||
- forbidigo
|
||||
path: cmd/commands/*
|
||||
|
||||
# Allow fmt.Printf() in config parsing.
|
||||
- linters:
|
||||
- forbidigo
|
||||
path: config\.go
|
||||
- linters:
|
||||
- forbidigo
|
||||
path: lnd\.go
|
||||
|
||||
- linters:
|
||||
# forcetypeassert is skipped for the mock because the test would fail
|
||||
# if the returned value doesn't match the type, so there's no need to
|
||||
# check the convert.
|
||||
- forcetypeassert
|
||||
path: lnmock/*
|
||||
|
||||
- linters:
|
||||
# forcetypeassert is skipped for the mock because the test would fail
|
||||
# if the returned value doesn't match the type, so there's no need to
|
||||
# check the convert.
|
||||
- forcetypeassert
|
||||
path: mock*
|
||||
|
||||
# Skip autogenerated files for mobile and gRPC as well as copied code for
|
||||
# internal use.
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
- "mobile\\/.*generated\\.go"
|
||||
- "\\.pb\\.go$"
|
||||
- "\\.pb\\.gw\\.go$"
|
||||
- "internal\\/musig2v040"
|
||||
- channeldb/migration_01_to_11
|
||||
- channeldb/migration/lnwire21
|
||||
|
||||
issues:
|
||||
# Only show newly introduced problems.
|
||||
new-from-rev: 03eab4db64540aa5f789c617793e4459f4ba9e78
|
||||
|
||||
# Skip autogenerated files for mobile and gRPC as well as copied code for
|
||||
# internal use.
|
||||
skip-files:
|
||||
- "mobile\\/.*generated\\.go"
|
||||
- "\\.pb\\.go$"
|
||||
- "\\.pb\\.gw\\.go$"
|
||||
- "internal\\/musig2v040"
|
||||
formatters:
|
||||
enable:
|
||||
- gci
|
||||
- gofmt
|
||||
- goimports
|
||||
|
||||
skip-dirs:
|
||||
- channeldb/migration_01_to_11
|
||||
- channeldb/migration/lnwire21
|
||||
settings:
|
||||
gofmt:
|
||||
# simplify code: gofmt with `-s` option, true by default
|
||||
simplify: true
|
||||
|
||||
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
|
||||
- funlen
|
||||
- revive
|
||||
# Allow duplications in tests so it's easier to follow a single unit
|
||||
# test.
|
||||
- dupl
|
||||
|
||||
- path: mock*
|
||||
linters:
|
||||
- revive
|
||||
# forcetypeassert is skipped for the mock because the test would fail
|
||||
# if the returned value doesn't match the type, so there's no need to
|
||||
# check the convert.
|
||||
- forcetypeassert
|
||||
|
||||
- path: test*
|
||||
linters:
|
||||
- gosec
|
||||
- funlen
|
||||
|
||||
# Allow duplicated code and fmt.Printf() in DB migrations.
|
||||
- path: channeldb/migration*
|
||||
linters:
|
||||
- dupl
|
||||
- forbidigo
|
||||
- godot
|
||||
|
||||
# Allow duplicated code and fmt.Printf() in DB migration tests.
|
||||
- path: channeldb/migtest
|
||||
linters:
|
||||
- dupl
|
||||
- forbidigo
|
||||
- godot
|
||||
|
||||
# Allow fmt.Printf() in commands.
|
||||
- path: cmd/commands/*
|
||||
linters:
|
||||
- forbidigo
|
||||
|
||||
# Allow fmt.Printf() in config parsing.
|
||||
- path: config\.go
|
||||
linters:
|
||||
- forbidigo
|
||||
- path: lnd\.go
|
||||
linters:
|
||||
- forbidigo
|
||||
|
||||
- path: lnmock/*
|
||||
linters:
|
||||
# forcetypeassert is skipped for the mock because the test would fail
|
||||
# if the returned value doesn't match the type, so there's no need to
|
||||
# check the convert.
|
||||
- forcetypeassert
|
||||
|
||||
- path: mock*
|
||||
linters:
|
||||
# forcetypeassert is skipped for the mock because the test would fail
|
||||
# if the returned value doesn't match the type, so there's no need to
|
||||
# check the convert.
|
||||
- forcetypeassert
|
||||
exclusions:
|
||||
generated: lax
|
||||
# Skip autogenerated files for mobile and gRPC as well as copied code for
|
||||
# internal use.
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
- "mobile\\/.*generated\\.go"
|
||||
- "\\.pb\\.go$"
|
||||
- "\\.pb\\.gw\\.go$"
|
||||
- "internal\\/musig2v040"
|
||||
- channeldb/migration_01_to_11
|
||||
- channeldb/migration/lnwire21
|
||||
Reference in new issue
Block a user