Skip to content

Commit 5869892

Browse files
Merge pull request #51 from geowa4/linter-fixes
Make some linting fixes
2 parents 045573f + fb256c5 commit 5869892

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

cmd/install/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func Cmd() *cobra.Command {
1818
ValidArgs: append(toolNames, "all"),
1919
Short: "Install a new tool",
2020
Long: "Installs one or more tools from the given list. It's valid to specify multiple tools: in this case, all tools provided will be installed. If no specific tools are provided, all are installed by default.",
21-
RunE: func(cmd *cobra.Command, args []string) error {
21+
RunE: func(_ *cobra.Command, args []string) error {
2222
return Install(args)
2323
},
2424
}

pkg/tools/tools.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ type Tool interface {
3333
// it to provided the latestDir
3434
Install() error
3535

36-
// Confiure is currently unused
36+
// Configure currently unused
3737
Configure() error
3838

39-
// Remove uninstalls the tool by deleting it's tool-unique directory under
39+
// Remove uninstalls the tool by deleting its tool-unique directory under
4040
// the provided rootDir and unlinking itself from the latestDir
4141
Remove() error
4242

4343
// Installed validates whether the tool has already been installed under the
4444
// provided rootDir or not
4545
Installed() (bool, error)
4646

47-
// Get the version installed in latest folder
47+
// InstalledVersion gets the version installed in latest folder
4848
InstalledVersion() (string, error)
4949

50-
// Get the latest version available on repo
50+
// LatestVersion gets the latest version available on repo
5151
LatestVersion() (string, error)
5252
}
5353

@@ -57,47 +57,47 @@ func initMap() {
5757
toolMap = map[string]Tool{}
5858

5959
// Self-management
60-
self := self.New()
61-
toolMap[self.Name()] = self
60+
selfTool := self.New()
61+
toolMap[selfTool.Name()] = selfTool
6262

6363
// 3rd party tools
64-
aws := awscli.New()
65-
toolMap[aws.Name()] = aws
64+
awsTool := awscli.New()
65+
toolMap[awsTool.Name()] = awsTool
6666

67-
oc := oc.New()
68-
toolMap[oc.Name()] = oc
67+
ocTool := oc.New()
68+
toolMap[ocTool.Name()] = ocTool
6969

70-
ocm := ocm.New()
71-
toolMap[ocm.Name()] = ocm
70+
ocmTool := ocm.New()
71+
toolMap[ocmTool.Name()] = ocmTool
7272

73-
ocmaddons := ocmaddons.New()
74-
toolMap[ocmaddons.Name()] = ocmaddons
73+
ocmaddonsTool := ocmaddons.New()
74+
toolMap[ocmaddonsTool.Name()] = ocmaddonsTool
7575

76-
osdctl := osdctl.New()
77-
toolMap[osdctl.Name()] = osdctl
76+
osdctlTool := osdctl.New()
77+
toolMap[osdctlTool.Name()] = osdctlTool
7878

79-
backplanecli := backplanecli.New()
80-
toolMap[backplanecli.Name()] = backplanecli
79+
backplanecliTool := backplanecli.New()
80+
toolMap[backplanecliTool.Name()] = backplanecliTool
8181

82-
rosa := rosa.New()
83-
toolMap[rosa.Name()] = rosa
82+
rosaTool := rosa.New()
83+
toolMap[rosaTool.Name()] = rosaTool
8484

85-
yq := yq.New()
86-
toolMap[yq.Name()] = yq
85+
yqTool := yq.New()
86+
toolMap[yqTool.Name()] = yqTool
8787

88-
butane := butane.New()
89-
toolMap[butane.Name()] = butane
88+
butaneTool := butane.New()
89+
toolMap[butaneTool.Name()] = butaneTool
9090

91-
gcloud, err := gcloud.New()
91+
gcloudTool, err := gcloud.New()
9292
if err != nil {
93-
fmt.Fprintf(os.Stderr, "Encountered error while initializing the 'gcloud' tool: %v\n", err)
94-
fmt.Fprintln(os.Stderr, "Unable to install, upgrade, or remove 'gcloud' until the error is resolved")
93+
_, _ = fmt.Fprintf(os.Stderr, "Encountered error while initializing the 'gcloud' tool: %v\n", err)
94+
_, _ = fmt.Fprintln(os.Stderr, "Unable to install, upgrade, or remove 'gcloud' until the error is resolved")
9595
} else {
96-
toolMap[gcloud.Name()] = gcloud
96+
toolMap[gcloudTool.Name()] = gcloudTool
9797
}
9898

99-
servicelogger := servicelogger.New()
100-
toolMap[servicelogger.Name()] = servicelogger
99+
serviceloggerTool := servicelogger.New()
100+
toolMap[serviceloggerTool.Name()] = serviceloggerTool
101101
}
102102

103103
func GetMap() map[string]Tool {
@@ -111,7 +111,7 @@ func Names() []string {
111111
return utils.Keys(GetMap())
112112
}
113113

114-
// Remove removes the provided tools from the install directory
114+
// Remove removes the provided tools from the installation directory
115115
func Remove(tools []Tool) error {
116116
for _, tool := range tools {
117117
fmt.Println()
@@ -183,7 +183,7 @@ func RemoveInstallDir() error {
183183
// ListInstalled returns a slice containing all tools the current machine has installed
184184
func ListInstalled() ([]Tool, error) {
185185
tools := GetMap()
186-
installedTools := []Tool{}
186+
installedTools := make([]Tool, 0)
187187

188188
for _, tool := range tools {
189189
installed, err := tool.Installed()

pkg/utils/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"bufio"
5+
"errors"
56
"fmt"
67
"io"
78
"os"
@@ -99,7 +100,7 @@ func GetLineInFileMatchingKey(filepath string, key string) (res string, err erro
99100
}
100101
}
101102

102-
return "", fmt.Errorf("no match found")
103+
return "", errors.New("no match found")
103104
}
104105

105106
// GetLinInReader searches the provided reader for a line that contains the

0 commit comments

Comments
 (0)