Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update golangci-lint to v1.55.2 #2817

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# NOTE: Keep this in sync with the version from .golangci.yml
version: v1.51.0
version: v1.55.2
33 changes: 24 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@ linters-settings:
extra-rules: true

gosec:
excludes:
- G104
config:
global:
audit: true

depguard:
include-go-root: true
packages:
- flag
- io/ioutil
packages-with-error-message:
- flag: '`flag` package is only allowed in main.go'
- io/ioutil: '`io/ioutil` package is deprecated, use the `io` and `os` package instead'
rules:
main:
deny:
- pkg: flag
desc: '`flag` package is only allowed in main.go'
- pkg: io/ioutil
desc: '`io/ioutil` package is deprecated, use the `io` and `os` package instead'

govet:
check-shadowing: true
Expand Down Expand Up @@ -93,13 +95,17 @@ linters-settings:
disabled: true
- name: cognitive-complexity
disabled: true
- name: comment-spacings
disabled: true # TODO https://github.com/gofiber/fiber/issues/2816
gaby marked this conversation as resolved.
Show resolved Hide resolved
- name: cyclomatic
disabled: true
- name: early-return
severity: warning
disabled: true
- name: exported
disabled: true
arguments:
- disableStutteringCheck # TODO https://github.com/gofiber/fiber/issues/2816
- name: file-header
disabled: true
- name: function-result-limit
Expand All @@ -116,6 +122,8 @@ linters-settings:
disabled: true
- name: package-comments
disabled: true
- name: unchecked-type-assertion
disabled: true # TODO https://github.com/gofiber/fiber/issues/2816

stylecheck:
checks:
Expand Down Expand Up @@ -164,7 +172,8 @@ linters:
- exportloopref
- forbidigo
- forcetypeassert
- goconst
# - gochecksumtype # TODO https://github.com/gofiber/fiber/issues/2816
# - goconst # TODO https://github.com/gofiber/fiber/issues/2816
- gocritic
- gofmt
- gofumpt
Expand All @@ -173,9 +182,12 @@ linters:
- goprintffuncname
- gosec
- gosimple
# - gosmopolitan # TODO https://github.com/gofiber/fiber/issues/2816
- govet
- grouper
# - inamedparam # TODO https://github.com/gofiber/fiber/issues/2816
- loggercheck
# - mirror # TODO https://github.com/gofiber/fiber/issues/2816
- misspell
- nakedret
- nilerr
Expand All @@ -184,6 +196,7 @@ linters:
- nolintlint
- nonamedreturns
- nosprintfhostport
# - perfsprint # TODO https://github.com/gofiber/fiber/issues/2816
- predeclared
- promlinter
- reassign
Expand All @@ -192,7 +205,9 @@ linters:
- sqlclosecheck
- staticcheck
- stylecheck
# - tagalign # TODO https://github.com/gofiber/fiber/issues/2816
- tagliatelle
- testifylint
# - testpackage # TODO: Enable once https://github.com/gofiber/fiber/issues/2252 is implemented
- thelper
- tparallel
Expand All @@ -201,7 +216,7 @@ linters:
- unparam
- unused
- usestdlibvars
- wastedassign
# - wastedassign # TODO https://github.com/gofiber/fiber/issues/2816
- whitespace
- wrapcheck
- tenv
4 changes: 2 additions & 2 deletions binder/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func parseParamSquareBrackets(k string) (string, error) {
for i, b := range kbytes {
if b == '[' && kbytes[i+1] != ']' {
if err := bb.WriteByte('.'); err != nil {
return "", err //nolint:wrapchec,wrapcheck // unnecessary to wrap it
return "", err //nolint:wrapcheck // unnecessary to wrap it
}
}

Expand All @@ -145,7 +145,7 @@ func parseParamSquareBrackets(k string) (string, error) {
}

if err := bb.WriteByte(b); err != nil {
return "", err //nolint:wrapchec,wrapcheck // unnecessary to wrap it
return "", err //nolint:wrapcheck // unnecessary to wrap it
}
}

Expand Down
28 changes: 14 additions & 14 deletions error.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package fiber

import (
errors "encoding/json"
stdErrors "errors"
"encoding/json"
"errors"

"github.com/gofiber/fiber/v3/internal/schema"
)

// Wrap and return this for unreachable code if panicking is undesirable (i.e., in a handler).
// Unexported because users will hopefully never need to see it.
var errUnreachable = stdErrors.New("fiber: unreachable code, please create an issue at github.com/gofiber/fiber")
var errUnreachable = errors.New("fiber: unreachable code, please create an issue at github.com/gofiber/fiber")

// Graceful shutdown errors
var (
ErrGracefulTimeout = stdErrors.New("shutdown: graceful timeout has been reached, exiting")
ErrGracefulTimeout = errors.New("shutdown: graceful timeout has been reached, exiting")
)

// Fiber redirection errors
Expand All @@ -23,17 +23,17 @@ var (

// Range errors
var (
ErrRangeMalformed = stdErrors.New("range: malformed range header string")
ErrRangeUnsatisfiable = stdErrors.New("range: unsatisfiable range")
ErrRangeMalformed = errors.New("range: malformed range header string")
ErrRangeUnsatisfiable = errors.New("range: unsatisfiable range")
)

// Binder errors
var ErrCustomBinderNotFound = stdErrors.New("binder: custom binder not found, please be sure to enter the right name")
var ErrCustomBinderNotFound = errors.New("binder: custom binder not found, please be sure to enter the right name")

// Format errors
var (
// ErrNoHandlers is returned when c.Format is called with no arguments.
ErrNoHandlers = stdErrors.New("format: at least one handler is required, but none were set")
ErrNoHandlers = errors.New("format: at least one handler is required, but none were set")
)

// gorilla/schema errors
Expand All @@ -52,21 +52,21 @@ type (
type (
// An InvalidUnmarshalError describes an invalid argument passed to Unmarshal.
// (The argument to Unmarshal must be a non-nil pointer.)
InvalidUnmarshalError = errors.InvalidUnmarshalError
InvalidUnmarshalError = json.InvalidUnmarshalError

// A MarshalerError represents an error from calling a MarshalJSON or MarshalText method.
MarshalerError = errors.MarshalerError
MarshalerError = json.MarshalerError

// A SyntaxError is a description of a JSON syntax error.
SyntaxError = errors.SyntaxError
SyntaxError = json.SyntaxError

// An UnmarshalTypeError describes a JSON value that was
// not appropriate for a value of a specific Go type.
UnmarshalTypeError = errors.UnmarshalTypeError
UnmarshalTypeError = json.UnmarshalTypeError

// An UnsupportedTypeError is returned by Marshal when attempting
// to encode an unsupported value type.
UnsupportedTypeError = errors.UnsupportedTypeError
UnsupportedTypeError = json.UnsupportedTypeError

UnsupportedValueError = errors.UnsupportedValueError
UnsupportedValueError = json.UnsupportedValueError
)
2 changes: 1 addition & 1 deletion middleware/adaptor/adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func Test_HTTPHandler(t *testing.T) {
req.Header.SetMethod(expectedMethod)
req.SetRequestURI(expectedRequestURI)
req.Header.SetHost(expectedHost)
req.BodyWriter().Write([]byte(expectedBody)) //nolint:errcheck, gosec // not needed
req.BodyWriter().Write([]byte(expectedBody)) //nolint:errcheck // not needed
for k, v := range expectedHeader {
req.Header.Set(k, v)
}
Expand Down
6 changes: 3 additions & 3 deletions redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func Benchmark_Redirect_Route(b *testing.B) {
b.ResetTimer()

for n := 0; n < b.N; n++ {
c.Redirect().Route("user", RedirectConfig{ //nolint:errcheck,gosec,revive // we don't need to handle error here
c.Redirect().Route("user", RedirectConfig{ //nolint:errcheck,revive // we don't need to handle error here
Params: Map{
"name": "fiber",
},
Expand All @@ -366,7 +366,7 @@ func Benchmark_Redirect_Route_WithQueries(b *testing.B) {
b.ResetTimer()

for n := 0; n < b.N; n++ {
c.Redirect().Route("user", RedirectConfig{ //nolint:errcheck,gosec,revive // we don't need to handle error here
c.Redirect().Route("user", RedirectConfig{ //nolint:errcheck,revive // we don't need to handle error here
Params: Map{
"name": "fiber",
},
Expand Down Expand Up @@ -395,7 +395,7 @@ func Benchmark_Redirect_Route_WithFlashMessages(b *testing.B) {
b.ResetTimer()

for n := 0; n < b.N; n++ {
c.Redirect().With("success", "1").With("message", "test").Route("user") //nolint:errcheck,gosec,revive // we don't need to handle error here
c.Redirect().With("success", "1").With("message", "test").Route("user") //nolint:errcheck,revive // we don't need to handle error here
}

require.Equal(b, 302, c.Response().StatusCode())
Expand Down
Loading