...

Text file src/go.mongodb.org/mongo-driver/.golangci.yml

Documentation: go.mongodb.org/mongo-driver

     1run:
     2  timeout: 5m
     3  skip-dirs-use-default: false
     4  skip-dirs:
     5    - (^|/)vendor($|/)
     6    - (^|/)testdata($|/)
     7    - (^|/)etc($|/)
     8    # Disable all linters for "golang.org/x/exp/rand" package in internal/rand.
     9    - internal/rand
    10
    11linters:
    12  disable-all: true
    13  # TODO(GODRIVER-2156): Enable all commented-out linters.
    14  enable:
    15    - errcheck
    16    # - errorlint
    17    - exportloopref
    18    - gocritic
    19    - goimports
    20    - gosimple
    21    - gosec
    22    - govet
    23    - ineffassign
    24    - makezero
    25    - misspell
    26    - nakedret
    27    - paralleltest
    28    - prealloc
    29    - revive
    30    - staticcheck
    31    - typecheck
    32    - unused
    33    - unconvert
    34    - unparam
    35
    36linters-settings:
    37  errcheck:
    38    exclude: .errcheck-excludes
    39  gocritic:
    40    enabled-checks:
    41      # Detects suspicious append result assignments. E.g. "b := append(a, 1, 2, 3)"
    42      - appendAssign
    43  govet:
    44    disable:
    45      - cgocall
    46      - composites
    47  paralleltest:
    48    # Ignore missing calls to `t.Parallel()` and only report incorrect uses of `t.Parallel()`.
    49    ignore-missing: true
    50  staticcheck:
    51    checks: [
    52      "all",
    53      "-SA1019", # Disable deprecation warnings for now.
    54      "-SA1012", # Disable "do not pass a nil Context" to allow testing nil contexts in tests.
    55    ]
    56
    57issues:
    58  exclude-use-default: false
    59  exclude:
    60    # Add all default excluded issues except issues related to exported types/functions not having
    61    # comments; we want those warnings. The defaults are copied from the "--exclude-use-default"
    62    # documentation on https://golangci-lint.run/usage/configuration/#command-line-options
    63    ## Defaults ##
    64    # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
    65    - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
    66    # EXC0003 golint: False positive when tests are defined in package 'test'
    67    - func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
    68    # EXC0004 govet: Common false positives
    69    - (possible misuse of unsafe.Pointer|should have signature)
    70    # EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
    71    - ineffective break statement. Did you mean to break out of the outer loop
    72    # EXC0006 gosec: Too many false-positives on 'unsafe' usage
    73    - Use of unsafe calls should be audited
    74    # EXC0007 gosec: Too many false-positives for parametrized shell calls
    75    - Subprocess launch(ed with variable|ing should be audited)
    76    # EXC0008 gosec: Duplicated errcheck checks
    77    - (G104|G307)
    78    # EXC0009 gosec: Too many issues in popular repos
    79    - (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
    80    # EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
    81    - Potential file inclusion via variable
    82    ## End Defaults ##
    83
    84    # Ignore capitalization warning for this weird field name.
    85    - "var-naming: struct field CqCssWxW should be CqCSSWxW"
    86    # Ignore warnings for common "wiremessage.Read..." usage because the safest way to use that API
    87    # is by assigning possibly unused returned byte buffers.
    88    - "SA4006: this value of `wm` is never used"
    89    - "SA4006: this value of `rem` is never used"
    90    - "ineffectual assignment to wm"
    91    - "ineffectual assignment to rem"
    92
    93  exclude-rules:
    94    # Ignore some linters for example code that is intentionally simplified.
    95    - path: examples/
    96      linters:
    97        - revive
    98        - errcheck
    99    # Disable "unused" linter for code files that depend on the "mongocrypt.MongoCrypt" type because
   100    # the linter build doesn't work correctly with CGO enabled. As a result, all calls to a
   101    # "mongocrypt.MongoCrypt" API appear to always panic (see mongocrypt_not_enabled.go), leading
   102    # to confusing messages about unused code.
   103    - path: x/mongo/driver/crypt.go|mongo/(crypt_retrievers|mongocryptd).go
   104      linters:
   105        - unused
   106    # Ignore "TLS MinVersion too low", "TLS InsecureSkipVerify set true", and "Use of weak random
   107    # number generator (math/rand instead of crypto/rand)" in tests.
   108    - path: _test\.go
   109      text: G401|G402|G404
   110      linters:
   111        - gosec
   112    # Ignore missing comments for exported variable/function/type for code in the "internal" and
   113    # "benchmark" directories.
   114    - path: (internal\/|benchmark\/)
   115      text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
   116    # Ignore missing package comments for directories that aren't frequently used by external users.
   117    - path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/)
   118      text: should have a package comment

View as plain text