all repos

onasty @ d87c770

a one-time notes service

onasty/.golangci.yaml (view raw)

Smirnov Oleksandr Smirnov Oleksandr
ss2316544@gmail.com
chore(linter): ignore some of the Config structs (#145), 11 months ago
1
version: "2"
2
run:
3
  tests: true
4
5
linters:
6
  default: none
7
  enable:
8
    - errcheck # checking for unchecked errors
9
    - govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
10
    - staticcheck # is a go vet on steroids, applying a ton of static analysis checks
11
    - ineffassign # detects when assignments to existing variables are not used
12
    - unused # checks for unused constants, variables, functions and types
13
    - asasalint # checks for pass []any as any in variadic func(...any)
14
    - asciicheck # checks that your code does not contain non-ASCII identifiers
15
    - bidichk # checks for dangerous unicode character sequences
16
    - bodyclose # checks whether HTTP response body is closed successfully
17
    - cyclop # checks function and package cyclomatic complexity
18
    - dupl # tool for code clone detection
19
    - durationcheck # checks for two durations multiplied together
20
    - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
21
    - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
22
    - exhaustive # checks exhaustiveness of enum switch statements
23
    - forbidigo # forbids identifiers
24
    - funlen # tool for detection of long functions
25
    - gocheckcompilerdirectives # validates go compiler directive comments (//go:)
26
    - gochecknoinits # checks that no init functions are present in Go code
27
    - gochecksumtype # checks exhaustiveness on Go "sum types"
28
    - goconst # finds repeated strings that could be replaced by a constant
29
    - gocritic # provides diagnostics that check for bugs, performance and style issues
30
    - gocyclo # computes and checks the cyclomatic complexity of functions
31
    - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
32
    - goprintffuncname # checks that printf-like functions are named with f at the end
33
    - gosec # inspects source code for security problems
34
    - lll # reports long lines
35
    - loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
36
    - makezero # finds slice declarations with non-zero initial length
37
    - mirror # reports wrong mirror patterns of bytes/strings usage
38
    - musttag # enforces field tags in (un)marshaled structs
39
    - nakedret # finds naked returns in functions greater than a specified function length
40
    - nestif # reports deeply nested if statements
41
    - nilerr # finds the code that returns nil even if it checks that the error is not nil
42
    - nilnil # checks that there is no simultaneous return of nil error and an invalid value
43
    - noctx # finds sending http request without context.Context
44
    - nolintlint # reports ill-formed or insufficient nolint directives
45
    - nonamedreturns # reports all named returns
46
    - nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
47
    - perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
48
    - predeclared # finds code that shadows one of Go's predeclared identifiers
49
    - promlinter # checks Prometheus metrics naming via promlint
50
    - protogetter # reports direct reads from proto message fields when getters should be used
51
    - reassign # checks that package variables are not reassigned
52
    - revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
53
    - rowserrcheck # checks whether Err of rows is checked successfully
54
    - sloglint # ensure consistent code style when using log/slog
55
    - sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
56
    - testableexamples # checks if examples are testable (have an expected output)
57
    - testifylint # checks usage of github.com/stretchr/testify
58
    - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
59
    - unconvert # removes unnecessary type conversions
60
    - unparam # reports unused function parameters
61
    - usestdlibvars # detects the possibility to use variables/constants from the Go standard library
62
    - wastedassign # finds wasted assignment statements
63
    - whitespace # detects leading and trailing whitespace
64
    - inamedparam # peports interfaces with unnamed method parameters
65
    - forcetypeassert # finds forced type assertions.
66
    - exhaustruct # checks if all structure fields are initialized.
67
    - err113 # forbids usage of dynamic errors
68
    - contextcheck # check whether the function uses a non-inherited context
69
    - ireturn # accept interfaces, return concrete types
70
71
  settings:
72
    cyclop:
73
      max-complexity: 30
74
      package-average: 10
75
76
    errcheck:
77
      check-type-assertions: true
78
79
    exhaustruct:
80
      exclude:
81
        - log/slog\.HandlerOptions
82
        - net/http\.(Server|Client|Response)
83
        - github.com/golang-jwt/jwt/v5\.RegisteredClaims
84
        - github.com/gin-contrib/cors\.Config
85
        - github.com/prometheus/client_golang/prometheus\.(CounterOpts|HistogramOpts)
86
        - github.com/nats-io/nats.go/micro\.Config
87
        - github.com/golang-migrate/migrate/v4/database/pgx.Config
88
89
    funlen:
90
      lines: 100
91
      statements: 50
92
      ignore-comments: true
93
94
    gocritic:
95
      settings:
96
        captLocal:
97
          paramsOnly: false
98
        underef:
99
          skipRecvDeref: false
100
101
    govet:
102
      disable:
103
        - fieldalignment
104
      enable-all: true
105
106
  exclusions:
107
    generated: lax
108
    presets:
109
      - comments
110
      - common-false-positives
111
      - legacy
112
      - std-error-handling
113
    rules:
114
      - linters:
115
          - gocritic
116
        source: //noinspection
117
      - linters:
118
          - bodyclose
119
          - dupl
120
          - err113
121
          - funlen
122
          - goconst
123
          - gosec
124
          - lll
125
          - noctx
126
          - wrapcheck
127
        path: _test\.go
128
    paths:
129
      - third_party$
130
      - builtin$
131
      - examples$
132
133
issues:
134
  max-same-issues: 50
135
136
formatters:
137
  enable:
138
    - gofumpt
139
    - goimports
140
  exclusions:
141
    generated: lax
142
    paths:
143
      - third_party$
144
      - builtin$
145
      - examples$