Skip to content

Commit

Permalink
build: Add errorlint linter.
Browse files Browse the repository at this point in the history
This adds the errorlint linter to the list of linters and addresses a
few false positives it complains about.
  • Loading branch information
davecgh committed Aug 28, 2023
1 parent 318d81b commit f69247f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ linters:
- dupword
- durationcheck
- errchkjson
- errorlint
- exportloopref
- gofmt
- goimports
Expand Down
3 changes: 2 additions & 1 deletion dcrutil/wif_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013, 2014 The btcsuite developers
// Copyright (c) 2015-2021 The Decred developers
// Copyright (c) 2015-2023 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -38,6 +38,7 @@ func TestWIF(t *testing.T) {
if (err == nil) != (target == nil) {
return false
}
// nolint: errorlint
return err == target || (err != nil && err.Error() == target.Error())
}

Expand Down
2 changes: 2 additions & 0 deletions wire/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (e ErrorCode) Error() string {
// - The target is a *MessageError and the error codes match
// - The target is an ErrorCode and it the error codes match
func (e ErrorCode) Is(target error) bool {
// nolint: errorlint
switch target := target.(type) {
case *MessageError:
return e == target.ErrorCode
Expand Down Expand Up @@ -232,6 +233,7 @@ func messageError(funcName string, c ErrorCode, desc string) *MessageError {
// - The target is a *MessageError and the error codes match
// - The target is an ErrorCode and it the error codes match
func (m *MessageError) Is(target error) bool {
// nolint: errorlint
switch target := target.(type) {
case *MessageError:
return m.ErrorCode == target.ErrorCode
Expand Down

0 comments on commit f69247f

Please sign in to comment.