| 1 | # SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly> |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | |
| 4 | version: "2" |
| 5 | linters: |
| 6 | enable: |
| 7 | - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers |
| 8 | - bidichk # Checks for dangerous unicode character sequences |
| 9 | - bodyclose # checks whether HTTP response body is closed successfully |
| 10 | - containedctx # containedctx is a linter that detects struct contained context.Context field |
| 11 | - contextcheck # check the function whether use a non-inherited context |
| 12 | - cyclop # checks function and package cyclomatic complexity |
| 13 | - decorder # check declaration order and count of types, constants, variables and functions |
| 14 | - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) |
| 15 | - dupl # Tool for code clone detection |
| 16 | - durationcheck # check for two durations multiplied together |
| 17 | - err113 # Golang linter to check the errors handling expressions |
| 18 | - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases |
| 19 | - 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. |
| 20 | - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. |
| 21 | - 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. |
| 22 | - exhaustive # check exhaustiveness of enum switch statements |
| 23 | - forbidigo # Forbids identifiers |
| 24 | - forcetypeassert # finds forced type assertions |
| 25 | - gochecknoglobals # Checks that no globals are present in Go code |
| 26 | - gocognit # Computes and checks the cognitive complexity of functions |
| 27 | - goconst # Finds repeated strings that could be replaced by a constant |
| 28 | - gocritic # The most opinionated Go source code linter |
| 29 | - gocyclo # Computes and checks the cyclomatic complexity of functions |
| 30 | - godot # Check if comments end in a period |
| 31 | - godox # Tool for detection of FIXME, TODO and other comment keywords |
| 32 | - goheader # Checks is file header matches to pattern |
| 33 | - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. |
| 34 | - goprintffuncname # Checks that printf-like functions are named with `f` at the end |
| 35 | - gosec # Inspects source code for security problems |
| 36 | - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string |
| 37 | - grouper # An analyzer to analyze expression groups. |
| 38 | - importas # Enforces consistent import aliases |
| 39 | - ineffassign # Detects when assignments to existing variables are not used |
| 40 | - lll # Reports long lines |
| 41 | - maintidx # maintidx measures the maintainability index of each function. |
| 42 | - makezero # Finds slice declarations with non-zero initial length |
| 43 | - misspell # Finds commonly misspelled English words in comments |
| 44 | - modernize # Replace and suggests simplifications to code |
| 45 | - nakedret # Finds naked returns in functions greater than a specified function length |
| 46 | - nestif # Reports deeply nested if statements |
| 47 | - nilerr # Finds the code that returns nil even if it checks that the error is not nil. |
| 48 | - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. |
| 49 | - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity |
| 50 | - noctx # noctx finds sending http request without context.Context |
| 51 | - predeclared # find code that shadows one of Go's predeclared identifiers |
| 52 | - revive # golint replacement, finds style mistakes |
| 53 | - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks |
| 54 | - tagliatelle # Checks the struct tags. |
| 55 | - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers |
| 56 | - unconvert # Remove unnecessary type conversions |
| 57 | - unparam # Reports unused function parameters |
| 58 | - unused # Checks Go code for unused constants, variables, functions and types |
| 59 | - varnamelen # checks that the length of a variable's name matches its scope |
| 60 | - wastedassign # wastedassign finds wasted assignment statements |
| 61 | - whitespace # Tool for detection of leading and trailing whitespace |
| 62 | disable: |
| 63 | - depguard # Go linter that checks if package imports are in a list of acceptable packages |
| 64 | - funlen # Tool for detection of long functions |
| 65 | - gochecknoinits # Checks that no init functions are present in Go code |
| 66 | - 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. |
| 67 | - interfacebloat # A linter that checks length of interface. |
| 68 | - ireturn # Accept Interfaces, Return Concrete Types |
| 69 | - mnd # An analyzer to detect magic numbers |
| 70 | - nolintlint # Reports ill-formed or insufficient nolint directives |
| 71 | - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test |
| 72 | - prealloc # Finds slice declarations that could potentially be preallocated |
| 73 | - promlinter # Check Prometheus metrics naming via promlint |
| 74 | - rowserrcheck # checks whether Err of rows is checked successfully |
| 75 | - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. |
| 76 | - testpackage # linter that makes you use a separate _test package |
| 77 | - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes |
| 78 | - wrapcheck # Checks that errors returned from external packages are wrapped |
| 79 | - wsl # Whitespace Linter - Forces you to use empty lines! |
| 80 | settings: |
| 81 | staticcheck: |
| 82 | checks: |
| 83 | - all |
| 84 | - -QF1008 # "could remove embedded field", to keep it explicit! |
| 85 | - -QF1003 # "could use tagged switch on enum", Cases conflicts with exhaustive! |
| 86 | exhaustive: |
| 87 | default-signifies-exhaustive: true |
| 88 | forbidigo: |
| 89 | forbid: |
| 90 | - pattern: ^fmt.Print(f|ln)?$ |
| 91 | - pattern: ^log.(Panic|Fatal|Print)(f|ln)?$ |
| 92 | - pattern: ^os.Exit$ |
| 93 | - pattern: ^panic$ |
| 94 | - pattern: ^print(ln)?$ |
| 95 | - pattern: ^testing.T.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$ |
| 96 | pkg: ^testing$ |
| 97 | msg: use testify/assert instead |
| 98 | analyze-types: true |
| 99 | gomodguard: |
| 100 | blocked: |
| 101 | modules: |
| 102 | - github.com/pkg/errors: |
| 103 | recommendations: |
| 104 | - errors |
| 105 | govet: |
| 106 | enable: |
| 107 | - shadow |
| 108 | revive: |
| 109 | rules: |
| 110 | # Prefer 'any' type alias over 'interface{}' for Go 1.18+ compatibility |
| 111 | - name: use-any |
| 112 | severity: warning |
| 113 | disabled: false |
| 114 | misspell: |
| 115 | locale: US |
| 116 | varnamelen: |
| 117 | max-distance: 12 |
| 118 | min-name-length: 2 |
| 119 | ignore-type-assert-ok: true |
| 120 | ignore-map-index-ok: true |
| 121 | ignore-chan-recv-ok: true |
| 122 | ignore-decls: |
| 123 | - i int |
| 124 | - n int |
| 125 | - w io.Writer |
| 126 | - r io.Reader |
| 127 | - b []byte |
| 128 | exclusions: |
| 129 | generated: lax |
| 130 | rules: |
| 131 | - linters: |
| 132 | - forbidigo |
| 133 | - gocognit |
| 134 | path: (examples|main\.go) |
| 135 | - linters: |
| 136 | - gocognit |
| 137 | path: _test\.go |
| 138 | - linters: |
| 139 | - forbidigo |
| 140 | path: cmd |
| 141 | formatters: |
| 142 | enable: |
| 143 | - gci # Gci control golang package import order and make it always deterministic. |
| 144 | - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification |
| 145 | - gofumpt # Gofumpt checks whether code was gofumpt-ed. |
| 146 | - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports |
| 147 | exclusions: |
| 148 | generated: lax |
| 149 | issues: |
| 150 | max-issues-per-linter: 0 |
| 151 | max-same-issues: 0 |