# golangci-lint configuration # Compatible with golangci-lint v2.4+ and Go 1.20 # This is a best practice starter configuration that can be gradually enhanced version: "2" run: # Go version - fixed to 1.20 go: "1.20" # Timeout setting timeout: "5m" # Allow parallel runners allow-parallel-runners: true # Module download mode modules-download-mode: "mod" # Code formatters configuration formatters: enable: - gofmt # Go official formatter - goimports # Automatic import management - gci # Import grouping and sorting settings: gofmt: # Simplify code simplify: true goimports: # Local package prefix (must be array in v2) local-prefixes: - github.com/moond4rk/hackbrowserdata gci: # Import section order sections: - standard # Standard library - default # Third-party libraries - prefix(github.com/moond4rk/hackbrowserdata) # Local packages # Linter configuration linters: # Use standard linters as base default: standard # Additional enabled linters (best practices recommended) enable: # Error checking - errcheck # Check unhandled errors - errorlint # Improve error handling # Code quality - ineffassign # Detect ineffective assignments - revive # Code quality checks - misspell # Spell checking - unconvert # Detect unnecessary type conversions # Security related - gosec # Security vulnerability checks # Performance related - prealloc # Slice preallocation optimization # Code standards - whitespace # Whitespace checks # Best practices - gocritic # Comprehensive code analysis - goprintffuncname # Printf function naming checks # Dependency management - depguard # Package dependency control - gomodguard # Go module dependency control # Code complexity (optional for initial setup) - funlen # Function length checks - goconst # Magic number checks # Explicitly disabled linters (to avoid false positives and noise) disable: - exhaustruct # Struct field completeness check (too strict) - wrapcheck # Error wrapping check (project specific) - testpackage # Test package separation (not conventional) - paralleltest # Parallel test check (not always needed) - nlreturn # Newline before return (too strict) - wsl # Whitespace rules (too strict) - gochecknoglobals # No global variables (sometimes needed) - gochecknoinits # No init functions (sometimes needed) - exhaustive # Enum completeness (too strict initially) - unused # Temporarily disabled for gradual cleanup # Exclusion configuration exclusions: # Paths to exclude paths: - vendor - third_party - testdata - ".*\\.pb\\.go$" - ".*\\.gen\\.go$" # Use default exclusion presets presets: - comments - common-false-positives - legacy - std-error-handling # Exclusion rules rules: # Test file exclusions - path: '_test\.go' linters: - dupl - funlen - goconst - gosec - errcheck # Generated file exclusions - path: '\.pb\.go$' linters: - all # Vendor directory exclusions - path: "vendor" linters: - all # Defer statement exclusions - source: "defer" linters: - errcheck # SQL query exclusions - text: "SELECT" linters: - gosec # Package comment exclusions - text: "should have a package comment" linters: - staticcheck - revive # Types package exclusions - path: "types/types.go" linters: - revive # Unused code exclusions (temporary) - text: "is unused" linters: - unused - staticcheck # Linter specific settings settings: # Error check settings errcheck: # Check type assertion errors check-type-assertions: true # Don't check blank identifier check-blank: false # Excluded functions - expanded list to reduce noise exclude-functions: - "os.Remove" - "os.RemoveAll" - "io.Copy(os.Stdout)" - "(*database/sql.DB).Close" - "(*database/sql.Rows).Close" - "(*github.com/syndtr/goleveldb/leveldb.DB).Close" - "defer" - "(net/http.ResponseWriter).Write" # Security check settings gosec: # Excluded rules (adjust based on project needs) excludes: - G101 # Hardcoded credentials - too many false positives - G104 # Error checking (handled by errcheck) - G304 # File path traversal (needed for project features) - G306 # Poor file permissions (test files) - G401 # Weak cryptographic algorithm (needed for compatibility) - G405 # Weak cryptographic algorithm - G501 # Import crypto/md5 (needed for compatibility) - G502 # Import crypto/des (needed for compatibility) - G505 # Import crypto/sha1 (needed for compatibility) # Go vet settings govet: enable-all: true disable: - fieldalignment # Field alignment optimization (premature optimization) - shadow # Variable shadowing (sometimes intentional) # Static check settings staticcheck: # Check all except the ones we exclude checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", ] # Revive settings revive: severity: warning rules: - name: unused-parameter disabled: true # Interface implementations may not use all parameters - name: var-naming disabled: true # Too many false positives with types package - name: package-comments disabled: true # Package comments are not mandatory - name: exported disabled: true # Not all exported types need comments initially # Function length settings funlen: lines: 150 # Increased for existing code statements: 80 # Increased for existing code ignore-comments: true # Code critic settings gocritic: enabled-tags: - diagnostic - performance disabled-checks: - hugeParam # Large value parameters (sometimes needed) - rangeValCopy # Range value copy (minimal performance impact) - commentedOutCode # Allow commented code for now - ifElseChain # Allow if-else chains settings: rangeExprCopy: sizeThreshold: 512 # Dependency guard settings depguard: rules: main: files: - $all deny: - pkg: "github.com/pkg/errors" desc: "Use standard library errors package instead" - pkg: "io/ioutil" desc: "io/ioutil is deprecated, use io or os package" # Spell check settings misspell: locale: US ignore-rules: - behaviour # British spelling # goconst settings - make it less aggressive goconst: min-len: 5 # Minimum length of string constant min-occurrences: 5 # Increased from default 3 # Output configuration output: # Output format - use text format with colors formats: text: path: stdout colors: true