|
| 1 | +# options for analysis running |
| 2 | +run: |
| 3 | + # timeout for analysis, e.g. 30s, 5m, default is 1m |
| 4 | + timeout: 1m |
| 5 | + |
| 6 | +output: |
| 7 | + sort-results: true |
| 8 | + |
| 9 | +# Uncomment and add a path if needed to exclude |
| 10 | +# skip-dirs: |
| 11 | +# - some/path |
| 12 | +# skip-files: |
| 13 | +# - ".*\\.my\\.go$" |
| 14 | +# - lib/bad.go |
| 15 | + |
| 16 | +# Find the whole list here https://golangci-lint.run/usage/linters/ |
| 17 | +linters: |
| 18 | + disable-all: true |
| 19 | + enable: |
| 20 | + - deadcode # finds unused code |
| 21 | + - errcheck # checking for unchecked errors in go programs |
| 22 | + - 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. |
| 23 | + - goconst # finds repeated strings that could be replaced by a constant |
| 24 | + - dupl # tool for code clone detection |
| 25 | + - forbidigo # forbids identifiers matched by reg exps |
| 26 | + - gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. |
| 27 | + - gosimple # linter for Go source code that specializes in simplifying a code |
| 28 | + - misspell # finds commonly misspelled English words in comments |
| 29 | + - nakedret # finds naked returns in functions greater than a specified function length |
| 30 | + - prealloc # finds slice declarations that could potentially be preallocated |
| 31 | + - nolintlint # reports ill-formed or insufficient nolint directives |
| 32 | + - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks |
| 33 | + - stylecheck # a replacement for golint |
| 34 | + - unparam # reports unused function parameters |
| 35 | + - unused # checks Go code for unused constants, variables, functions and types |
| 36 | + |
| 37 | + - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string |
| 38 | + - ineffassign # detects when assignments to existing variables are not used |
| 39 | + - structcheck # finds unused struct fields |
| 40 | + - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code |
| 41 | + - varcheck # Finds unused global variables and constants |
| 42 | + - asciicheck # simple linter to check that your code does not contain non-ASCII identifiers |
| 43 | + - bodyclose # checks whether HTTP response body is closed successfully |
| 44 | + - durationcheck # check for two durations multiplied together |
| 45 | + - exportloopref # checks for pointers to enclosing loop variables |
| 46 | + - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports |
| 47 | + - gosec # inspects source code for security problems |
| 48 | + - importas # enforces consistent import aliases |
| 49 | + - nilerr # finds the code that returns nil even if it checks that the error is not nil. |
| 50 | + - noctx # noctx finds sending http request without context.Context |
| 51 | + - unconvert # Remove unnecessary type conversions |
| 52 | + - wastedassign # wastedassign finds wasted assignment statements. |
| 53 | + - godox # tool for detection of FIXME, TODO and other comment keywords |
| 54 | + |
| 55 | +# all available settings of specific linters |
| 56 | +linters-settings: |
| 57 | + errcheck: |
| 58 | + # report about not checking of errors in type assertions: `a := b.(MyStruct)`; |
| 59 | + # default is false: such cases aren't reported by default. |
| 60 | + check-type-assertions: true |
| 61 | + |
| 62 | + errorlint: |
| 63 | + # Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats |
| 64 | + errorf: true |
| 65 | + # Check for plain type assertions and type switches |
| 66 | + asserts: true |
| 67 | + # Check for plain error comparisons |
| 68 | + comparison: true |
| 69 | + |
| 70 | + goconst: |
| 71 | + # minimal length of string constant, 3 by default |
| 72 | + min-len: 3 |
| 73 | + # minimal occurrences count to trigger, 3 by default |
| 74 | + min-occurrences: 2 |
| 75 | + |
| 76 | + dupl: |
| 77 | + # tokens count to trigger issue, 150 by default |
| 78 | + threshold: 100 |
| 79 | + |
| 80 | + forbidigo: |
| 81 | + # Forbid the following identifiers |
| 82 | + forbid: |
| 83 | + - fmt.Print.* # too much log noise |
| 84 | + # Exclude godoc examples from forbidigo checks. Default is true. |
| 85 | + exclude_godoc_examples: true |
| 86 | + |
| 87 | + gomoddirectives: |
| 88 | + # Allow local `replace` directives. Default is false. |
| 89 | + replace-local: false |
| 90 | + |
| 91 | + gosimple: |
| 92 | + # Select the Go version to target. The default is '1.13'. |
| 93 | + go: "1.17" |
| 94 | + |
| 95 | + misspell: |
| 96 | + # Correct spellings using locale preferences for US or UK. |
| 97 | + # Default is to use a neutral variety of English. |
| 98 | + # Setting locale to US will correct the British spelling of 'colour' to 'color'. |
| 99 | + # locale: US |
| 100 | + # ignore-words: |
| 101 | + # - IdP |
| 102 | + |
| 103 | + nakedret: |
| 104 | + # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 |
| 105 | + max-func-lines: 0 |
| 106 | + |
| 107 | + prealloc: |
| 108 | + # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. |
| 109 | + # True by default. |
| 110 | + simple: true |
| 111 | + range-loops: true # Report preallocation suggestions on range loops, true by default |
| 112 | + for-loops: false # Report preallocation suggestions on for loops, false by default |
| 113 | + |
| 114 | + nolintlint: |
| 115 | + # Enable to ensure that nolint directives are all used. Default is true. |
| 116 | + allow-unused: false |
| 117 | + # Disable to ensure that nolint directives don't have a leading space. Default is true. |
| 118 | + allow-leading-space: true |
| 119 | + # Exclude following linters from requiring an explanation. Default is []. |
| 120 | + allow-no-explanation: [] |
| 121 | + # Enable to require an explanation of nonzero length after each nolint directive. Default is false. |
| 122 | + require-explanation: true |
| 123 | + # Enable to require nolint directives to mention the specific linter being suppressed. Default is false. |
| 124 | + require-specific: true |
| 125 | + |
| 126 | + staticcheck: |
| 127 | + # Select the Go version to target. The default is '1.13'. |
| 128 | + go: "1.17" |
| 129 | + |
| 130 | + stylecheck: |
| 131 | + # Select the Go version to target. The default is '1.13'. |
| 132 | + go: "1.17" |
| 133 | + |
| 134 | + unparam: |
| 135 | + # Inspect exported functions, default is false. Set to true if no external program/library imports your code. |
| 136 | + # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: |
| 137 | + # if it's called for subdir of a project it can't find external interfaces. All text editor integrations |
| 138 | + # with golangci-lint call it on a directory with the changed file. |
| 139 | + check-exported: false |
| 140 | + |
| 141 | + unused: |
| 142 | + # Select the Go version to target. The default is '1.13'. |
| 143 | + go: "1.17" |
0 commit comments