From 4d5f104017f290f3282a1b6cff2e4b311024f25d Mon Sep 17 00:00:00 2001 From: Mario Carrion Date: Mon, 30 Dec 2024 18:56:09 -0500 Subject: [PATCH] fix(golangci-lint): Fix errors after upgrade --- .golangci.yml | 2 -- internal/rest/priority.go | 16 +++++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a65d5f10..92c375af 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,7 +2,6 @@ linters: enable-all: true disable: - gofumpt # Prefer `gofmt` rules / some rules conflict with `wsl` - - gomnd # XXX: For now - spancheck # Calling End() is implemented as expected # I disagree with the rationale behind these linters - err113 @@ -10,7 +9,6 @@ linters: - musttag - nonamedreturns # The following are deprecated linters, added to avoid initial warning when running - - execinquery - exportloopref # - - mnd # Magic number diff --git a/internal/rest/priority.go b/internal/rest/priority.go index 4a6ff17b..bb425b41 100644 --- a/internal/rest/priority.go +++ b/internal/rest/priority.go @@ -34,8 +34,8 @@ func NewPriority(p internal.Priority) Priority { // Convert returns the domain type defining the internal representation, when priority is unknown "none" is // used. -func (p Priority) Convert() internal.Priority { - switch p { +func (p *Priority) Convert() internal.Priority { + switch *p { case priorityNone: return internal.PriorityNone case priorityLow: @@ -50,8 +50,8 @@ func (p Priority) Convert() internal.Priority { } // Validate ... -func (p Priority) Validate() error { - switch p { +func (p *Priority) Validate() error { + switch *p { case priorityNone, priorityLow, priorityMedium, priorityHigh: return nil } @@ -60,12 +60,12 @@ func (p Priority) Validate() error { } // MarshalJSON ... -func (p Priority) MarshalJSON() ([]byte, error) { +func (p *Priority) MarshalJSON() ([]byte, error) { if err := p.Validate(); err != nil { return nil, internal.WrapErrorf(err, internal.ErrorCodeUnknown, "Validate") } - b, err := json.Marshal(string(p)) + b, err := json.Marshal(string(*p)) if err != nil { return nil, internal.WrapErrorf(err, internal.ErrorCodeUnknown, "json.Marshal") } @@ -80,7 +80,9 @@ func (p *Priority) UnmarshalJSON(b []byte) error { return internal.WrapErrorf(err, internal.ErrorCodeInvalidArgument, "json.Unmarshal") } - if err := Priority(str).Validate(); err != nil { + conv := Priority(str) + + if err := conv.Validate(); err != nil { return internal.WrapErrorf(err, internal.ErrorCodeInvalidArgument, "Validate") }