From 8efc74c239a05eb95ef4d1dcecbabb2c53fd7066 Mon Sep 17 00:00:00 2001 From: oleiade Date: Mon, 11 Dec 2023 09:16:15 +0100 Subject: [PATCH] Update linting rules --- .golangci.yml | 128 +++++++++++++++++++++++++++++++++----------------- characters.go | 2 +- 2 files changed, 87 insertions(+), 43 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index bab3ef7..ccdfd4b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,3 @@ -# v1.47.2 -# Please don't remove the first line. It uses in CI to determine the golangci version run: deadline: 5m @@ -10,13 +8,13 @@ issues: max-same-issues: 0 # We want to try and improve the comments in the k6 codebase, so individual - # non-golint items from the default exclusion list will gradually be addded + # non-golint items from the default exclusion list will gradually be added # to the exclude-rules below exclude-use-default: false exclude-rules: - # Exclude duplicate code and function length and complexity checking in test - # files (due to common repeats and long functions in test code) + # Exclude duplicate code and function length and complexity checking in test + # files (due to common repeats and long functions in test code) - path: _(test|gen)\.go linters: - cyclop @@ -25,13 +23,10 @@ issues: - funlen - lll - linters: - - paralleltest # false positive: https://github.com/kunwardeep/paralleltest/issues/8. - text: "does not use range value in test Run" + - staticcheck # Tracked in https://github.com/grafana/xk6-grpc/issues/14 + text: "The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated." linters-settings: - nolintlint: - # Disable to ensure that nolint directives don't have a leading space. Default is true. - allow-leading-space: false exhaustive: default-signifies-exhaustive: true govet: @@ -48,37 +43,86 @@ linters-settings: funlen: lines: 80 statements: 60 + forbidigo: + forbid: + - '^(fmt\\.Print(|f|ln)|print|println)$' + # Forbid everything in syscall except the uppercase constants + - '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?' + - '^logrus\.Logger$' + revive: + rules: + - name: package-comments + severity: warning + disabled: true + stylecheck: + checks: + - "all" + - '-ST1000' # Use of underscores in Go names linters: - enable-all: true - disable: - - nlreturn - - gci - - gochecknoinits - - godot - - godox - - gomodguard - - testpackage - - wsl - - gomnd - - goerr113 # most of the errors here are meant for humans - - goheader - - exhaustivestruct - - thelper - - gocyclo # replaced by cyclop since it also calculates the package complexity - - maligned # replaced by govet 'fieldalignment' - - interfacer # deprecated - - scopelint # deprecated, replaced by exportloopref - - wrapcheck # a little bit too much for k6, maybe after https://github.com/tomarrell/wrapcheck/issues/2 is fixed - - golint # this linter is deprecated - - varnamelen - - ireturn - - tagliatelle - - exhaustruct - - execinquery - - maintidx - - grouper - - decorder - - nonamedreturns - - nosnakecase - fast: false + disable-all: true + enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - contextcheck + - cyclop + - dogsled + - dupl + - durationcheck + - errcheck + - errchkjson + - errname + - errorlint + - exhaustive + - exportloopref + - forbidigo + - forcetypeassert + - funlen + - gocheckcompilerdirectives + - gochecknoglobals + - gocognit + - goconst + - gocritic + - gofmt + - gofumpt + - goimports + - gomoddirectives + - goprintffuncname + - gosec + - gosimple + - govet + - importas + - ineffassign + - interfacebloat + - lll + - makezero + - misspell + - nakedret + - nestif + - nilerr + - nilnil + - noctx + - nolintlint + - nosprintfhostport + - paralleltest + - prealloc + - predeclared + - promlinter + - revive + - reassign + - rowserrcheck + - sqlclosecheck + - staticcheck + - stylecheck + - tenv + - tparallel + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + - wastedassign + - whitespace + fast: false \ No newline at end of file diff --git a/characters.go b/characters.go index 6094d55..b7a1541 100644 --- a/characters.go +++ b/characters.go @@ -219,7 +219,7 @@ func HexDigit1[I Bytes]() Parser[I, I] { } } -// WhiteSpace0 parses zero or more whitespace characters: ' ', '\t', '\n', '\r'. +// Whitespace0 parses zero or more whitespace characters: ' ', '\t', '\n', '\r'. // In the cases where the input is empty, or no terminating character is found, the parser // returns the input as is. func Whitespace0[I Bytes]() Parser[I, I] {