diff --git a/.golangci.yml b/.golangci.yml index d3487f184..8f5747217 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,18 +11,30 @@ linters: - asasalint # check for pass []any as any in variadic func(...any) [fast: false, auto-fix: false] - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false] - bidichk # Checks for dangerous unicode character sequences [fast: true, auto-fix: false] + - contextcheck # check the function whether use a non-inherited context [fast: false, auto-fix: false] - decorder # check declaration order and count of types, constants, variables and functions [fast: true, auto-fix: false] - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false] - dupword # checks for duplicate words in the source code [fast: true, auto-fix: true] - durationcheck # check for two durations multiplied together [fast: false, auto-fix: false] + - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false] + - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. [fast: false, auto-fix: false] + - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. [fast: false, auto-fix: false] - gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false] - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. [fast: true, auto-fix: false] - gochecksumtype # Run exhaustiveness checks on Go "sum types" [fast: false, auto-fix: false] - goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false] - gocritic # Provides diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false] + - gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false] - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true] - gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true] + - goheader # Checks is file header matches to pattern [fast: true, auto-fix: false] - goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true] + - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. [fast: true, auto-fix: false] + - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. [fast: true, auto-fix: false] + - goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false] + - gosimple #(megacheck): Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false] + - grouper # An analyzer to analyze expression groups. [fast: true, auto-fix: false] + - importas # Enforces consistent import aliases [fast: false, auto-fix: false] - mirror # reports wrong mirror patterns of bytes/strings usage [fast: false, auto-fix: false] - unused #(megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false] - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. [fast: true, auto-fix: false] diff --git a/api/applesilicon/v1alpha1/apple_silicon_utils.go b/api/applesilicon/v1alpha1/apple_silicon_utils.go index ccc3a55a9..bb92eb059 100644 --- a/api/applesilicon/v1alpha1/apple_silicon_utils.go +++ b/api/applesilicon/v1alpha1/apple_silicon_utils.go @@ -72,6 +72,6 @@ func (s *API) WaitForPossibleDeletion(req *WaitForServerRequest, opts ...scw.Req return nil, errors.Wrap(err, "waiting for server failed") } timeToDelete := *server.DeletableAt - time.Sleep(timeToDelete.Sub(time.Now())) + time.Sleep(time.Until(timeToDelete)) return server, nil } diff --git a/api/instance/v1/volume_utils.go b/api/instance/v1/volume_utils.go index 1a6d998d8..64582c592 100644 --- a/api/instance/v1/volume_utils.go +++ b/api/instance/v1/volume_utils.go @@ -75,7 +75,7 @@ func (s *API) getUnknownVolume(req *getUnknownVolumeRequest, opts ...scw.Request } // Try instance API - if req.IsBlockVolume == nil || *req.IsBlockVolume == false { + if req.IsBlockVolume == nil || !*req.IsBlockVolume { getVolumeResponse, err := s.GetVolume(&GetVolumeRequest{ Zone: req.Zone, VolumeID: req.VolumeID, @@ -93,7 +93,7 @@ func (s *API) getUnknownVolume(req *getUnknownVolumeRequest, opts ...scw.Request } } - if volume.Type == "" && (req.IsBlockVolume == nil || *req.IsBlockVolume == true) { + if volume.Type == "" && (req.IsBlockVolume == nil || *req.IsBlockVolume) { getVolumeResponse, err := block.NewAPI(s.client).GetVolume(&block.GetVolumeRequest{ Zone: req.Zone, VolumeID: req.VolumeID, diff --git a/scw/errors.go b/scw/errors.go index fe6080d9e..29ee1f03a 100644 --- a/scw/errors.go +++ b/scw/errors.go @@ -294,7 +294,7 @@ type InvalidRequestError struct { // ToSdkError returns a standard error InvalidArgumentsError or nil Fields is nil. func (e *InvalidRequestError) ToInvalidArgumentsError() SdkError { // If error has no fields, it is not an InvalidArgumentsError. - if e.Fields == nil || len(e.Fields) == 0 { + if len(e.Fields) == 0 { return nil }