Skip to content

Commit 84842ed

Browse files
committed
Fix lint errors and use error.Is instead of direct comparison
1 parent c740326 commit 84842ed

File tree

7 files changed

+73
-72
lines changed

7 files changed

+73
-72
lines changed

Diff for: arduino/libraries/librariesmanager/install.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ import (
3131
"gopkg.in/src-d/go-git.v4"
3232
)
3333

34-
type AlreadyInstalledError struct{}
34+
type alreadyInstalledError struct{}
3535

36-
func (e *AlreadyInstalledError) Error() string {
36+
func (e *alreadyInstalledError) Error() string {
3737
return tr("library already installed")
3838
}
3939

4040
var (
4141
// ErrAlreadyInstalled is returned when a library is already installed and task
4242
// cannot proceed.
43-
ErrAlreadyInstalled = &AlreadyInstalledError{}
43+
ErrAlreadyInstalled = &alreadyInstalledError{}
4444
)
4545

4646
// InstallPrerequisiteCheck performs prequisite checks to install a library. It returns the

Diff for: commands/board/list.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ import (
3535
"github.com/sirupsen/logrus"
3636
)
3737

38-
type BoardNotFoundError struct{}
38+
type boardNotFoundError struct{}
3939

40-
func (e *BoardNotFoundError) Error() string {
40+
func (e *boardNotFoundError) Error() string {
4141
return tr("board not found")
4242
}
4343

4444
var (
4545
// ErrNotFound is returned when the API returns 404
46-
ErrNotFound = &BoardNotFoundError{}
46+
ErrNotFound = &boardNotFoundError{}
4747
vidPidURL = "https://builder.arduino.cc/v3/boards/byVidPid"
4848
validVidPid = regexp.MustCompile(`0[xX][a-fA-F\d]{4}`)
4949
)
@@ -138,7 +138,7 @@ func identify(pm *packagemanager.PackageManager, port *discovery.Port) ([]*rpc.B
138138
// the builder API if the board is a USB device port
139139
if len(boards) == 0 {
140140
items, err := identifyViaCloudAPI(port)
141-
if err == ErrNotFound {
141+
if errors.Is(err, ErrNotFound) {
142142
// the board couldn't be detected, print a warning
143143
logrus.Debug("Board not recognized")
144144
} else if err != nil {

Diff for: commands/board/list_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestBoardDetectionViaAPIWithNonUSBPort(t *testing.T) {
108108
Properties: properties.NewMap(),
109109
}
110110
items, err := identifyViaCloudAPI(port)
111-
require.Equal(t, err, ErrNotFound)
111+
require.ErrorIs(t, err, ErrNotFound)
112112
require.Empty(t, items)
113113
}
114114

Diff for: commands/instances.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package commands
1717

1818
import (
1919
"context"
20+
"errors"
2021
"fmt"
2122
"io/ioutil"
2223
"net/url"
@@ -703,7 +704,7 @@ func Upgrade(ctx context.Context, req *rpc.UpgradeRequest, downloadCB DownloadPr
703704
// Installs downloaded library
704705
taskCB(&rpc.TaskProgress{Name: tr("Installing %s", available)})
705706
libPath, libReplaced, err := lm.InstallPrerequisiteCheck(available)
706-
if err == librariesmanager.ErrAlreadyInstalled {
707+
if errors.Is(err, librariesmanager.ErrAlreadyInstalled) {
707708
taskCB(&rpc.TaskProgress{Message: tr("Already installed %s", available), Completed: true})
708709
continue
709710
} else if err != nil {

Diff for: commands/lib/install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func installLibrary(lm *librariesmanager.LibrariesManager, libRelease *libraries
9292
taskCB(&rpc.TaskProgress{Name: tr("Installing %s", libRelease)})
9393
logrus.WithField("library", libRelease).Info("Installing library")
9494
libPath, libReplaced, err := lm.InstallPrerequisiteCheck(libRelease)
95-
if err == librariesmanager.ErrAlreadyInstalled {
95+
if errors.Is(err, librariesmanager.ErrAlreadyInstalled) {
9696
taskCB(&rpc.TaskProgress{Message: tr("Already installed %s", libRelease), Completed: true})
9797
return nil
9898
}

0 commit comments

Comments
 (0)