|
| 1 | +# golangci-lint v1 configuration for grant-cli |
| 2 | +# golangci-lint v1.64.8 | Go 1.25+ |
| 3 | +# https://golangci-lint.run/usage/configuration/ |
| 4 | + |
| 5 | +run: |
| 6 | + timeout: 3m |
| 7 | + tests: true |
| 8 | + |
| 9 | +linters: |
| 10 | + disable-all: true |
| 11 | + enable: |
| 12 | + # --- Default linters --- |
| 13 | + - errcheck |
| 14 | + - gosimple |
| 15 | + - govet |
| 16 | + - ineffassign |
| 17 | + - staticcheck |
| 18 | + - unused |
| 19 | + # --- Bug detection --- |
| 20 | + - bodyclose # unclosed HTTP response bodies |
| 21 | + - errorlint # error wrapping correctness (Go 1.13+) |
| 22 | + - noctx # HTTP requests without context.Context |
| 23 | + # --- Security --- |
| 24 | + - gosec # security issue detection |
| 25 | + # --- Style & naming --- |
| 26 | + - errname # sentinel error naming (ErrFoo) |
| 27 | + - gocritic # diagnostic/style/performance checks |
| 28 | + - misspell # common English typos |
| 29 | + - revive # configurable Go linter (golint replacement) |
| 30 | + # --- Complexity --- |
| 31 | + - gocognit # cognitive complexity |
| 32 | + # --- Performance --- |
| 33 | + - perfsprint # fmt.Sprintf replaceable with concatenation |
| 34 | + - unconvert # unnecessary type conversions |
| 35 | + # --- Testing --- |
| 36 | + - usetesting # modern test helpers (t.Context, etc.) |
| 37 | + |
| 38 | +linters-settings: |
| 39 | + gocognit: |
| 40 | + min-complexity: 40 |
| 41 | + |
| 42 | + gocritic: |
| 43 | + enabled-tags: |
| 44 | + - diagnostic |
| 45 | + - style |
| 46 | + - performance |
| 47 | + disabled-checks: |
| 48 | + - hugeParam # small structs in a CLI are fine |
| 49 | + - rangeValCopy # same: small value copies are fine |
| 50 | + |
| 51 | + gosec: |
| 52 | + excludes: |
| 53 | + # G101 "hardcoded credentials" false-positives on test JWT tokens |
| 54 | + - G101 |
| 55 | + |
| 56 | + revive: |
| 57 | + severity: warning |
| 58 | + enable-all-rules: false |
| 59 | + rules: |
| 60 | + - name: blank-imports |
| 61 | + - name: context-as-argument |
| 62 | + - name: context-keys-type |
| 63 | + - name: dot-imports |
| 64 | + - name: empty-block |
| 65 | + - name: error-naming |
| 66 | + - name: error-return |
| 67 | + - name: error-strings |
| 68 | + - name: errorf |
| 69 | + # exported: disabled because stuttering names (cache.CacheDir, |
| 70 | + # config.ConfigDir, sca.SCAAccessService) are established API. |
| 71 | + - name: exported |
| 72 | + disabled: true |
| 73 | + - name: increment-decrement |
| 74 | + - name: indent-error-flow |
| 75 | + - name: range |
| 76 | + - name: receiver-naming |
| 77 | + - name: redefines-builtin-id |
| 78 | + - name: superfluous-else |
| 79 | + - name: time-naming |
| 80 | + - name: unexported-return |
| 81 | + - name: unreachable-code |
| 82 | + - name: var-declaration |
| 83 | + - name: var-naming |
| 84 | + # unused-parameter: disabled because Cobra RunE signatures require |
| 85 | + # func(cmd *cobra.Command, args []string) and test mocks implement |
| 86 | + # interfaces with necessarily unused parameters. |
| 87 | + - name: unused-parameter |
| 88 | + disabled: true |
| 89 | + |
| 90 | + misspell: |
| 91 | + locale: US |
| 92 | + |
| 93 | +issues: |
| 94 | + max-issues-per-linter: 0 |
| 95 | + max-same-issues: 0 |
| 96 | + |
| 97 | + exclude-rules: |
| 98 | + # Test files: relax security checks (G306 WriteFile perms in temp dirs) |
| 99 | + - path: _test\.go |
| 100 | + linters: |
| 101 | + - gosec |
| 102 | + |
| 103 | + # Test files: relax complexity checks (table-driven tests are long) |
| 104 | + - path: _test\.go |
| 105 | + linters: |
| 106 | + - gocognit |
| 107 | + |
| 108 | + # Test files: bodyclose on mock HTTP responses |
| 109 | + - path: _test\.go |
| 110 | + linters: |
| 111 | + - bodyclose |
0 commit comments