framework/.golangci.yml

804 lines
No EOL
39 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

run:
tests: true # include test files or not, default is true
go: '1.22'
linters:
enable:
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
- bodyclose # checks whether HTTP response body is closed successfully
- depguard # Go linter that checks if package imports are in a list of acceptable packages
- dupl # Tool for code clone detection
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- 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
- exhaustive # check exhaustiveness of enum switch statements and map literals
- exportloopref # checks for pointers to enclosing loop variables
- gochecknoinits # Checks that no init functions are present in Go code
- gocognit # Computes and checks the cognitive complexity of functions
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # Provides diagnostics that check for bugs, performance and style issues
- gocyclo # Computes and checks the cyclomatic complexity of functions
- godot # Check if comments end in a period
- gofmt # Gofmt checks whether code was gofmt-ed. By default, this tool runs with -s option to check for code simplification
- goheader # Checks is file header matches to pattern
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt
- 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
- gosec # Inspects source code for security problems
- gosimple # Linter for Go source code that specializes in simplifying code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # Detects when assignments to existing variables are not used
- misspell # Finds commonly misspelled English words in comments
- nakedret # Finds naked returns in functions greater than a specified function length
- nestif # Reports deeply nested if statements
- noctx # noctx finds sending http request without context.Context
- nolintlint # Reports ill-formed or insufficient nolint directives
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
- prealloc # Finds slice declarations that could potentially be pre-allocated
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed
- staticcheck # 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
- stylecheck # Stylecheck is a replacement for golint
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- unconvert # Remove unnecessary type conversions
- unparam # Reports unused function parameters
- unused # Checks Go code for unused constants, variables, functions and types
- whitespace # Tool for detection of leading and trailing whitespace
- asasalint # check for pass []any as any in variadic func(...any)
- bidichk # Checks for dangerous unicode character sequences
- containedctx # containedctx is a linter that detects struct contained context.Context field
- cyclop # checks function and package cyclomatic complexity
- decorder # check declaration order and count of types, constants, variables and functions
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
- dupword # checks for duplicate words in the source code
- durationcheck # check for two durations multiplied together
- 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.
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`
- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
- forbidigo # Forbids identifiers
- forcetypeassert # finds forced type assertions
- funlen # Tool for detection of long functions
- gomnd # An analyzer to detect magic numbers
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
- grouper # An analyzer to analyze expression groups
- importas # Enforces consistent import aliases
- interfacebloat # A linter that checks the number of methods inside an interface
- lll # Reports long lines
- loggercheck # Checks key valur pairs for common logger libraries (kitlog,klog,logr,zap)
- maintidx # maintidx measures the maintainability index of each function
- makezero # Finds slice declarations with non-zero initial length
- nilerr # Finds the code that returns nil even if it checks that the error is not nil
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL
- predeclared # find code that shadows one of Go's predeclared identifiers
- promlinter # Check Prometheus metrics naming via promlint
- reassign # Checks that package variables are not reassigned
- tagliatelle # Checks the struct tags
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- testableexamples # linter checks if examples are testable (have an expected output)
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library
- varnamelen # checks that the length of a variable's name matches its scope
- wastedassign # wastedassign finds wasted assignment statements
- wsl # Whitespace Linter - Forces you to use empty lines
disable:
# [disabled]
# Use goimports instead.
- gci # Gci controls golang package import order and makes it always deterministic
# This is just a most stupid linter rule ever.
- testpackage # linter that makes you use a separate _test package
# Sometimes you really need globals.
- gochecknoglobals # check that no global variables exist
# This is stupid.
- exhaustruct # Checks if all structure fields are initialized.
# Sometimes you just have to return unwrapped error.
- wrapcheck # Checks that errors returned from external packages are wrapped.
# Not always and not everywhere.
- ireturn # Accept Interfaces, Return Concrete Types.
# They are useful to handle errors in deferred functions.
- nonamedreturns # Reports all named returns.
# Disabled because of lack of configuration. It makes a lot of unnecessary noise.
- goerr113 # Golang linter to check the errors handling expressions.
# Disabled because of the bug of reporting already sorted imports order.
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
# [deprecated]
- structcheck # Finds unused struct fields
- varcheck # Finds unused global variables and constants
- deadcode # Finds unused code
- exhaustivestruct # Checks if all struct's fields are initialized
- godox # Tool for detection of FIXME, TODO and other comment keywords
- golint # Golint differs from gofmt. Gofmt reformat Go source code, whereas golint prints out style mistakes
- ifshort # Checks that your code uses short syntax for if-statements whenever possible
- interfacer # Linter that suggests narrower interface types
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted
- nosnakecase # nosnakecase is a linter that detects snake case of variable naming and function name
- scopelint # Scopelint checks for unpinned variables in go programs
linters-settings:
depguard:
rules:
prevent_unmaintained_packages:
list-mode: lax # allow unless explicitely denied
files:
- $all
- "!$test"
allow:
- $gostd
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
paralleltest:
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.
# Default: false
ignore-missing: true
revive:
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
# Defaults to unlimited.
# When set to false, ignores files with "GENERATED" header, similar to golint.
# See https://github.com/mgechev/revive#available-rules for details.
# Default: false
ignore-generated-header: true
# Sets the default severity.
# See https://github.com/mgechev/revive#configuration
# Default: warning
severity: warning
# Enable all available rules.
# Default: false
enable-all-rules: true
# Sets the default failure confidence.
# This means that linting errors with less than 0.8 confidence will be ignored.
# Default: 0.8
confidence: 0.1
rules:
# Suggests using constant for magic numbers and string literals.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant
# TODO: try rule later. Looks like it is broken in 1.50.0. Use gomnd instead
- name: add-constant
severity: warning
disabled: true
arguments:
- maxLitCount: '5'
allowStrs: '""'
allowInts: '0,1,2,3,4,5,6,7,8,9,10,24,30,31'
allowFloats: '0.0,0.,1.0,1.,2.0,2.'
# Warns when a function receives more parameters than the maximum set by the rule's configuration.
# Enforcing a maximum number of parameters helps to keep the code readable and maintainable.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit
- name: argument-limit
severity: warning
disabled: false
arguments: [ 4 ]
# Check for commonly mistaken usages of the sync/atomic package
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic
- name: atomic
severity: warning
disabled: false
# Warns on bare (a.k.a. naked) returns
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters
- name: banned-characters
severity: warning
disabled: false
arguments: [ "Ω", "Σ", "σ", "7" ]
# Checks given banned characters in identifiers(func, var, const). Comments are not checked.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return
- name: bare-return
severity: warning
disabled: false
# Blank import should be only in a main or test package, or have a comment justifying it.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
- name: blank-imports
severity: warning
disabled: false
# Using Boolean literals (true, false) in logic expressions may make the code less readable.
# This rule suggests removing Boolean literals from logic expressions.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
severity: warning
disabled: false
# Explicitly invoking the garbage collector is, except for specific uses in benchmarking, very dubious.
# The garbage collector can be configured through environment variables as described here: https://pkg.go.dev/runtime
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc
- name: call-to-gc
severity: warning
disabled: false
# Description: Cognitive complexity is a measure of how hard code is to understand.
# While cyclomatic complexity is good to measure "testability" of the code, cognitive complexity
# aims to provide a more precise measure of the difficulty of understanding the code.
# Enforcing a maximum complexity per function helps to keep code readable and maintainable.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity
- name: cognitive-complexity
severity: warning
disabled: false
arguments: [ 30 ]
# Methods or fields of struct that have names different only by capitalization could be confusing.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming
- name: confusing-naming
severity: warning
disabled: false
# Function or methods that return multiple, no named, values of the same type could induce error.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-results
- name: confusing-results
severity: warning
disabled: false
# The rule spots logical expressions that evaluate always to the same value.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
- name: constant-logical-expr
severity: warning
disabled: false
# By convention, context.Context should be the first parameter of a function.
# https://github.com/golang/go/wiki/CodeReviewComments#contexts
# This rule spots function declarations that do not follow the convention.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
- name: context-as-argument
severity: warning
disabled: false
arguments: [ { allowTypesBefore = "*testing.T" } ]
# Basic types should not be used as a key in context.WithValue.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
- name: context-keys-type
severity: warning
disabled: false
# Cyclomatic complexity is a measure of code complexity.
# Enforcing a maximum complexity per function helps to keep code readable and maintainable.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic
- name: cyclomatic
severity: warning
disabled: false
arguments: [ 15 ]
# This rule spots potential dataraces caused by go-routines capturing (by-reference) particular
# identifiers of the function from which go-routines are created.
# The rule is able to spot two of such cases: go-routines capturing named return values,
# and capturing for-range values.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#datarace
- name: datarace
severity: warning
disabled: false
# Packages exposing functions that can stop program execution by exiting are hard to reuse.
# This rule looks for program exits in functions other than main() or init().
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
- name: deep-exit
severity: warning
disabled: false
# This rule warns on some common mistakes when using defer statement.
# It currently alerts on the following situations:
# - [ call-chain ] - even if deferring call-chains of the form foo()() is valid,
# it does not help code understanding (only the last call is deferred)
# - [ loop ] - deferring inside loops can be misleading (deferred functions are not executed at the end
# of the loop iteration but of the current function) and it could lead to exhausting the execution stack
# - [ method-call ] - deferring a call to a method can lead to subtle bugs if the method does not have a pointer receiver
# - [ recover ] - calling recover outside a deferred function has no effect
# - [ immediate-recover ] - calling recover at the time a defer is registered, rather than as part of the deferred callback.
# e.g. defer recover() or equivalent.
# - [ return ] - returning values form a deferred function has no effect.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
- name: defer
severity: warning
disabled: false
arguments:
- [ "call-chain", "loop", "method-call", "recover", "immediate-recover", "return" ]
# Importing with . makes the programs much harder to understand because it is unclear
# whether names belong to the current package or to an imported package.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
- name: dot-imports
severity: warning
disabled: false
# It is possible to unintentionally import the same package twice.
# This rule looks for packages that are imported two or more times.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
- name: duplicated-imports
severity: warning
disabled: false
# In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
severity: warning
disabled: false
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
- name: empty-block
severity: warning
disabled: false
# Sometimes gofmt is not enough to enforce a common formatting of a code-base.
# This rule warns when there are heading or trailing newlines in code blocks.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
severity: warning
disabled: false
# By convention, for the sake of readability, variables of type error must be named with the prefix err.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
- name: error-naming
severity: warning
disabled: false
# By convention, for the sake of readability, the errors should be last in the list of returned values by a function.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
- name: error-return
severity: warning
disabled: false
# By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
- name: error-strings
severity: warning
disabled: false
# It is possible to get a simpler program by replacing errors.New(fmt.Sprintf()) with fmt.Errorf().
# This rule spots that kind of simplification opportunities.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
- name: errorf
severity: warning
disabled: false
# Exported function and methods should have comments.
# This warns on undocumented exported functions and methods.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
- name: exported
severity: warning
disabled: false
arguments: [ ]
# This rule helps to enforce a common header for all source files in a project by spotting those files
# that do not have the specified header.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header
- name: file-header
severity: warning
disabled: true
arguments: [ "" ]
# If a function controls the flow of another by passing it information on what to do, both functions are said to be control-coupled.
# Coupling among functions must be minimized for better maintainability of the code.
# This rule warns on boolean parameters that create a control coupling.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
- name: flag-parameter
severity: warning
disabled: false
# Functions returning too many results can be hard to understand/use.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit
- name: function-result-limit
severity: warning
disabled: false
arguments: [ 2 ]
# Functions too long (with many statements and/or lines) can be hard to understand.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length
- name: function-length
severity: warning
disabled: false
# (int,int) the maximum allowed statements and lines.
# Must be non-negative integers. Set to 0 to disable the check
arguments: [ 30, 0 ]
# Typically, functions with names prefixed with Get are supposed to return a value.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return
- name: get-return
severity: warning
disabled: false
# An if-then-else conditional with identical implementations in both branches is an error.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
- name: identical-branches
severity: warning
disabled: false
# Checking if an error is nil to just after return the error or nil is redundant.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
- name: if-return
severity: warning
disabled: false
# By convention, for better readability, incrementing an integer variable by 1 is recommended
# to be done using the ++ operator.
# This rule spots expressions like i += 1 and i -= 1 and proposes to change them into i++ and i--.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
- name: increment-decrement
severity: warning
disabled: false
# To improve the readability of code, it is recommended to reduce the indentation as much as possible.
# This rule highlights redundant else-blocks that can be eliminated from the code.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
- name: indent-error-flow
severity: warning
disabled: false
# Warns when importing black-listed packages.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blacklist
- name: imports-blocklist
severity: warning
disabled: false
arguments:
- "crypto/md5"
- "crypto/sha1"
# In GO it is possible to declare identifiers (packages, structs, interfaces, parameters,
# receivers, variables, constants...) that conflict with the name of an imported package.
# This rule spots identifiers that shadow an import.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
- name: import-shadowing
severity: warning
disabled: false
# Warns in the presence of code lines longer than a configured maximum.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit
- name: line-length-limit
severity: warning
disabled: false
arguments: [ 150 ]
# Packages declaring too many public structs can be hard to understand/use,
# and could be a symptom of bad design.
# This rule warns on files declaring more than a configured, maximum number of public structs.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs
- name: max-public-structs
severity: warning
disabled: true
arguments: [ 3 ]
# A function that modifies its parameters can be hard to understand.
# It can also be misleading if the arguments are passed by value by the caller.
# This rule warns when a function modifies one or more of its parameters.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-parameter
- name: modifies-parameter
severity: warning
disabled: false
# A method that modifies its receiver value can have undesired behavior.
# The modification can be also the root of a bug because the actual value receiver could be a copy of that used at the calling site.
# This rule warns when a method modifies its receiver.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-value-receiver
- name: modifies-value-receiver
severity: warning
disabled: false
# Packages declaring structs that contain other inline struct definitions can be hard to understand/read for other developers.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#nested-structs
- name: nested-structs
severity: warning
disabled: false
# conditional expressions can be written to take advantage of short circuit evaluation and speed up
# its average evaluation time by forcing the evaluation of less time-consuming terms before more costly ones.
# This rule spots logical expressions where the order of evaluation of terms seems non-optimal.
# Please notice that confidence of this rule is low and is up to the user to decide if the suggested
# rewrite of the expression keeps the semantics of the original one.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#optimize-operands-order
- name: optimize-operands-order
severity: warning
disabled: false
# Packages should have comments. This rule warns on undocumented packages and when packages comments are detached to the package keyword.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
- name: package-comments
severity: warning
disabled: false
# This rule suggests a shorter way of writing ranges that do not use the second value.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
- name: range
severity: warning
disabled: false
# Range variables in a loop are reused at each iteration; therefore a goroutine created
# in a loop will point to the range variable with from the upper scope.
# This way, the goroutine could use the variable with an undesired value.
# This rule warns when a range value (or index) is used inside a closure.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
- name: range-val-in-closure
severity: warning
disabled: false
# Range variables in a loop are reused at each iteration. This rule warns when assigning the address of the variable,
# passing the address to append() or using it in a map.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
- name: range-val-address
severity: warning
disabled: false
# By convention, receiver names in a method should reflect their identity.
# For example, if the receiver is of type Parts, p is an adequate name for it.
# Contrary to other languages, it is not idiomatic to name receivers as this or self.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming
- name: receiver-naming
severity: warning
disabled: false
# Constant names like false, true, nil, function names like append, make, and basic type names like bool,
# and byte are not reserved words of the language; therefore the can be redefined.
# Even if possible, redefining these built in names can lead to bugs very difficult to detect.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
- name: redefines-builtin-id
severity: warning
disabled: false
# explicit type conversion string(i) where i has an integer type other than
# rune might behave not as expected by the developer (e.g. string(42) is not "42").
# This rule spot that kind of suspicious conversions.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int
- name: string-of-int
severity: warning
disabled: false
# This rule allows you to configure a list of regular expressions that string literals
# in certain function calls are checked against. This is geared towards user facing applications
# where string literals are often used for messages that will be presented to users,
# so it may be desirable to enforce consistent formatting.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
- name: string-format
severity: warning
disabled: true
arguments: [ ]
# Struct tags are not checked at compile time.
# This rule, checks and warns if it finds errors in common struct tags types like:
# asn1, default, json, protobuf, xml, yaml.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
severity: warning
disabled: false
# To improve the readability of code, it is recommended to reduce the indentation as much as possible.
# This rule highlights redundant else-blocks that can be eliminated from the code.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
- name: superfluous-else
severity: warning
disabled: false
# This rule warns when using == and != for equality check time.Time and suggest to time.time.Equal method,
# for about information follow this link: https://pkg.go.dev/time#Time
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
- name: time-equal
severity: warning
disabled: false
# Using unit-specific suffix like "Secs", "Mins", ... when naming variables of type time.Duration
# can be misleading, this rule highlights those cases.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-naming
- name: time-naming
severity: warning
disabled: false
# This rule warns when initialism, variable or package naming conventions are not followed.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
- name: var-naming
severity: warning
disabled: false
arguments:
- [ ] # AllowList
- [ "ID", "VM" ] # DenyList
# This rule proposes simplifications of variable declarations.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
- name: var-declaration
severity: warning
disabled: false
# Unconditional recursive calls will produce infinite recursion, thus program stack overflow.
# This rule detects and warns about unconditional (direct) recursive calls.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
- name: unconditional-recursion
severity: warning
disabled: false
# This rule warns on wrongly named un-exported symbols, i.e. un-exported symbols whose name
# start with a capital letter.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
- name: unexported-naming
severity: warning
disabled: false
# This rule warns when an exported function or method returns a value of an un-exported type.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
- name: unexported-return
severity: warning
disabled: false
# This rule warns when errors returned by a function are not explicitly handled on the caller side.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
- name: unhandled-error
severity: warning
disabled: false
arguments:
- "fmt.Println"
- "fmt.Printf"
# This rule suggests to remove redundant statements like a break at the end of a case block,
# for improving the code's readability.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
- name: unnecessary-stmt
severity: warning
disabled: false
# This rule spots and proposes to remove unreachable code.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code
- name: unreachable-code
severity: warning
disabled: false
# This rule warns on unused parameters. Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: false
# This rule warns on unused method receivers.
# Methods with unused receivers can be a symptom of an unfinished refactoring or a bug.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
severity: warning
disabled: false
# This rule warns on useless break statements in case clauses of switch and select statements.
# GO, unlike other programming languages like C, only executes statements of the selected case
# while ignoring the subsequent case clauses.
# Therefore, inserting a break at the end of a case clause has no effect.
# Because break statements are rarely used in case clauses, when switch or select statements
# are inside a for-loop, the programmer might wrongly assume that a break in a case clause will
# take the control out of the loop. The rule emits a specific warning for such cases.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
severity: warning
disabled: false
# Function parameters that are passed by value, are in fact a copy of the original argument.
# Passing a copy of a sync.WaitGroup is usually not what the developer wants to do.
# This rule warns when a sync.WaitGroup expected as a by-value parameter in a function or method.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
- name: waitgroup-by-value
severity: warning
disabled: false
forbidigo:
# Forbid the following identifiers (list of regexp).
# Default: ["^(fmt\\.Print(|f|ln)|print|println)$"]
forbid:
# Optionally put comments at the end of the regex, surrounded by `(# )?`
# Escape any special characters.
- '^print.*$(# print statements should not be committed)'
# Exclude godoc examples from forbidigo checks.
# Default: true
exclude-godoc-examples: true
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 15
# The maximal average package complexity.
# If it's higher than 0.0 (float) the check is enabled
# Default: 0.0
package-average: 6
# Should ignore tests.
# Default: false
skip-tests: true
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: 200
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
statements: 50
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: false
# `camel` is used for `json` and `yaml` (can be overridden)
# Default: {}
rules:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
json: snake
yaml: camel
xml: camel
bson: camel
avro: snake
mapstructure: kebab
varnamelen:
# The longest distance, in source lines, that is being considered a "small scope".
# Variables used in at most this many lines will be ignored.
# Default: 5
max-distance: 10
# The minimum length of a variable's name that is considered "long".
# Variable names that are at least this long will be ignored.
# Default: 3
min-name-length: 1
# Check method receivers.
# Default: false
check-receiver: true
# Check named return values.
# Default: false
check-return: true
# Check type parameters.
# Default: false
check-type-param: true
# Ignore "ok" variables that hold the bool return value of a type assertion.
# Default: false
ignore-type-assert-ok: true
# Ignore "ok" variables that hold the bool return value of a map index.
# Default: false
ignore-map-index-ok: true
# Ignore "ok" variables that hold the bool return value of a channel receive.
# Default: false
ignore-chan-recv-ok: true
# Optional list of variable names that should be ignored completely.
# Default: []
ignore-names:
- err
# Optional list of variable declarations that should be ignored completely.
# Entries must be in one of the following forms (see below for examples):
# - for variables, parameters, named return values, method receivers, or type parameters:
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
# - for constants: const <name>
#
# Default: []
ignore-decls:
- t testing.T
- e error
- i int
- T any
lll:
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
# Default: 120.
line-length: 150
# Tab width in spaces.
# Default: 1
tab-width: 1
nlreturn:
# Size of the block (including return statement that is still "OK")
# so no return split required.
# Default: 1
block-size: 3
wsl:
# See https://github.com/bombsimon/wsl/blob/master/doc/configuration.md for
# documentation of available settings. These are the defaults for golangci-lint.
allow-assign-and-anything: false
allow-assign-and-call: true
allow-cuddle-declarations: false
allow-multiline-assign: true
allow-separated-leading-comment: false
allow-trailing-comment: false
force-case-trailing-whitespace: 0
force-err-cuddling: false
force-short-decl-cuddling: false
strict-append: true