Skip to content
Snippets Groups Projects
.golangci.yml 11.9 KiB
Newer Older
run:
  timeout: 2m
  sort-results: true
Axel Prel's avatar
Axel Prel committed
  allow-parallel-runners: true
linters:
  disable-all: true
  enable:
    # enable by default linters
    - errcheck
Axel Prel's avatar
Axel Prel committed
    # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
    - gosimple
Axel Prel's avatar
Axel Prel committed
    # Linter for Go source code that specializes in simplifying code. [auto-fix]
Axel Prel's avatar
Axel Prel committed
    # Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [auto-fix]
    - ineffassign
Axel Prel's avatar
Axel Prel committed
    # Detects when assignments to existing variables are not used. [fast]
    - staticcheck
Axel Prel's avatar
Axel Prel committed
    # It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [auto-fix]
Axel Prel's avatar
Axel Prel committed
    # Checks Go code for unused constants, variables, functions and types.

    # extra linters
Axel Prel's avatar
Axel Prel committed
    - asasalint # ⚙️	Check for pass []any as any in variadic func(...any).	bugs		1.47.0
    - asciicheck  # Simple linter to check that your code does not contain non-ASCII identifiers
    - bidichk  # Checks for dangerous unicode character sequences
    - bodyclose  # checks whether HTTP response body is closed successfully
Axel Prel's avatar
Axel Prel committed
    # - canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header.	style		v1.58.0
    # - containedctx  # containedctx is a linter that detects struct contained context.Context field	style		1.44.0
    - contextcheck  # check the function whether use a non-inherited context	bugs		v1.43.0
Axel Prel's avatar
Axel Prel committed
    - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied.	style		v1.57.0
    # - cyclop  # checks function and package cyclomatic complexity	complexity		v1.37.0
Axel Prel's avatar
Axel Prel committed
    # - decorder  # check declaration order and count of types, constants, variables and functions	format, style		v1.44.0
    # - depguard  # Go linter that checks if package imports are in a list of acceptable packages	style, import, module		v1.4.0
Axel Prel's avatar
Axel Prel committed
    - dogsled  # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())	style		v1.19.0
Axel Prel's avatar
Axel Prel committed
    - dupl  # Tool for code clone detection	style		v1.0.0
Axel Prel's avatar
Axel Prel committed
    - dupword # ⚙️	Checks for duplicate words in the source code.	comment	✔	1.50.0
    - durationcheck  # check for two durations multiplied together	bugs		v1.37.0
Axel Prel's avatar
Axel Prel committed
    # - err113 # Go linter to check the errors handling expressions.	style, error		v1.26.0
    - errchkjson  # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.	bugs		1.44.0
Axel Prel's avatar
Axel Prel committed
    - errname  # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.	style		v1.42.0
Axel Prel's avatar
Axel Prel committed
    - 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.	bugs, error		v1.32.0
    - exhaustive  # check exhaustiveness of enum switch statements	bugs		v1.28.0
    # - exhaustruct  # Checks if all struct's fields are initialized	style, test		v1.32.0
Axel Prel's avatar
Axel Prel committed
    - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. [auto-fix]
Axel Prel's avatar
Axel Prel committed
    - fatcontext # Detects nested contexts in loops.	performance		1.58.0
Axel Prel's avatar
Axel Prel committed
    # - forbidigo  # Forbids identifiers	style		v1.34.0
Axel Prel's avatar
Axel Prel committed
    - forcetypeassert  # finds forced type assertions	style		v1.38.0
    # - funlen  # Tool for detection of long functions	complexity		v1.18.0
    - gci  # Gci control golang package import order and make it always deterministic.	format, import	✔	v1.30.0
Axel Prel's avatar
Axel Prel committed
    - ginkgolinter # Enforces standards of using ginkgo and gomega.	style		v1.51.0
    - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid.	bugs		v1.51.0
    # - gochecknoglobals  # check that no global variables exist. style		v1.12.0
    # - gochecknoinits  # Checks that no init functions are present in Go code	style		v1.12.0
Axel Prel's avatar
Axel Prel committed
    - gochecksumtype # Run exhaustiveness checks on Go "sum types".	bugs		v1.55.0
    # - gocognit  # Computes and checks the cognitive complexity of functions	complexity		v1.20.0
Axel Prel's avatar
Axel Prel committed
    - goconst  # Finds repeated strings that could be replaced by a constant	style		v1.0.0
    - gocritic  # Provides diagnostics that check for bugs, performance and style issues. style, metalinter		v1.12.0
    # - gocyclo  # Computes and checks the cyclomatic complexity of functions	complexity		v1.0.0
    - godot  # Check if comments end in a period	style, comment	✔	v1.25.0
    # - godox  # Tool for detection of FIXME, TODO and other comment keywords	style, comment		v1.19.0
Axel Prel's avatar
Axel Prel committed
    - gofmt  # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification	format	✔	v1.0.0
    - gofumpt  # Gofumpt checks whether code was gofumpt-ed.	format	✔	v1.28.0
Axel Prel's avatar
Axel Prel committed
    - goheader  # Checks is file header matches to pattern	style		v1.28.0
    - goimports  # In addition to fixing imports, goimports also formats your code in the same style as gofmt.	format, import	✔	v1.20.0
    # - gomoddirectives  # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.	style, module		v1.39.0
Axel Prel's avatar
Axel Prel committed
    - gomodguard  # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.	style, import, module		v1.25.0
    - goprintffuncname  # Checks that printf-like functions are named with f at the end	style		v1.23.0
    - gosec  # Inspects source code for security problems	bugs		v1.0.0
Axel Prel's avatar
Axel Prel committed
    # - gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase.	bugs		v1.53.0
    - grouper # Analyze expression groups.	style		v1.44.0
Axel Prel's avatar
Axel Prel committed
    - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. [auto-fix]
Axel Prel's avatar
Axel Prel committed
    - importas  # Enforces consistent import aliases	style		v1.38.0
Axel Prel's avatar
Axel Prel committed
    - inamedparam # Reports interfaces with unnamed method parameters.	style		v1.55.0
Axel Prel's avatar
Axel Prel committed
    - interfacebloat # checks the number of methods inside an interface.	style		v1.49.0
    - intrange # Intrange is a linter to find places where for loops could make use of an integer range.			v1.57.0
    # - ireturn  # Accept Interfaces, Return Concrete Types	style		v1.43.0
    - lll  # Reports long lines	style		v1.8.0
    - loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).	style, bugs
    # - maintidx  # maintidx measures the maintainability index of each function.	complexity		v1.44.0
    - makezero  # Finds slice declarations with non-zero initial length	style, bugs		v1.34.0
Axel Prel's avatar
Axel Prel committed
    - mirror # 	Reports wrong mirror patterns of bytes/strings usage.	style		v1.53.0
    - misspell  # Finds commonly misspelled English words in comments	style, comment	✔	v1.8.0
Axel Prel's avatar
Axel Prel committed
    # - mnd # An analyzer to detect magic numbers.	style		v1.22.0
    - musttag # ⚙️	Enforce field tags in (un)marshaled structs.	style, bugs		v1.51.0
Axel Prel's avatar
Axel Prel committed
    - nakedret  # Finds naked returns in functions greater than a specified function length	style		v1.19.0
    # - nestif  # Reports deeply nested if statements	complexity		v1.25.0
Axel Prel's avatar
Axel Prel committed
    - nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error.
    - nilerr  # Finds the code that returns nil even if it checks that the error is not nil.	bugs		v1.38.0
    - nilnil  # Checks that there is no simultaneous return of nil error and an invalid value.	style		v1.43.0
    - nlreturn  # nlreturn checks for a new line before return and branch statements to increase code clarity	style		v1.30.0
Axel Prel's avatar
Axel Prel committed
    - noctx  # noctx finds sending http request without context.Context	performance, bugs		v1.28.0
    - nolintlint  # Reports ill-formed or insufficient nolint directives	style		v1.26.0
Axel Prel's avatar
Axel Prel committed
    - nonamedreturns # Reports all named returns.	style		v1.46.0
Axel Prel's avatar
Axel Prel committed
    - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.	style		v1.46.0
    # - paralleltest  # paralleltest detects missing usage of t.Parallel() method in your Go test	style, test		v1.33.0
Axel Prel's avatar
Axel Prel committed
    - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.	performance		v1.55.0
    - prealloc  # Finds slice declarations that could potentially be preallocated	performance		v1.19.0
    - predeclared  # find code that shadows one of Go's predeclared identifiers	style		v1.35.0
Axel Prel's avatar
Axel Prel committed
    - promlinter  # Check Prometheus metrics naming via promlint	style		v1.40.0
Axel Prel's avatar
Axel Prel committed
    - protogetter # Reports direct reads from proto message fields when getters should be used.	bugs	✔	v1.55.0
    - reassign # ⚙️	Checks that package variables are not reassigned.	bugs		1.49.0
Axel Prel's avatar
Axel Prel committed
    # - recvcheck # Checks for receiver type consistency.
Axel Prel's avatar
Axel Prel committed
    - revive  # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.	style, metalinter		v1.37.0
    - rowserrcheck  # checks whether Err of rows is checked successfully	bugs, sql		v1.23.0
Axel Prel's avatar
Axel Prel committed
    - sloglint # Ensure consistent code style when using log/slog.	style, format		v1.55.0
    - spancheck # Checks for mistakes with OpenTelemetry/Census spans.	bugs		v1.56.0
    - sqlclosecheck  # Checks that sql.Rows and sql.Stmt are closed.	bugs, sql		v1.28.0
Axel Prel's avatar
Axel Prel committed
    - stylecheck  # Stylecheck is a replacement for golint	style		v1.20.0
    # - tagalign # ⚙️	Check that struct tags are well aligned.	style, format	✔	v1.53.0
    # - tagliatelle  # Checks the struct tags.	style		v1.40.0
Axel Prel's avatar
Axel Prel committed
    - testableexamples # 	Linter checks if examples are testable (have an expected output).	test		v1.50.0
    - testifylint # Checks usage of github.com/stretchr/testify.	test, bugs		v1.55.0
    - testpackage  # linter that makes you use a separate _test package	style, test		v1.25.0
    - thelper  # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers	style		v1.34.0
    - tparallel  # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes	style, test		v1.32.0
    - unconvert  # Remove unnecessary type conversions	style		v1.0.0
Axel Prel's avatar
Axel Prel committed
    - unparam  # Reports unused function parameters	unused		v1.9.0
Axel Prel's avatar
Axel Prel committed
    - usetesting # Reports uses of functions with replacement inside the testing package. [auto-fix]
Axel Prel's avatar
Axel Prel committed
    - usestdlibvars # ⚙️	A linter that detect the possibility to use variables/constants from the Go standard library.	style		v1.48.0
    # - varnamelen  # checks that the length of a variable's name matches its scope	style		v1.43.0
    - wastedassign  # wastedassign finds wasted assignment statements.	style		v1.38.0
    - whitespace  # Tool for detection of leading and trailing whitespace	style	✔	v1.19.0
    # - wrapcheck  # Checks that errors returned from external packages are wrapped	style, error		v1.32.0
    - wsl  # Whitespace Linter - Forces you to use empty lines!	style		v1.20.0
Axel Prel's avatar
Axel Prel committed
    - zerologlint # 	Detects the wrong usage of zerolog that a user forgets to dispatch with Send or Msg.	bugs		v1.53.0
linters-settings:
Axel Prel's avatar
Axel Prel committed
    sections:
      - standard
      - default
      - prefix(orus.io/orus-io/rednerd)
  golint:
    # minimal confidence for issues, default is 0.8
    min-confidence: 0.5
  varnamelen:
    ignore-names:
      - db
      - msg
    ignore-decls:
      - t testing.T
      - i int
Axel Prel's avatar
Axel Prel committed
  testifylint:
    enable-all: true
    disable:
      - require-error
Axel Prel's avatar
Axel Prel committed
  # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
  max-issues-per-linter: 0
  # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
  max-same-issues: 0
  exclude:
    - SA5008  # duplicate struct tag (staticcheck)
Axel Prel's avatar
Axel Prel committed
    - ST1016 # too many false + on method owner name consistency
    - "unused-parameter:"  # revive
    - "if-return:"  # revive
    - "empty-block:"  # revive
    - "var-naming: don't use an underscore in package name"
    - "ST1003: should not use underscores in package names"
Axel Prel's avatar
Axel Prel committed
  exclude-rules:
    - path: 'tests/.*'
      linters:
        - testpackage
        - testifylint
    - path: 'cmd/|auth/|restapi/'
      linters:
        - lll
Axel Prel's avatar
Axel Prel committed
  exclude-dirs:
    - dependencies
    - restapi/operations
  exclude-files:
    - bindata.go