Skip to content

Commit

Permalink
fix(golangci-lint): Fix errors after upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioCarrion committed Dec 31, 2024
1 parent 118d1da commit 4d5f104
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ 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
- depguard
- musttag
- nonamedreturns
# The following are deprecated linters, added to avoid initial warning when running
- execinquery
- exportloopref
# -
- mnd # Magic number
Expand Down
16 changes: 9 additions & 7 deletions internal/rest/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
}
Expand All @@ -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")
}
Expand All @@ -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")
}

Expand Down

0 comments on commit 4d5f104

Please sign in to comment.