|
@@ -0,0 +1,247 @@
|
|
|
+# see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
|
|
|
+
|
|
|
+run:
|
|
|
+ skip-dirs:
|
|
|
+ - pkg/time/rate
|
|
|
+ skip-files:
|
|
|
+ - pkg/database/ent/generate.go
|
|
|
+
|
|
|
+linters-settings:
|
|
|
+ gocyclo:
|
|
|
+ min-complexity: 30
|
|
|
+
|
|
|
+ funlen:
|
|
|
+ # Checks the number of lines in a function.
|
|
|
+ # If lower than 0, disable the check.
|
|
|
+ # Default: 60
|
|
|
+ lines: -1
|
|
|
+ # Checks the number of statements in a function.
|
|
|
+ # If lower than 0, disable the check.
|
|
|
+ # Default: 40
|
|
|
+ statements: -1
|
|
|
+
|
|
|
+ govet:
|
|
|
+ check-shadowing: true
|
|
|
+ lll:
|
|
|
+ line-length: 140
|
|
|
+ misspell:
|
|
|
+ locale: US
|
|
|
+ nolintlint:
|
|
|
+ allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
|
|
|
+ allow-unused: false # report any unused nolint directives
|
|
|
+ require-explanation: false # don't require an explanation for nolint directives
|
|
|
+ require-specific: false # don't require nolint directives to be specific about which linter is being skipped
|
|
|
+
|
|
|
+linters:
|
|
|
+ enable-all: true
|
|
|
+ disable:
|
|
|
+ #
|
|
|
+ # DEPRECATED by golangi-lint
|
|
|
+ #
|
|
|
+ - golint # [deprecated]: Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
|
|
|
+ - interfacer # [deprecated]: Linter that suggests narrower interface types
|
|
|
+ - maligned # [deprecated]: Tool to detect Go structs that would take less memory if their fields were sorted
|
|
|
+ - scopelint # [deprecated]: Scopelint checks for unpinned variables in go programs
|
|
|
+
|
|
|
+ #
|
|
|
+ # Enabled
|
|
|
+ #
|
|
|
+ # - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
|
|
|
+ # - bidichk # Checks for dangerous unicode character sequences
|
|
|
+ # - decorder # check declaration order and count of types, constants, variables and functions
|
|
|
+ # - depguard # Go linter that checks if package imports are in a list of acceptable packages
|
|
|
+ # - durationcheck # check for two durations multiplied together
|
|
|
+ # - exportloopref # checks for pointers to enclosing loop variables
|
|
|
+ # - funlen # Tool for detection of long functions
|
|
|
+ # - gochecknoinits # Checks that no init functions are present in Go code
|
|
|
+ # - goheader # Checks is file header matches to pattern
|
|
|
+ # - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
|
|
|
+ # - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
|
|
|
+ # - goprintffuncname # Checks that printf-like functions are named with `f` at the end
|
|
|
+ # - grouper # An analyzer to analyze expression groups.
|
|
|
+ # - importas # Enforces consistent import aliases
|
|
|
+ # - makezero # Finds slice declarations with non-zero initial length
|
|
|
+ # - nolintlint # Reports ill-formed or insufficient nolint directives
|
|
|
+ # - rowserrcheck # checks whether Err of rows is checked successfully
|
|
|
+ # - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
|
|
|
+ # - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
|
|
|
+ # - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
|
|
|
+ # - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
|
|
|
+ # - varcheck # Finds unused global variables and constants
|
|
|
+
|
|
|
+ #
|
|
|
+ # Enabled by default by golangci (but requires fixing current issues, see at the end of this file) There
|
|
|
+ # is some redundancy, but never 1 to 1 (staticcheck seems to find more
|
|
|
+ # cases than ineffassign, deadcore more than unused..).
|
|
|
+ #
|
|
|
+ # - deadcode # Finds unused code
|
|
|
+ # - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
|
|
|
+ # - gosimple # (megacheck): Linter for Go source code that specializes in simplifying a code
|
|
|
+ # - govet # (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
|
|
|
+ # - ineffassign # Detects when assignments to existing variables are not used
|
|
|
+ # - staticcheck # (megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks
|
|
|
+ # - structcheck # Finds unused struct fields
|
|
|
+ # - unused # (megacheck): Checks Go code for unused constants, variables, functions and types
|
|
|
+
|
|
|
+ #
|
|
|
+ # Recommended? (easy)
|
|
|
+ #
|
|
|
+ - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.
|
|
|
+ - 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.
|
|
|
+ - forcetypeassert # finds forced type assertions
|
|
|
+ - gci # Gci control golang package import order and make it always deterministic.
|
|
|
+ - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
|
|
|
+ - goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
|
|
|
+ - gosec # (gas): Inspects source code for security problems
|
|
|
+ - misspell # Finds commonly misspelled English words in comments
|
|
|
+ - nakedret # Finds naked returns in functions greater than a specified function length
|
|
|
+ - nilerr # Finds the code that returns nil even if it checks that the error is not nil.
|
|
|
+ - predeclared # find code that shadows one of Go's predeclared identifiers
|
|
|
+ - promlinter # Check Prometheus metrics naming via promlint
|
|
|
+ - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
|
|
|
+ - unconvert # Remove unnecessary type conversions
|
|
|
+ - wastedassign # wastedassign finds wasted assignment statements.
|
|
|
+ - gocritic # Provides diagnostics that check for bugs, performance and style issues.
|
|
|
+ - exhaustive # check exhaustiveness of enum switch statements
|
|
|
+ - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
|
|
|
+ - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
|
|
|
+ - wrapcheck # Checks that errors returned from external packages are wrapped
|
|
|
+ - lll # Reports long lines
|
|
|
+ - ifshort # Checks that your code uses short syntax for if-statements whenever possible
|
|
|
+ - godot # Check if comments end in a period
|
|
|
+
|
|
|
+ #
|
|
|
+ # Recommended? (requires some work)
|
|
|
+ #
|
|
|
+
|
|
|
+ - bodyclose # checks whether HTTP response body is closed successfully
|
|
|
+ - containedctx # containedctx is a linter that detects struct contained context.Context field
|
|
|
+ - contextcheck # check the function whether use a non-inherited context
|
|
|
+ - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
|
|
|
+ - noctx # noctx finds sending http request without context.Context
|
|
|
+ - unparam # Reports unused function parameters
|
|
|
+ - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
|
|
|
+ - gomnd # An analyzer to detect magic numbers.
|
|
|
+ - ireturn # Accept Interfaces, Return Concrete Types
|
|
|
+
|
|
|
+ #
|
|
|
+ # Formatting only, useful in IDE but should not be forced on CI?
|
|
|
+ #
|
|
|
+
|
|
|
+ - gofumpt # Gofumpt checks whether code was gofumpt-ed.
|
|
|
+ - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
|
|
|
+ - whitespace # Tool for detection of leading and trailing whitespace
|
|
|
+ - wsl # Whitespace Linter - Forces you to use empty lines!
|
|
|
+
|
|
|
+ #
|
|
|
+ # Well intended, but not ready for this
|
|
|
+ #
|
|
|
+ - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
|
|
|
+ - cyclop # checks function and package cyclomatic complexity
|
|
|
+ - gocognit # Computes and checks the cognitive complexity of functions
|
|
|
+ - maintidx # maintidx measures the maintainability index of each function.
|
|
|
+ - goerr113 # Golang linter to check the errors handling expressions
|
|
|
+ - nestif # Reports deeply nested if statements
|
|
|
+ - gocyclo # Computes and checks the cyclomatic complexity of functions
|
|
|
+ - godox # Tool for detection of FIXME, TODO and other comment keywords
|
|
|
+ - dupl # Tool for code clone detection
|
|
|
+ - testpackage # linter that makes you use a separate _test package
|
|
|
+
|
|
|
+ #
|
|
|
+ # Too strict (for now?)
|
|
|
+ #
|
|
|
+ - forbidigo # Forbids identifiers
|
|
|
+ - tagliatelle # Checks the struct tags.
|
|
|
+ - varnamelen # checks that the length of a variable's name matches its scope
|
|
|
+ - gochecknoglobals # check that no global variables exist
|
|
|
+ - exhaustivestruct # Checks if all struct's fields are initialized
|
|
|
+ - goconst # Finds repeated strings that could be replaced by a constant
|
|
|
+ - stylecheck # Stylecheck is a replacement for golint
|
|
|
+
|
|
|
+ #
|
|
|
+ # Under evaluation
|
|
|
+ #
|
|
|
+
|
|
|
+ - prealloc # Finds slice declarations that could potentially be preallocated
|
|
|
+
|
|
|
+
|
|
|
+issues:
|
|
|
+ exclude-rules:
|
|
|
+ - path: go.mod
|
|
|
+ text: "replacement are not allowed: golang.org/x/time/rate"
|
|
|
+
|
|
|
+ # `err` is often shadowed, we may continue to do it
|
|
|
+ - linters:
|
|
|
+ - govet
|
|
|
+ text: "shadow: declaration of \"err\" shadows declaration"
|
|
|
+
|
|
|
+ #
|
|
|
+ # govet
|
|
|
+ #
|
|
|
+
|
|
|
+ - linters:
|
|
|
+ - govet
|
|
|
+ text: "shadow: declaration of .* shadows declaration"
|
|
|
+ - linters:
|
|
|
+ - govet
|
|
|
+ text: "copylocks: assignment copies lock value to newStream:"
|
|
|
+ - linters:
|
|
|
+ - govet
|
|
|
+ text: "composites: .* composite literal uses unkeyed fields"
|
|
|
+
|
|
|
+ #
|
|
|
+ # errcheck
|
|
|
+ #
|
|
|
+
|
|
|
+ - linters:
|
|
|
+ - errcheck
|
|
|
+ text: "Error return value of `.*` is not checked"
|
|
|
+
|
|
|
+ #
|
|
|
+ # staticcheck
|
|
|
+ #
|
|
|
+
|
|
|
+ - linters:
|
|
|
+ - staticcheck
|
|
|
+ text: "SA4009: argument .* is overwritten before first use"
|
|
|
+ - linters:
|
|
|
+ - staticcheck
|
|
|
+ text: "SA4009.related information.: assignment to .*"
|
|
|
+ - linters:
|
|
|
+ - staticcheck
|
|
|
+ text: "SA4006: this value of .* is never used"
|
|
|
+ - linters:
|
|
|
+ - staticcheck
|
|
|
+ text: "SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead"
|
|
|
+
|
|
|
+ #
|
|
|
+ # gosimple
|
|
|
+ #
|
|
|
+
|
|
|
+ - linters:
|
|
|
+ - gosimple
|
|
|
+ text: "S1023: redundant .* statement"
|
|
|
+ - linters:
|
|
|
+ - gosimple
|
|
|
+ text: "S1000: should use a simple channel send/receive instead of `select` with a single case"
|
|
|
+ - linters:
|
|
|
+ - gosimple
|
|
|
+ text: "S1028: should use .* instead of .*"
|
|
|
+
|
|
|
+ #
|
|
|
+ # deadcode
|
|
|
+ #
|
|
|
+
|
|
|
+ - linters:
|
|
|
+ - deadcode
|
|
|
+ - unused
|
|
|
+ - structcheck
|
|
|
+ text: ".* is unused"
|
|
|
+
|
|
|
+ #
|
|
|
+ # ineffassign
|
|
|
+ #
|
|
|
+
|
|
|
+ - linters:
|
|
|
+ - ineffassign
|
|
|
+ text: "ineffectual assignment to .*"
|