update golangci-lint to v1.59.1

Includes fixes for new lint warnings from unparam and usestdlibvars.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2024-06-10 14:46:45 +02:00
parent 7ff1494c47
commit fa4f11facc
6 changed files with 13 additions and 8 deletions

View File

@ -62,7 +62,7 @@ BUILDTAGS += ${EXTRA_BUILDTAGS}
# N/B: This value is managed by Renovate, manual changes are # N/B: This value is managed by Renovate, manual changes are
# possible, as long as they don't disturb the formatting # possible, as long as they don't disturb the formatting
# (i.e. DO NOT ADD A 'v' prefix!) # (i.e. DO NOT ADD A 'v' prefix!)
GOLANGCI_LINT_VERSION := 1.59.0 GOLANGCI_LINT_VERSION := 1.59.1
PYTHON ?= $(shell command -v python3 python|head -n1) PYTHON ?= $(shell command -v python3 python|head -n1)
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1) PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)
# ~/.local/bin is not in PATH on all systems # ~/.local/bin is not in PATH on all systems

View File

@ -161,7 +161,7 @@ func jsonOut(responses []entities.ListContainer) error {
return nil return nil
} }
func quietOut(responses []entities.ListContainer) error { func quietOut(responses []entities.ListContainer) {
for _, r := range responses { for _, r := range responses {
id := r.ID id := r.ID
if !noTrunc { if !noTrunc {
@ -169,7 +169,6 @@ func quietOut(responses []entities.ListContainer) error {
} }
fmt.Println(id) fmt.Println(id)
} }
return nil
} }
func getResponses() ([]entities.ListContainer, error) { func getResponses() ([]entities.ListContainer, error) {
@ -217,7 +216,8 @@ func ps(cmd *cobra.Command, _ []string) error {
case report.IsJSON(listOpts.Format): case report.IsJSON(listOpts.Format):
return jsonOut(listContainers) return jsonOut(listContainers)
case listOpts.Quiet && !cmd.Flags().Changed("format"): case listOpts.Quiet && !cmd.Flags().Changed("format"):
return quietOut(listContainers) quietOut(listContainers)
return nil
} }
responses := make([]psReporter, 0, len(listContainers)) responses := make([]psReporter, 0, len(listContainers))

View File

@ -321,30 +321,35 @@ func (c *Connection) GetDialer(ctx context.Context) (net.Conn, error) {
// IsInformational returns true if the response code is 1xx // IsInformational returns true if the response code is 1xx
func (h *APIResponse) IsInformational() bool { func (h *APIResponse) IsInformational() bool {
//nolint:usestdlibvars // linter wants to use http.StatusContinue over 100 but that makes less readable IMO
return h.Response.StatusCode/100 == 1 return h.Response.StatusCode/100 == 1
} }
// IsSuccess returns true if the response code is 2xx // IsSuccess returns true if the response code is 2xx
func (h *APIResponse) IsSuccess() bool { func (h *APIResponse) IsSuccess() bool {
//nolint:usestdlibvars // linter wants to use http.StatusContinue over 100 but that makes less readable IMO
return h.Response.StatusCode/100 == 2 return h.Response.StatusCode/100 == 2
} }
// IsRedirection returns true if the response code is 3xx // IsRedirection returns true if the response code is 3xx
func (h *APIResponse) IsRedirection() bool { func (h *APIResponse) IsRedirection() bool {
//nolint:usestdlibvars // linter wants to use http.StatusContinue over 100 but that makes less readable IMO
return h.Response.StatusCode/100 == 3 return h.Response.StatusCode/100 == 3
} }
// IsClientError returns true if the response code is 4xx // IsClientError returns true if the response code is 4xx
func (h *APIResponse) IsClientError() bool { func (h *APIResponse) IsClientError() bool {
//nolint:usestdlibvars // linter wants to use http.StatusContinue over 100 but that makes less readable IMO
return h.Response.StatusCode/100 == 4 return h.Response.StatusCode/100 == 4
} }
// IsConflictError returns true if the response code is 409 // IsConflictError returns true if the response code is 409
func (h *APIResponse) IsConflictError() bool { func (h *APIResponse) IsConflictError() bool {
return h.Response.StatusCode == 409 return h.Response.StatusCode == http.StatusConflict
} }
// IsServerError returns true if the response code is 5xx // IsServerError returns true if the response code is 5xx
func (h *APIResponse) IsServerError() bool { func (h *APIResponse) IsServerError() bool {
//nolint:usestdlibvars // linter wants to use http.StatusContinue over 100 but that makes less readable IMO
return h.Response.StatusCode/100 == 5 return h.Response.StatusCode/100 == 5
} }

View File

@ -427,7 +427,7 @@ func Export(ctx context.Context, nameOrID string, w io.Writer, options *ExportOp
} }
defer response.Body.Close() defer response.Body.Close()
if response.StatusCode/100 == 2 { if response.IsSuccess() {
_, err = io.Copy(w, response.Body) _, err = io.Copy(w, response.Body)
return err return err
} }

View File

@ -162,7 +162,7 @@ func Export(ctx context.Context, nameOrIDs []string, w io.Writer, options *Expor
} }
defer response.Body.Close() defer response.Body.Close()
if response.StatusCode/100 == 2 || response.StatusCode/100 == 3 { if response.IsSuccess() || response.IsRedirection() {
_, err = io.Copy(w, response.Body) _, err = io.Copy(w, response.Body)
return err return err
} }

View File

@ -269,7 +269,7 @@ func WaitAndPingAPI(sock string) {
if err == nil { if err == nil {
defer resp.Body.Close() defer resp.Body.Close()
} }
if err != nil || resp.StatusCode != 200 { if err != nil || resp.StatusCode != http.StatusOK {
logrus.Warn("API socket failed ping test") logrus.Warn("API socket failed ping test")
} }
} }