.golangci.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. # SPDX-License-Identifier: MIT
  3. linters-settings:
  4. govet:
  5. check-shadowing: true
  6. misspell:
  7. locale: US
  8. exhaustive:
  9. default-signifies-exhaustive: true
  10. gomodguard:
  11. blocked:
  12. modules:
  13. - github.com/pkg/errors:
  14. recommendations:
  15. - errors
  16. forbidigo:
  17. forbid:
  18. - ^fmt.Print(f|ln)?$
  19. - ^log.(Panic|Fatal|Print)(f|ln)?$
  20. - ^os.Exit$
  21. - ^panic$
  22. - ^print(ln)?$
  23. linters:
  24. enable:
  25. - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
  26. - bidichk # Checks for dangerous unicode character sequences
  27. - bodyclose # checks whether HTTP response body is closed successfully
  28. - contextcheck # check the function whether use a non-inherited context
  29. - decorder # check declaration order and count of types, constants, variables and functions
  30. - depguard # Go linter that checks if package imports are in a list of acceptable packages
  31. - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
  32. - dupl # Tool for code clone detection
  33. - durationcheck # check for two durations multiplied together
  34. - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
  35. - 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.
  36. - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
  37. - 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.
  38. - exhaustive # check exhaustiveness of enum switch statements
  39. - exportloopref # checks for pointers to enclosing loop variables
  40. - forbidigo # Forbids identifiers
  41. - forcetypeassert # finds forced type assertions
  42. - gci # Gci control golang package import order and make it always deterministic.
  43. - gochecknoglobals # Checks that no globals are present in Go code
  44. - gochecknoinits # Checks that no init functions are present in Go code
  45. - gocognit # Computes and checks the cognitive complexity of functions
  46. - goconst # Finds repeated strings that could be replaced by a constant
  47. - gocritic # The most opinionated Go source code linter
  48. - godox # Tool for detection of FIXME, TODO and other comment keywords
  49. - goerr113 # Golang linter to check the errors handling expressions
  50. - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
  51. - gofumpt # Gofumpt checks whether code was gofumpt-ed.
  52. - goheader # Checks is file header matches to pattern
  53. - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
  54. - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
  55. - 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.
  56. - goprintffuncname # Checks that printf-like functions are named with `f` at the end
  57. - gosec # Inspects source code for security problems
  58. - gosimple # Linter for Go source code that specializes in simplifying a code
  59. - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
  60. - grouper # An analyzer to analyze expression groups.
  61. - importas # Enforces consistent import aliases
  62. - ineffassign # Detects when assignments to existing variables are not used
  63. - misspell # Finds commonly misspelled English words in comments
  64. - nakedret # Finds naked returns in functions greater than a specified function length
  65. - nilerr # Finds the code that returns nil even if it checks that the error is not nil.
  66. - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
  67. - noctx # noctx finds sending http request without context.Context
  68. - predeclared # find code that shadows one of Go's predeclared identifiers
  69. - revive # golint replacement, finds style mistakes
  70. - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
  71. - stylecheck # Stylecheck is a replacement for golint
  72. - tagliatelle # Checks the struct tags.
  73. - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
  74. - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
  75. - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
  76. - unconvert # Remove unnecessary type conversions
  77. - unparam # Reports unused function parameters
  78. - unused # Checks Go code for unused constants, variables, functions and types
  79. - wastedassign # wastedassign finds wasted assignment statements
  80. - whitespace # Tool for detection of leading and trailing whitespace
  81. disable:
  82. - containedctx # containedctx is a linter that detects struct contained context.Context field
  83. - cyclop # checks function and package cyclomatic complexity
  84. - exhaustivestruct # Checks if all struct's fields are initialized
  85. - funlen # Tool for detection of long functions
  86. - gocyclo # Computes and checks the cyclomatic complexity of functions
  87. - godot # Check if comments end in a period
  88. - gomnd # An analyzer to detect magic numbers.
  89. - ifshort # Checks that your code uses short syntax for if-statements whenever possible
  90. - ireturn # Accept Interfaces, Return Concrete Types
  91. - lll # Reports long lines
  92. - maintidx # maintidx measures the maintainability index of each function.
  93. - makezero # Finds slice declarations with non-zero initial length
  94. - maligned # Tool to detect Go structs that would take less memory if their fields were sorted
  95. - nestif # Reports deeply nested if statements
  96. - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
  97. - nolintlint # Reports ill-formed or insufficient nolint directives
  98. - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
  99. - prealloc # Finds slice declarations that could potentially be preallocated
  100. - promlinter # Check Prometheus metrics naming via promlint
  101. - rowserrcheck # checks whether Err of rows is checked successfully
  102. - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
  103. - testpackage # linter that makes you use a separate _test package
  104. - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
  105. - varnamelen # checks that the length of a variable's name matches its scope
  106. - wrapcheck # Checks that errors returned from external packages are wrapped
  107. - wsl # Whitespace Linter - Forces you to use empty lines!
  108. issues:
  109. exclude-use-default: false
  110. exclude-rules:
  111. # Allow complex tests, better to be self contained
  112. - path: _test\.go
  113. linters:
  114. - gocognit
  115. - forbidigo
  116. # Allow complex main function in examples
  117. - path: examples
  118. text: "of func `main` is high"
  119. linters:
  120. - gocognit
  121. # Allow forbidden identifiers in examples
  122. - path: examples
  123. linters:
  124. - forbidigo
  125. # Allow forbidden identifiers in CLI commands
  126. - path: cmd
  127. linters:
  128. - forbidigo
  129. run:
  130. skip-dirs-use-default: false