summaryrefslogtreecommitdiffhomepage
path: root/.golangci.yml
blob: eb34f9d9efc76b7603e7e986bacb3bfd0534f790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
version: "2"
# Configuration for how we run golangci-lint
# Timeout of 5m was the default in v1.
run:
  timeout: 5m
linters:
  # Don't enable any linters by default; just the ones that we explicitly
  # enable in the list below.
  default: none
  enable:
    - bidichk
    - govet
    - misspell
    - revive
  settings:
    # Matches what we use in corp as of 2023-12-07
    govet:
      enable:
        - asmdecl
        - assign
        - atomic
        - bools
        - buildtag
        - cgocall
        - copylocks
        - deepequalerrors
        - errorsas
        - framepointer
        - httpresponse
        - ifaceassert
        - loopclosure
        - lostcancel
        - nilfunc
        - nilness
        - printf
        - reflectvaluecompare
        - shift
        - sigchanyzer
        - sortslice
        - stdmethods
        - stringintconv
        - structtag
        - testinggoroutine
        - tests
        - unmarshal
        - unreachable
        - unsafeptr
        - unusedresult
      settings:
        printf:
          # List of print function names to check (in addition to default)
          funcs:
            - github.com/tailscale/tailscale/types/logger.Discard
            # NOTE(andrew-d): this doesn't currently work because the printf
            # analyzer doesn't support type declarations
            #- github.com/tailscale/tailscale/types/logger.Logf
    revive:
      enable-all-rules: false
      rules:
        - name: atomic
        - name: context-keys-type
        - name: defer
          arguments: [[
              # Calling 'recover' at the time a defer is registered (i.e. "defer recover()") has no effect.
              "immediate-recover",
              # Calling 'recover' outside of a deferred function has no effect
              "recover",
              # Returning values from a deferred function has no effect
              "return",
          ]]
        - name: duplicated-imports
        - name: errorf
        - name: string-of-int
        - name: time-equal
        - name: unconditional-recursion
        - name: useless-break
        - name: waitgroup-by-value
  exclusions:
    generated: lax
    presets:
      - comments
      - common-false-positives
      - legacy
      - std-error-handling
    rules:
      # These are forks of an upstream package and thus are exempt from stylistic
      # changes that would make pulling in upstream changes harder.
      - path: tempfork/.*\.go
        text: File is not `gofmt`-ed with `-s` `-r 'interface{} -> any'`
      - path: util/singleflight/.*\.go
        text: File is not `gofmt`-ed with `-s` `-r 'interface{} -> any'`
    paths:
      - third_party$
      - builtin$
      - examples$
formatters:
  enable:
    - gofmt
    - goimports
  settings:
    gofmt:
      rewrite-rules:
        - pattern: interface{}
          replacement: any
  exclusions:
    generated: lax
    paths:
      - third_party$
      - builtin$
      - examples$