all repos

onasty @ 5829b75

a one-time notes service

onasty/.golangci.yaml (view raw)

Smirnov Oleksandr Smirnov Oleksandr
ss2316544@gmail.com
feat: add cors (#115)..., 1 year 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
87
    funlen:
88
      lines: 100
89
      statements: 50
90
      ignore-comments: true
91
92
    gocritic:
93
      settings:
94
        captLocal:
95
          paramsOnly: false
96
        underef:
97
          skipRecvDeref: false
98
99
    govet:
100
      disable:
101
        - fieldalignment
102
      enable-all: true
103
104
  exclusions:
105
    generated: lax
106
    presets:
107
      - comments
108
      - common-false-positives
109
      - legacy
110
      - std-error-handling
111
    rules:
112
      - linters:
113
          - gocritic
114
        source: //noinspection
115
      - linters:
116
          - bodyclose
117
          - dupl
118
          - err113
119
          - funlen
120
          - goconst
121
          - gosec
122
          - lll
123
          - noctx
124
          - wrapcheck
125
        path: _test\.go
126
    paths:
127
      - third_party$
128
      - builtin$
129
      - examples$
130
131
issues:
132
  max-same-issues: 50
133
134
formatters:
135
  enable:
136
    - gofumpt
137
    - goimports
138
  exclusions:
139
    generated: lax
140
    paths:
141
      - third_party$
142
      - builtin$
143
      - examples$