Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add errorlint linter. #3179

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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