diff --git a/time/.golangci.yml b/.golangci.yml similarity index 96% rename from time/.golangci.yml rename to .golangci.yml index 199bcf6..0e851be 100644 --- a/time/.golangci.yml +++ b/.golangci.yml @@ -61,6 +61,7 @@ linters: - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - prealloc # Finds slice declarations that could potentially be pre-allocated. + - protogetter # Reports direct reads from proto message fields when getters should be used. - reassign # Checks that package variables are not reassigned. - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - staticcheck # It's a set of rules from staticcheck. @@ -89,6 +90,23 @@ linters: - text: 'ctx is never used' linters: [ staticcheck ] + # Per-module exceptions. + + # `iface: unused` is not enabled for these modules. + - path: '^(closer|dispatcher|prommetrics)/' + linters: [ iface ] + text: '^unused: interface' + + # `iface: opaque` is not enabled for these modules. + - path: '^ctxkey/' + linters: [ iface ] + text: '^opaque: ' + + # `gocritic: hugeParam` is not enabled for these modules. + - path: '^prommetrics/' + linters: [ gocritic ] + text: '^hugeParam: opts is heavy' + paths: - \\.git$ - assets$ @@ -240,7 +258,7 @@ linters: ## PERFORMANCE - appendCombine # Detects append chains to the same slice that can be done in a single append call. - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. + - hugeParam # Detects params that incur excessive amount of copying. - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). @@ -253,7 +271,7 @@ linters: - zeroByteRepeat # Detects bytes.Repeat with 0 value. goheader: - template-path: ../.github/goheader.tmpl + template-path: ${config-path}/.github/goheader.tmpl gomoddirectives: replace-local: true @@ -290,6 +308,11 @@ linters: prealloc: range-loops: true + protogetter: + skip-files: + - '*/vendor/*' + skip-any-generated: true + reassign: patterns: - '.*' diff --git a/closer/.golangci.yml b/closer/.golangci.yml deleted file mode 100644 index 62d996f..0000000 --- a/closer/.golangci.yml +++ /dev/null @@ -1,345 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/closer/closer.go b/closer/closer.go index ab610fa..a2a6a75 100644 --- a/closer/closer.go +++ b/closer/closer.go @@ -186,11 +186,12 @@ func (c *closer) CloseAll() { //nolint:gocognit } errs := make([]error, 0, len(*funcs)) - for i := 0; i < cap(errs); i++ { + for i := 0; i < len(*funcs); i++ { if err := <-errCh; err != nil { errs = append(errs, err) } } + if len(errs) > 0 { c.err.Store(errors.Join(errs...)) } diff --git a/ctxkey/.golangci.yml b/ctxkey/.golangci.yml deleted file mode 100644 index 164c260..0000000 --- a/ctxkey/.golangci.yml +++ /dev/null @@ -1,345 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - unused - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/deferred/.golangci.yml b/deferred/.golangci.yml deleted file mode 100644 index 10dedd8..0000000 --- a/deferred/.golangci.yml +++ /dev/null @@ -1,346 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - unused - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/dispatcher/.golangci.yml b/dispatcher/.golangci.yml deleted file mode 100644 index 62d996f..0000000 --- a/dispatcher/.golangci.yml +++ /dev/null @@ -1,345 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/prommetrics/.golangci.yml b/prommetrics/.golangci.yml deleted file mode 100644 index 62d996f..0000000 --- a/prommetrics/.golangci.yml +++ /dev/null @@ -1,345 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/prommetrics/exemplar/.golangci.yml b/prommetrics/exemplar/.golangci.yml deleted file mode 100644 index d67ad60..0000000 --- a/prommetrics/exemplar/.golangci.yml +++ /dev/null @@ -1,345 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/protomap/.golangci.yml b/protomap/.golangci.yml deleted file mode 100644 index dd08290..0000000 --- a/protomap/.golangci.yml +++ /dev/null @@ -1,352 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - protogetter # Reports direct reads from proto message fields when getters should be used. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - unused - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - protogetter: - skip-files: - - '*/vendor/*' - skip-any-generated: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/slogger/.golangci.yml b/slogger/.golangci.yml deleted file mode 100644 index 01e620c..0000000 --- a/slogger/.golangci.yml +++ /dev/null @@ -1,353 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - sloglint # Ensure consistent code style when using log/slog. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - - hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - unused - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - - sloglint: - attr-only: true - context: "scope" - msg-style: "capitalized" - key-naming-case: "snake" - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/slogger/grpcslog/.golangci.yml b/slogger/grpcslog/.golangci.yml deleted file mode 100644 index 4955f26..0000000 --- a/slogger/grpcslog/.golangci.yml +++ /dev/null @@ -1,353 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - sloglint # Ensure consistent code style when using log/slog. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - - hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - unused - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - - sloglint: - attr-only: true - context: "scope" - msg-style: "capitalized" - key-naming-case: "snake" - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/strcase/.golangci.yml b/strcase/.golangci.yml deleted file mode 100644 index 3feaf3c..0000000 --- a/strcase/.golangci.yml +++ /dev/null @@ -1,346 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 15 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - unused - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 diff --git a/strcase/strcase.go b/strcase/strcase.go index 443963e..8ca6d67 100644 --- a/strcase/strcase.go +++ b/strcase/strcase.go @@ -116,7 +116,7 @@ func Detect(s string) Mode { // detectCore detects the case of a string without the leading and the trailing // separators. -func detectCore(s string) Mode { +func detectCore(s string) Mode { //nolint:gocognit if s == "" { return FlatCase // FlatCase used as a fallback value } @@ -223,7 +223,7 @@ func toCamel(s string, sep rune) string { // given separator, lowercasing the result. // // The abbreviations are handled: "ReadJSONData" becomes "read_json_data". -func fromCamel(s string, sep rune) string { +func fromCamel(s string, sep rune) string { //nolint:gocognit if s == "" { return "" } diff --git a/sync/.golangci.yml b/sync/.golangci.yml deleted file mode 100644 index 10dedd8..0000000 --- a/sync/.golangci.yml +++ /dev/null @@ -1,346 +0,0 @@ -version: "2" - -run: - timeout: 10m - -severity: - default: "critical" - -formatters: - enable: - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification. - - goimports # Check import statements are formatted according to the 'goimport' command. - - settings: - gofmt: - rewrite-rules: - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - -linters: - default: none - enable: - - asasalint # Check for pass []any as any in variadic func(…any). - - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - - bidichk # Checks for dangerous unicode character sequences. - - containedctx # Containedctx is a linter that detects struct contained context.Context field. - - contextcheck # Check whether the function uses a non-inherited context. - - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - - depguard # Go linter that checks if package imports are in a list of acceptable packages. - - dupword # Checks for duplicate words in the source code. - - durationcheck # Check for two durations multiplied together. - - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. - - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - - 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. - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # Detects nested contexts in loops and function literals. - - forcetypeassert # Find forced type assertions. - - funcorder # Checks the order of functions, methods, and constructors. - - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - - 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. - - goheader # Checks if file header matches to pattern. - - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - gosec # Inspects source code for security problems. - - govet # Vet examines Go source code and reports suspicious constructs. - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - inamedparam # Reports interfaces with unnamed method parameters. - - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - - makezero # Finds slice declarations with non-zero initial length. - - mirror # Reports wrong mirror patterns of bytes/strings usage. - - mnd # An analyzer to detect magic numbers. - - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - - nolintlint # Reports ill-formed or insufficient nolint directives. - - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # Finds slice declarations that could potentially be pre-allocated. - - reassign # Checks that package variables are not reassigned. - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. - - staticcheck # It's a set of rules from staticcheck. - - testifylint # Checks usage of github.com/stretchr/testify. - - testpackage # Linter that makes you use a separate _test package. - - thelper # Thelper detects tests helpers which do not start with the t.Helper() method. - - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - - unconvert # Remove unnecessary type conversions. - - unused # Checks Go code for unused constants, variables, functions and types. - - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - - usetesting # Reports uses of functions with replacement inside the testing package. - - wastedassign # Finds wasted assignment statements. - - whitespace # Checks for unnecessary newlines at the start and end of functions, if, for, etc. - - exclusions: - rules: - - text: 'Error return value of .((os\.)?std(out|err)\..*|.*print(f|ln)?). is not checked' - linters: [ errcheck ] - - path: (.+)_test\.go - linters: [ gocognit, goconst, mnd ] - - path: (.+)_test\.go - linters: [ govet ] - text: 'fieldalignment:' - - text: 'assigned to ctx' - linters: [ wastedassign ] - - text: 'ctx is never used' - linters: [ staticcheck ] - - paths: - - \\.git$ - - assets$ - - bench(mark)?s?$ - - bin$ - - build$ - - configs?$ - - deploy(ment)?s?$ - - docs$ - - githooks$ - - scripts$ - - generated: strict - - settings: - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: 'math/rand$' - desc: 'use math/rand/v2' - - pkg: 'github.com/pkg/errors' - desc: 'Should be replaced by standard lib errors package' - - dupword: - comments-only: true - - embeddedstructfieldcheck: - forbid-mutex: true - - errcheck: - exclude-functions: - - encoding/json.Marshal - - encoding/json.MarshalIndent - - gocognit: - min-complexity: 10 - - goconst: - min-len: 2 - min-occurrences: 2 - - gocritic: - disable-all: true - enabled-checks: - ## DIAGNOSTIC - - appendAssign # Detects suspicious append result assignments. - - argOrder # Detects suspicious arguments order. - - badCall # Detects suspicious function calls. - - badCond # Detects suspicious condition expressions. - - badLock # Detects suspicious mutex lock/unlock operations. - - badRegexp # Detects suspicious regexp patterns. - - badSorting # Detects bad usage of sort package. - - badSyncOnceFunc # Detects bad usage of sync.OnceFunc. - - builtinShadowDecl # Detects top-level declarations that shadow the predeclared identifiers. - - caseOrder # Detects erroneous case order inside switch statements. - - codegenComment # Detects malformed ‘code generated’ file comments. - - commentedOutCode # Detects commented-out code inside function bodies. - - deferInLoop # Detects loops inside functions that use defer. - - deprecatedComment # Detects malformed ‘deprecated’ doc-comments. - - dupArg # Detects suspicious duplicated arguments. - - dupBranchBody # Detects duplicated branch bodies inside conditional statements. - - dupCase # Detects duplicated case clauses inside switch or select statements. - - dupOption # Detects duplicated option function arguments in variadic function calls. - - dupSubExpr # Detects suspicious duplicated sub-expressions. - - dynamicFmtString # Detects suspicious formatting strings usage. - - emptyDecl # Detects suspicious empty declarations blocks. - - evalOrder # Detects unwanted dependencies on the evaluation order. - - exitAfterDefer # Detects calls to exit/fatal inside functions that use defer. - - externalErrorReassign # Detects suspicious reassignment of error from another package. - - filepathJoin # Detects problems in filepath.Join() function calls. - - flagDeref # Detects immediate dereferencing of flag package pointers. - - flagName # Detects suspicious flag names. - - mapKey # Detects suspicious map literal keys. - - nilValReturn # Detects return statements those results evaluate to nil. - - offBy1 # Detects various off-by-one kind of errors. - - rangeAppendAll # Detects append all its data while range it. - - regexpPattern # Detects suspicious regexp patterns. - - returnAfterHttpError # Detects suspicious http.Error call without following return. - - sloppyLen # Detects usage of len when result is obvious or doesn’t make sense. - - sloppyReassign # Detects suspicious/confusing re-assignments. - - sloppyTypeAssert # Detects redundant type assertions. - - sortSlice # Detects suspicious sort.Slice calls. - - sprintfQuotedString # Detects “%s” formatting directives that can be replaced with %q. - - sqlQuery # Detects issue in Query() and Exec() calls. - - syncMapLoadAndDelete # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - - truncateCmp # Detects potential truncation issues when comparing ints of different sizes. - - uncheckedInlineErr # Detects unchecked errors in if statements. - - unnecessaryDefer # Detects redundantly deferred calls. - - weakCond # Detects conditions that are unsafe due to not being exhaustive. - - ## STYLE - - assignOp # Detects assignments that can be simplified by using assignment operators. - - boolExprSimplify # Detects bool expressions that can be simplified. - - builtinShadow # Detects when predeclared identifiers are shadowed in assignments. - - captLocal # Detects capitalized names for local variables. - - commentFormatting # Detects comments with non-idiomatic formatting. - - commentedOutImport # Detects commented-out imports. - - defaultCaseOrder # Detects when default case in switch isn’t on 1st or last position. - - deferUnlambda # Detects deferred function literals that can be simplified. - - docStub # Detects comments that silence go lint complaints about doc-comment. - - dupImport # Detects multiple imports of the same package under different aliases. - - elseif # Detects else with nested if statement that can be replaced with else-if. - - emptyFallthrough # Detects fallthrough that can be avoided by using multi case values. - - emptyStringTest # Detects empty string checks that can be written more idiomatically. - - exposedSyncMutex # Detects exposed methods from sync.Mutex and sync.RWMutex. - - hexLiteral # Detects hex literals that have mixed case letter digits. - - httpNoBody # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - - ifElseChain # Detects repeated if-else statements and suggests to replace them with switch statement. - - importShadow # Detects when imported package names shadowed in the assignments. - - initClause # Detects non-assignment statements inside if/switch init clause. - - methodExprCall # Detects method expression call that can be replaced with a method call. - - nestingReduce # Finds where nesting level could be reduced. - - newDeref # Detects immediate dereferencing of new expressions. - - octalLiteral # Detects old-style octal literals. - - paramTypeCombine # Detects if function parameters could be combined by type and suggest the way to do it. - - preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - - ptrToRefParam # Detects input and output parameters that have a type of pointer to referential type. - - redundantSprint # Detects redundant fmt.Sprint calls. - - regexpMust # Detects regexp.Compile* that can be replaced with regexp.MustCompile*. - - regexpSimplify # Detects regexp patterns that can be simplified. - - singleCaseSwitch # Detects switch statements that could be better written as if statement. - - stringConcatSimplify # Detects string concat operations that can be simplified. - - stringsCompare # Detects strings.Compare usage. - - switchTrue # Detects switch-over-bool statements that use explicit true tag value. - - timeExprSimplify # Detects manual conversion to milli- or microseconds. - - todoCommentWithoutDetail # Detects TODO comments without detail/assignee. - # tooManyResultsChecker # Detects function with too many results. - - typeAssertChain # Detects repeated type assertions and suggests to replace them with type switch statement. - - typeDefFirst # Detects method declarations preceding the type definition itself. - - typeSwitchVar # Detects type switches that can benefit from type guard clause with variable. - - typeUnparen # Detects unneeded parenthesis inside type expressions and suggests to remove them. - - underef # Detects dereference expressions that can be omitted. - - unlabelStmt # Detects redundant statement labels. - - unlambda # Detects function literals that can be simplified. - # unnamedResult # Detects unnamed results that may benefit from names. - # unnecessaryBlock # Detects unnecessary braced statement blocks. - - unslice # Detects slice expressions that can be simplified to sliced expression itself. - - valSwap # Detects value swapping code that are not using parallel assignment. - # whyNoLint # Ensures that //nolint comments include an explanation. - - wrapperFunc # Detects function calls that can be replaced with convenience wrappers. - - yodaStyleExpr # Detects Yoda style expressions and suggests to replace them. - - ## PERFORMANCE - - appendCombine # Detects append chains to the same slice that can be done in a single append call. - - equalFold # Detects unoptimal strings/bytes case-insensitive comparison. - # hugeParam # Detects params that incur excessive amount of copying. - - indexAlloc # Detects strings.Index calls that may cause unwanted allocs. - - preferDecodeRune # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - - preferFprint # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - - preferStringWriter # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - - preferWriteByte # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - - rangeExprCopy # Detects expensive copies of for loop range expressions. - - rangeValCopy # Detects loops that copy big objects during each iteration. - - sliceClear # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - - stringXbytes # Detects redundant conversions between string and []byte. - - zeroByteRepeat # Detects bytes.Repeat with 0 value. - - goheader: - template-path: ../.github/goheader.tmpl - - gomoddirectives: - replace-local: true - - gosec: - excludes: - # _ instead of err checks - - G104 - - govet: - enable-all: true - - iface: - enable: - - identical - - opaque - - unused - - inamedparam: - skip-single-param: true - - iotamixing: - report-individual: true - - nakedret: - max-func-lines: 10 - - nilnil: - detect-opposite: true - - nolintlint: - require-specific: true - - prealloc: - range-loops: true - - reassign: - patterns: - - '.*' - - revive: - severity: error - rules: - - name: atomic # Check for commonly mistaken usages of the sync/atomic package. - - name: confusing-naming # Methods or fields of struct that have names different only by capitalization could be confusing. - - name: confusing-results # Function or methods that return multiple, no named, values of the same type could induce error. - - name: constant-logical-expr # The rule spots logical expressions that evaluate always to the same value. - - name: context-as-argument # By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention. - - name: context-keys-type # Basic types should not be used as a key in context.WithValue. - - name: deep-exit # 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(). - - name: defer # This rule warns on some common mistakes when using defer statement. - arguments: - - - 'call-chain' - - 'loop' - - 'method-call' - - 'recover' - - 'immediate-recover' - - 'return' - - name: duplicated-imports # It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times. - - name: early-return # In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. - - name: empty-block # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - - name: empty-lines # 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. - - name: error-return # By convention, for the sake of readability, the errors should be last in the list of returned values by a function. - - name: error-strings # By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. - - name: errorf # 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. - - name: forbidden-call-in-wg-go # Warns on forbidden calls inside calls to wg.Go. - - name: identical-branches # An if-then-else conditional with identical implementations in both branches is an error. - - name: identical-ifelseif-branches # An if ... else if chain with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one. - - name: identical-ifelseif-conditions # An if ... else if chain with identical conditions can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: identical-switch-branches # A switch with identical branches makes maintenance harder and might be a source of bugs. Duplicated branches should be consolidated in one case clause. - - name: identical-switch-conditions # A switch statement with cases with the same condition can lead to unreachable code and is a potential source of bugs while making the code harder to read and maintain. - - name: if-return # Checking if an error is nil to just after return the error or nil is redundant. - - name: increment-decrement # 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--. - - name: inefficient-map-lookup # This rule identifies code that iteratively searches for a key in a map. - - name: optimize-operands-order # 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. - - name: range # This rule suggests a shorter way of writing ranges that do not use the second value. - - name: redefines-builtin-id # 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. - - name: redundant-build-tag # This rule warns about redundant build tag comments // +build when //go:build is present. gofmt in Go 1.17+ automatically adds the //go:build constraint, making the // +build comment unnecessary. - - name: string-of-int # 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. - - name: unchecked-type-assertion # This rule checks whether a type assertion result is checked (the ok value), preventing unexpected panics. - arguments: - - accept-ignored-assertion-result: true - - name: use-any # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. - - name: use-errors-new # This rules identifies calls to fmt.Errorf that can be safely replaced by, the more efficient, errors.New. - - name: use-fmt-print # This rule proposes to replace calls to built-in print and println with their equivalents from fmt standard package. - - name: use-waitgroup-go # Since Go 1.25 the sync package proposes the WaitGroup.Go method. This method is a shorter and safer replacement for the idiom wg.Add ... go { ... wg.Done ... }. - - name: useless-break # This rule warns on useless break statements in case clauses of switch and select statements. - - name: useless-fallthrough # This rule warns on useless fallthrough statements in case clauses of switch statements. A fallthrough is considered useless if it's the single statement of a case clause block. - - name: unnecessary-if # Identifies `if-else` statements that can be replaced by simpler statements. - - name: unnecessary-stmt # This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code's readability. - - name: unreachable-code # This rule spots and proposes to remove unreachable code. - - name: waitgroup-by-value # 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. - -issues: - max-issues-per-linter: 0 - max-same-issues: 0