Skip to content

Commit 824c82a

Browse files
committed
Fixed a bunch of lint warnings
1 parent d4395bc commit 824c82a

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

commands/core/download.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ func downloadPlatform(pm *packagemanager.PackageManager, platformRelease *cores.
6868
if err != nil {
6969
formatter.PrintError(err, "Error downloading "+platformRelease.String())
7070
return err
71-
} else {
72-
return download(resp, platformRelease.String(), progressCallback)
7371
}
72+
return download(resp, platformRelease.String(), progressCallback)
7473
}
7574

7675
func downloadTool(pm *packagemanager.PackageManager, tool *cores.ToolRelease, progressCallback func(*rpc.DownloadProgress)) error {
@@ -89,9 +88,8 @@ func DownloadToolRelease(pm *packagemanager.PackageManager, toolRelease *cores.T
8988
if err != nil {
9089
formatter.PrintError(err, "Error downloading "+toolRelease.String())
9190
return err
92-
} else {
93-
return download(resp, toolRelease.String(), progressCallback)
9491
}
92+
return download(resp, toolRelease.String(), progressCallback)
9593
}
9694

9795
// TODO: Refactor this into output.*?

commands/core/install.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq, progress
2929
platform, tools, err := pm.FindPlatformReleaseDependencies(ref)
3030
if err != nil {
3131
formatter.PrintError(err, "Could not determine platform dependencies")
32-
return nil, fmt.Errorf("Could not determine platform dependencies", err)
32+
return nil, fmt.Errorf("Could not determine platform dependencies: %s", err)
3333
}
3434

3535
err = installPlatform(pm, platform, tools, progress)
@@ -92,7 +92,7 @@ func installPlatform(pm *packagemanager.PackageManager,
9292
if err != nil {
9393
log.WithError(err).Error("Cannot install platform")
9494
formatter.PrintError(err, "Cannot install platform")
95-
return fmt.Errorf("Cannot install platform", err)
95+
return err
9696
}
9797

9898
// If upgrading remove previous release
@@ -108,9 +108,9 @@ func installPlatform(pm *packagemanager.PackageManager,
108108
if err := pm.UninstallPlatform(platformRelease); err != nil {
109109
log.WithError(err).Error("Error rolling-back changes.")
110110
formatter.PrintError(err, "Error rolling-back changes.")
111-
return fmt.Errorf("Error rolling-back changes.", err)
111+
return fmt.Errorf("rolling-back changes: %s", err)
112112
}
113-
return fmt.Errorf("Error updating platform", errUn)
113+
return fmt.Errorf("updating platform: %s", errUn)
114114
}
115115
}
116116

commands/core/uninstall.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
3333
// If no version is specified consider the installed
3434
version, err := semver.Parse(req.Version)
3535
if err != nil {
36-
formatter.PrintError(err, "version not readable")
37-
return nil, fmt.Errorf("version not readable", err)
36+
return nil, fmt.Errorf("invalid version: %s", err)
3837
}
3938
ref := &packagemanager.PlatformReference{
4039
Package: req.PlatformPackage,
@@ -45,13 +44,13 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
4544
platform := pm.FindPlatform(ref)
4645
if platform == nil {
4746
formatter.PrintErrorMessage("Platform not found " + ref.String())
48-
return nil, fmt.Errorf("Platform not found "+ref.String(), err)
47+
return nil, fmt.Errorf("platform not found: %s", ref.String())
4948

5049
}
5150
platformRelease := pm.GetInstalledPlatformRelease(platform)
5251
if platformRelease == nil {
5352
formatter.PrintErrorMessage("Platform not installed " + ref.String())
54-
return nil, fmt.Errorf("Platform not installed "+ref.String(), err)
53+
return nil, fmt.Errorf("platform not installed: %s", ref.String())
5554

5655
}
5756
ref.PlatformVersion = platformRelease.Version
@@ -60,8 +59,7 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
6059
platform, tools, err := pm.FindPlatformReleaseDependencies(ref)
6160
if err != nil {
6261
formatter.PrintError(err, "Could not determine platform dependencies")
63-
return nil, fmt.Errorf("Could not determine platform dependencies", err)
64-
62+
return nil, fmt.Errorf("finding platform dependencies: %s", err)
6563
}
6664

6765
err = uninstallPlatformRelease(pm, platform)

commands/core/upgrade.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeReq, progress
5858
}
5959

6060
func upgradePlatform(pm *packagemanager.PackageManager, platformRef *packagemanager.PlatformReference, progress commands.ProgressCB) error {
61-
6261
if platformRef.PlatformVersion != nil {
6362
formatter.PrintErrorMessage("Invalid item " + platformRef.String() + ", upgrade doesn't accept parameters with version")
6463
return fmt.Errorf("Invalid item " + platformRef.String() + ", upgrade doesn't accept parameters with version")
@@ -80,10 +79,9 @@ func upgradePlatform(pm *packagemanager.PackageManager, platformRef *packagemana
8079
if !latest.Version.GreaterThan(installed.Version) {
8180
formatter.PrintResult("Platform " + platformRef.String() + " is already at the latest version.")
8281
return fmt.Errorf("Platform " + platformRef.String() + " is already at the latest version.")
83-
} else {
84-
platformRef.PlatformVersion = latest.Version
85-
toInstallRefs = append(toInstallRefs, platformRef)
8682
}
83+
platformRef.PlatformVersion = latest.Version
84+
toInstallRefs = append(toInstallRefs, platformRef)
8785

8886
for _, platformRef := range toInstallRefs {
8987
platform, tools, err := pm.FindPlatformReleaseDependencies(platformRef)

0 commit comments

Comments
 (0)