diff --git a/.golangci.yml b/.golangci.yml index e62350f..8a91f85 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,226 +1,200 @@ -# .golangci.yml +version: "2" run: modules-download-mode: mod - -linters-settings: - - gosec: - excludes: - - G307 - - staticcheck: - # https://staticcheck.io/docs/options#checks - checks: [ "all" ] - - tagliatelle: - # Check the struck tag name case. - case: - # Use the struct field name to check the name of the struct tag. - # Default: false - use-field-name: true +linters: + default: none + enable: + - bidichk + - bodyclose + - containedctx + - contextcheck + - decorder + - dupl + - dupword + - err113 + - errcheck + - errchkjson + - errname + - exhaustive + - exptostd + - fatcontext + - forcetypeassert + - gochecksumtype + - gocognit + - goconst + - gocritic + - gocyclo + - godot + - gosec + - gosmopolitan + - govet + - grouper + - iface + - importas + - inamedparam + - ineffassign + - interfacebloat + - loggercheck + - mirror + - mnd + - musttag + - nilnesserr + - nilnil + - perfsprint + - prealloc + - reassign + - recvcheck + - revive + - staticcheck + - tagalign + - tagliatelle + - testableexamples + - thelper + - unused + - usestdlibvars + - usetesting + - varnamelen + - wsl + settings: + dupl: + threshold: 300 + errcheck: + exclude-functions: + - (*net/http.Response.Body).Close + - (io.ReadCloser).Close + - (*database/sql.DB).Close + gocognit: + min-complexity: 20 + goconst: + min-len: 2 + min-occurrences: 2 + gocritic: + disabled-checks: + - dupImport + - whyNoLint + - hugeParam + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + gocyclo: + min-complexity: 20 + gosec: + excludes: + - G307 + misspell: + locale: US + nolintlint: + require-explanation: true + require-specific: false + allow-unused: false + revive: + confidence: 0.1 + enable-all-rules: true rules: - # Any struct tag type can be used. - # Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower` - json: snake - - dupl: - threshold: 300 # tokens count of duplicate code to trigger issue - - goconst: - min-len: 2 # minimal length of string constant - min-occurrences: 2 # minimal occurrences count to trigger - - gocritic: - enabled-tags: - - diagnostic - - experimental - - opinionated - - performance - - style - disabled-checks: - - dupImport # https://github.com/go-critic/go-critic/issues/845 - - whyNoLint - - hugeParam - - gocyclo: - min-complexity: 20 # minimal code cyclomatic complexity to report - - mnd: - settings: - mnd: - # don't include the "operation" and "assign" - checks: [argument,case,condition,return] - - misspell: - locale: US - - nolintlint: - allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) - allow-unused: false # report any unused nolint directives - require-explanation: true # don't require an explanation for nolint directives - require-specific: false # don't require nolint directives to be specific about which linter is being skipped - - gocognit: - min-complexity: 20 # minimal code cognitive complexity to report - - gofumpt: - extra-rules: true - - varnamelen: - max-distance: 15 - ignore-names: - - tx - - err - - pk - - to - - db - - wg - - id - - DB - ignore-type-assert-ok: true - ignore-map-index-ok: true - ignore-chan-recv-ok: true - ignore-decls: - - t testing.T - - i int - - T any - - i *is.I - - eg *errgroup.Group - - ok bool - - revive: - ignore-generated-header: true - enable-all-rules: true - confidence: 0.1 + - name: nested-structs + disabled: true + - name: function-result-limit + arguments: + - 3 + - name: function-length + disabled: true + - name: banned-characters + disabled: true + - name: max-public-structs + disabled: true + - name: line-length-limit + arguments: + - 100 + - name: argument-limit + disabled: true + - name: cyclomatic + disabled: true + - name: file-header + disabled: true + - name: cognitive-complexity + disabled: true + - name: package-comments + disabled: true + - name: add-constant + disabled: true + - name: unhandled-error + disabled: true + - name: confusing-naming + disabled: true + - name: modifies-parameter + disabled: true + - name: var-naming + arguments: + - [] + - - WS + - VM + staticcheck: + checks: + - all + tagliatelle: + case: + rules: + json: snake + use-field-name: true + varnamelen: + max-distance: 15 + ignore-names: + - tx + - err + - pk + - to + - db + - wg + - id + - DB + ignore-type-assert-ok: true + ignore-map-index-ok: true + ignore-chan-recv-ok: true + ignore-decls: + - t testing.T + - i int + - T any + - i *is.I + - eg *errgroup.Group + - ok bool + exclusions: + generated: lax rules: - - name: nested-structs - disabled: true - - name: function-result-limit - arguments: [ 3 ] - - name: function-length - disabled: true - - name: banned-characters - disabled: true - - name: max-public-structs - disabled: true - - name: line-length-limit - arguments: [ 100 ] - - name: argument-limit - disabled: true - - name: cyclomatic - disabled: true - - name: file-header - disabled: true - - name: cognitive-complexity - disabled: true - - name: package-comments - disabled: true - - name: add-constant - disabled: true - - name: unhandled-error - disabled: true - - name: confusing-naming - disabled: true - - name: modifies-parameter - disabled: true - - name: var-naming - arguments: [[], ["WS", "VM"]] - errcheck: - exclude-functions: - - (*net/http.Response.Body).Close - - (io.ReadCloser).Close - - (*database/sql.DB).Close - -linters: - disable-all: true + - linters: + - err113 + - errcheck + - forcetypeassert + - gocognit + - gocyclo + - gosec + - nilnil + - varnamelen + path: _test\.go + - linters: + - dupl + - errcheck + - forcetypeassert + - gocyclo + - gosec + - revive + path: mock + paths: + - third_party$ + - builtin$ + - examples$ +formatters: enable: - - bidichk # Checks for dangerous unicode character sequences - - contextcheck # check the function whether use a non-inherited context - - containedctx # containedctx is a linter that detects struct contained context.Context field - - decorder # check declaration order and count of types, constants, variables and functions - - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. - - grouper # An analyzer to analyze expression groups. - - govet # Vet examines Go source code and reports suspicious constructs, only purpose of this tool is to detect go structs that would take less memory if their fields were sorted - - bodyclose # Detects whether the HTTP response body is closed successfully, not closing the response body could lead to memory leaks - - goconst # Finds repeated strings that could be replaced by a constant - - godot # Check if comments end in a period - - mnd # An analyzer to detect magic numbers. - - err113 # Golang linter to check the errors handling expressions - - gocritic # Provides many diagnostics that check for bugs, performance and style issues. - - exhaustive # Check exhaustiveness of enum switch statements - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - forcetypeassert # finds forced type assertions - - importas # Enforces consistent import aliases - - gci # improves imports - - dupl # Detects code clones - - revive # Makes code style recomandations - - gocyclo # Computes and checks the cyclomatic complexity of functions - - gofumpt # Stricter gofmt - - errcheck # Checks unchecked errors in go programs - - gosimple # Linter for Go source code that specializes in simplifying a code - - ineffassign # Detects when assignments to existing variables are not used - - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks - - tagliatelle # Checks the struct tags. - - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers - - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 - - unused # Checks Go code for unused constants, variables, functions and types - - varnamelen # checks that the length of a variable's name matches its scope style - - gocognit # Computes and checks the cognitive complexity of functions https://github.com/uudashr/gocognit - - gosec # Inspects source code for security problems - - prealloc # Finds slice declarations that could potentially be preallocated - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - wsl # Whitespace Linter - Forces you to use empty lines! - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - interfacebloat # A linter that checks the number of methods inside an interface. - - loggercheck # Check logr arguments. - - reassign # Checks that package variables are not reassigne - - musttag # linter that enforces field tags in (un)marshaled structslinter that enforces field tags in (un)marshaled structs - - dupword # checks for duplicate words in the source code comments. - - testableexamples # checks if examples are testable (have an expected output) - - fatcontext # Detects potential fat contexts in loops or function literals. - - copyloopvar # Detects places where loop variables are copied. - - intrange # Detect loops that could use the Go 1.22 integer range feature. - - perfsprint # Detects performance issues with fmt.Sprintf. - - inamedparam # Detects interfaces with unnamed method parameters. - - gochecksumtype # Detects the use of checksum types in Go code. - - mirror # Use right mirror functions for string/[]byte performance bust. - - tagalign # Align and sort tags for Go struct. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - nilnesserr # Detects nil errors in Go code. - - usetesting # Detects when some calls can be replaced by methods from the testing package. - - recvcheck # Golang linter checks for receiver type consistency. - - iface # Detects the incorrect use of interfaces. - -issues: - exclude-use-default: false - include: - - EXC0001 - - EXC0004 - - EXC0006 - - EXC0007 - - EXC0009 - - EXC0010 - - EXC0014 - - # Excluding configuration per-path, per-linter, per-text and per-source - exclude-rules: - # Exclude some linters from running on tests files. - - path: _test\.go - linters: - - gocyclo - - errcheck - - gosec - - gocognit - - forcetypeassert - - varnamelen - - nilnil - - goerr113 - - path: mock - linters: - - revive - - gocyclo - - errcheck - - dupl - - gosec - - forcetypeassert \ No newline at end of file + - gci + - gofumpt + settings: + gofumpt: + extra-rules: true + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$