From 0e95a863c22190145a9e33dc39a94e4eb87fa6d8 Mon Sep 17 00:00:00 2001 From: Liam Stanley Date: Sat, 15 Jun 2024 00:07:16 -0400 Subject: [PATCH] chore(terraform): auto-applied ".golangci.yml" this file was auto-applied from the "github-common-files" module located here: - https://github.com/lrstanley/.github/tree/master/terraform/github-common-files instructions on how to tell Terraform to exclude this file: - https://github.com/lrstanley/.github/blob/master/example.ci-config.yml Signed-off-by: Liam Stanley --- .golangci.yml | 81 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 32 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9def06b..e7280af 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,8 +10,7 @@ run: timeout: 3m issues: - max-per-linter: 0 - # max-same-issues: 0 + max-issues-per-linter: 0 max-same-issues: 50 exclude-rules: @@ -44,18 +43,21 @@ linters: - asciicheck # checks that your code does not contain non-ASCII identifiers - bidichk # checks for dangerous unicode character sequences - bodyclose # checks whether HTTP response body is closed successfully + - canonicalheader # checks whether net/http.Header uses canonical header + - copyloopvar # detects places where loop variables are copied - cyclop # checks function and package cyclomatic complexity - dupl # tool for code clone detection - durationcheck # checks for two durations multiplied together - errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 - - execinquery # checks query string in Query function which reads your Go src files and warning it finds - exportloopref # checks for pointers to enclosing loop variables + - fatcontext # detects nested contexts in loops - forbidigo # forbids identifiers - funlen # tool for detection of long functions - gci # controls golang package import order and makes it always deterministic - gocheckcompilerdirectives # validates go compiler directive comments (//go:) - gochecknoinits # checks that no init functions are present in Go code + - gochecksumtype # checks exhaustiveness on Go "sum types" - goconst # finds repeated strings that could be replaced by a constant - gocritic # provides diagnostics that check for bugs, performance and style issues - gocyclo # computes and checks the cyclomatic complexity of functions @@ -69,6 +71,7 @@ linters: - gosimple # specializes in simplifying a code - govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string - ineffassign # detects when assignments to existing variables are not used + - intrange # finds places where for loops could make use of an integer range - loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap) - makezero # finds slice declarations with non-zero initial length - misspell # finds commonly misspelled words @@ -78,16 +81,20 @@ linters: - nilnil # checks that there is no simultaneous return of nil error and an invalid value - noctx # finds sending http request without context.Context - 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 - predeclared # finds code that shadows one of Go's predeclared identifiers - promlinter # checks Prometheus metrics naming via promlint - reassign # checks that package variables are not reassigned - revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint - rowserrcheck # checks whether Err of rows is checked successfully + - sloglint # ensure consistent code style when using log/slog - sqlclosecheck # checks that sql.Rows and sql.Stmt are closed - staticcheck # is a go vet on steroids, applying a ton of static analysis checks - stylecheck # is a replacement for golint + - tagalign # aligns struct tags - tenv # detects using os.Setenv instead of t.Setenv since Go1.17 - testableexamples # checks if examples are testable (have an expected output) + - testifylint # checks usage of github.com/stretchr/testify - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes - typecheck # like the front-end of a Go compiler, parses and type-checks Go code - unconvert # removes unnecessary type conversions @@ -97,15 +104,6 @@ linters: - wastedassign # finds wasted assignment statements - whitespace # detects leading and trailing whitespace - # disabled for now: - # - gomnd # detects magic numbers - # - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - # - gochecknoglobals # checks that no global variables exist - # - gocognit # computes and checks the cognitive complexity of functions - # - nestif # reports deeply nested if statements - # - nonamedreturns # reports all named returns - # - testpackage # makes you use a separate _test package - linters-settings: cyclop: # The maximal code complexity to report. @@ -121,15 +119,11 @@ linters-settings: funlen: # Checks the number of lines in a function. - # If lower than 0, disable the check. lines: 150 # Checks the number of statements in a function. - # If lower than 0, disable the check. statements: 75 - - # gocognit: - # # Minimal code complexity to report. - # min-complexity: 25 + # Ignore comments. + ignore-comments: true gocritic: disabled-checks: @@ -150,20 +144,6 @@ linters-settings: # Whether to skip (*x).method() calls where x is a pointer receiver. skipRecvDeref: false - # gomnd: - # # Values always ignored: `time.Date`, - # # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, - # # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. - # ignored-functions: - # - os.Chmod - # - os.Mkdir - # - os.MkdirAll - # - os.OpenFile - # - os.WriteFile - # - prometheus.ExponentialBuckets - # - prometheus.ExponentialBucketsRange - # - prometheus.LinearBuckets - gomodguard: blocked: # List of blocked modules. @@ -205,6 +185,43 @@ linters-settings: - all - -ST1008 # handled by revive already. + sloglint: + # Enforce not using global loggers. + no-global: "all" + # Enforce using methods that accept a context. + context: "scope" + + tagalign: + align: true + sort: true + order: + # go-flags items + - command + - alias + - group + - namespace + - env-namespace + - subcommands-optional + - env + - env-delim + - short + - long + - no-flag + - hidden + - required + - value-name + - default + - choice + - description + - long-description + # everything else + - json + - yaml + - yml + - toml + - validate + strict: false + tenv: # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.