|
1 | 1 | # GolangCI-Lint configuration |
2 | | -# Suppress warnings from testcontainers dependencies |
| 2 | +# Focused on correctness checks, not style |
| 3 | +# Run with: golangci-lint run |
| 4 | + |
| 5 | +version: "2" |
| 6 | + |
| 7 | +run: |
| 8 | + # Timeout for analysis |
| 9 | + timeout: 5m |
| 10 | + # Include test files in analysis |
| 11 | + tests: true |
| 12 | + # Skip vendor and scripts directories |
| 13 | + skip-dirs: |
| 14 | + - vendor |
| 15 | + - scripts |
| 16 | + # Skip generated files |
| 17 | + skip-files: |
| 18 | + - ".*\\.pb\\.go$" |
| 19 | + - ".*\\.gen\\.go$" |
| 20 | + |
| 21 | +# Enable only correctness-focused linters |
| 22 | +linters: |
| 23 | + # Disable all linters first |
| 24 | + disable-all: true |
| 25 | + # Enable correctness-focused linters |
| 26 | + enable: |
| 27 | + # Core correctness checks |
| 28 | + - govet # Reports suspicious constructs |
| 29 | + - errcheck # Checks for unchecked errors |
| 30 | + - staticcheck # Advanced static analysis (includes type checking and gosimple checks) |
| 31 | + - ineffassign # Detects ineffectual assignments |
| 32 | + - unused # Finds unused code (replaces deadcode, varcheck, structcheck) |
| 33 | + - gosec # Security-focused linter |
| 34 | + - nilerr # Finds nil errors that should be checked |
| 35 | + - unconvert # Detects unnecessary conversions |
| 36 | + - unparam # Finds unused function parameters |
| 37 | + - gocritic # Advanced linter (correctness-focused checks, includes exportloopref) |
| 38 | + - bodyclose # Checks whether HTTP response body is closed |
| 39 | + - noctx # Detects http.Request without context |
| 40 | + - rowserrcheck # Checks for errors from database row operations |
| 41 | + - sqlclosecheck # Checks that sql.DB, sql.Rows, sql.Stmt, sql.Tx are closed |
3 | 42 |
|
4 | 43 | linters-settings: |
5 | | - gci: |
6 | | - # Suppress warnings from third-party packages |
7 | | - skip-generated: true |
| 44 | + # govet settings |
| 45 | + govet: |
| 46 | + check-shadowing: true |
| 47 | + enable-all: true |
| 48 | + |
| 49 | + # errcheck settings |
| 50 | + errcheck: |
| 51 | + check-type-assertions: true |
| 52 | + check-blank: true |
| 53 | + ignore: | |
| 54 | + fmt:.* |
| 55 | + io:Close|Write |
| 56 | + bytes:.* |
| 57 | + github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:Set |
| 58 | + database/sql:Rows.Close |
| 59 | + database/sql:Row.Scan |
| 60 | + |
| 61 | + # staticcheck settings |
| 62 | + staticcheck: |
| 63 | + checks: ["all"] |
| 64 | + |
| 65 | + # gosec settings |
| 66 | + gosec: |
| 67 | + severity: medium |
| 68 | + confidence: medium |
| 69 | + # Exclude some false positives common in Terraform providers |
| 70 | + excludes: |
| 71 | + - G101 # Look for hard coded credentials |
| 72 | + - G104 # Errors unhandled (we use errcheck for this) |
| 73 | + - G307 # Deferring a method which returns an error |
| 74 | + |
| 75 | + # gocritic settings - enable correctness-focused checks |
| 76 | + gocritic: |
| 77 | + enabled-tags: |
| 78 | + - diagnostic |
| 79 | + - experimental |
| 80 | + - opinionated |
| 81 | + disabled-checks: |
| 82 | + # Style-focused checks to disable |
| 83 | + - dupImport |
| 84 | + - importShadow |
| 85 | + - ifElseChain |
| 86 | + - octalLiteral |
| 87 | + - whyNoLint |
| 88 | + - wrapperFunc |
| 89 | + # Keep correctness-focused checks enabled |
| 90 | + |
| 91 | + # unused settings |
| 92 | + unused: |
| 93 | + check-exported: false # Don't require exported functions to be used |
| 94 | + |
| 95 | + # unparam settings |
| 96 | + unparam: |
| 97 | + check-exported: false # Don't require exported functions to use all params |
8 | 98 |
|
9 | 99 | issues: |
| 100 | + # Maximum issues count per one linter |
| 101 | + max-issues-per-linter: 0 |
| 102 | + # Maximum count of issues with the same text |
| 103 | + max-same-issues: 0 |
| 104 | + |
10 | 105 | exclude-rules: |
11 | | - # Suppress warnings from go-m1cpu (testcontainers dependency) |
| 106 | + # Exclude scripts directory (contains separate programs) |
| 107 | + - path: scripts/.* |
| 108 | + |
| 109 | + # Suppress warnings from testcontainers dependencies |
12 | 110 | - path: _test\.go |
13 | 111 | linters: |
14 | 112 | - gocritic |
15 | 113 | text: ".*go-m1cpu.*" |
| 114 | + |
| 115 | + # Allow unused parameters in test helpers |
| 116 | + - path: _test\.go |
| 117 | + linters: |
| 118 | + - unparam |
| 119 | + text: ".*is unused" |
| 120 | + |
| 121 | + # Suppress some false positives in test files |
| 122 | + - path: _test\.go |
| 123 | + linters: |
| 124 | + - errcheck |
| 125 | + text: "Error return value of .* is not checked" |
| 126 | + |
| 127 | + # Allow defer in test cleanup functions |
| 128 | + - path: _test\.go |
| 129 | + linters: |
| 130 | + - gosec |
| 131 | + text: ".*defer.*" |
0 commit comments