Skip to content

Commit d329e49

Browse files
committed
.golangci.yml: enable staticcheck
``` pkg/editutil/editutil.go:55:17: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func OpenEditor(name string, content []byte, hdr string) ([]byte, error) { ^ pkg/downloader/downloader.go:480:2: if-return: redundant if ...; err != nil check, just return error instead. (revive) if err := os.Rename(localPathTmp, localPath); err != nil { return err } pkg/guestagent/api/server/server.go:19:50: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive) func (b *Backend) onError(w http.ResponseWriter, r *http.Request, err error, ec int) { ^ pkg/cidata/cidata_test.go:16:19: unused-parameter: parameter 'host' seems to be unused, consider removing or renaming it as _ (revive) func fakeLookupIP(host string) []net.IP { ^ pkg/driver/driver.go:82:63: unused-parameter: parameter 'password' seems to be unused, consider removing or renaming it as _ (revive) func (d *BaseDriver) ChangeDisplayPassword(_ context.Context, password string) error { ^ pkg/networks/usernet/recoincile.go:86:4: if-return: redundant if ...; err != nil check, just return error instead. (revive) if err := cmd.Start(); err != nil { return err } pkg/networks/reconcile/reconcile.go:152:2: if-return: redundant if ...; err != nil check, just return error instead. (revive) if err := cmd.Start(); err != nil { return err } pkg/qemu/qemu_driver.go:144:44: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (l *LimaQemuDriver) changeVNCPassword(ctx context.Context, password string) error { ^ pkg/qemu/qemu_driver.go:166:44: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (l *LimaQemuDriver) getVNCDisplayPort(ctx context.Context) (string, error) { ^ pkg/qemu/qemu_driver.go:269:41: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (l *LimaQemuDriver) DeleteSnapshot(ctx context.Context, tag string) error { ^ pkg/hostagent/api/server/server.go:17:50: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive) func (b *Backend) onError(w http.ResponseWriter, r *http.Request, err error, ec int) { ^ cmd/limactl/completion.go:8:32: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) func bashCompleteInstanceNames(cmd *cobra.Command) ([]string, cobra.ShellCompDirective) { ^ cmd/limactl/edit.go:141:43: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) func editBashComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ^ cmd/limactl/debug.go:64:6: empty-block: this block is empty, you can remove it (revive) for { } cmd/limactl/snapshot.go:187:47: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) func snapshotBashComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ^ cmd/limactl/factory-reset.go:25:25: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) func factoryResetAction(cmd *cobra.Command, args []string) error { ^ cmd/limactl/validate.go:23:21: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) func validateAction(cmd *cobra.Command, args []string) error { ^ cmd/limactl/factory-reset.go:59:51: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) func factoryResetBashComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ^ pkg/iso9660util/iso9660util.go:5:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck) "io/ioutil" ^ pkg/downloader/downloader_test.go:4:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck) "io/ioutil" ^ pkg/vz/vz_driver_darwin.go:174:11: SA1015: using time.Tick leaks the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (staticcheck) tick := time.Tick(500 * time.Millisecond) ^ pkg/networks/usernet/client.go:33:10: SA1015: using time.Tick leaks the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (staticcheck) tick := time.Tick(500 * time.Millisecond) ^ pkg/vz/vm_darwin.go:88:6: SA5003: defers in this infinite loop will never run (staticcheck) defer os.RemoveAll(pidFile) ^ ``` Signed-off-by: Akihiro Suda <[email protected]>
1 parent 7da9832 commit d329e49

39 files changed

+78
-88
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ linters:
6969
# - rowserrcheck
7070
# - scopelint
7171
# - sqlclosecheck
72-
# - staticcheck
72+
- staticcheck
7373
# - stylecheck
7474
# - testpackage
7575
# - tparallel

cmd/lima-guestagent/daemon_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func newDaemonCommand() *cobra.Command {
2424
return daemonCommand
2525
}
2626

27-
func daemonAction(cmd *cobra.Command, args []string) error {
27+
func daemonAction(cmd *cobra.Command, _ []string) error {
2828
socket := "/run/lima-guestagent.sock"
2929
tick, err := cmd.Flags().GetDuration("tick")
3030
if err != nil {

cmd/lima-guestagent/install_systemd_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func newInstallSystemdCommand() *cobra.Command {
2222
return installSystemdCommand
2323
}
2424

25-
func installSystemdAction(cmd *cobra.Command, args []string) error {
25+
func installSystemdAction(_ *cobra.Command, _ []string) error {
2626
unit, err := generateSystemdUnit()
2727
if err != nil {
2828
return err

cmd/limactl/completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"github.com/spf13/cobra"
66
)
77

8-
func bashCompleteInstanceNames(cmd *cobra.Command) ([]string, cobra.ShellCompDirective) {
8+
func bashCompleteInstanceNames(_ *cobra.Command) ([]string, cobra.ShellCompDirective) {
99
instances, err := store.Instances()
1010
if err != nil {
1111
return nil, cobra.ShellCompDirectiveDefault

cmd/limactl/debug.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"strconv"
5+
"time"
56

67
"github.com/lima-vm/lima/pkg/hostagent/dns"
78
"github.com/sirupsen/logrus"
@@ -62,5 +63,6 @@ func debugDNSAction(cmd *cobra.Command, args []string) error {
6263
}
6364
logrus.Infof("Started srv %+v (UDP %d, TCP %d)", srv, udpLocalPort, tcpLocalPort)
6465
for {
66+
time.Sleep(time.Hour)
6567
}
6668
}

cmd/limactl/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ func deleteInstance(inst *store.Instance, force bool) error {
5959
return nil
6060
}
6161

62-
func deleteBashComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
62+
func deleteBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
6363
return bashCompleteInstanceNames(cmd)
6464
}

cmd/limactl/disk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func diskCreateAction(cmd *cobra.Command, args []string) error {
9797
}
9898

9999
if err := qemu.CreateDataDisk(diskDir, format, int(diskSize)); err != nil {
100-
return err
100+
return fmt.Errorf("Failed to create %s disk in %q", format, diskDir)
101101
}
102102

103103
return nil
@@ -297,7 +297,7 @@ $ limactl disk unlock DISK1 DISK2 ...
297297
return diskUnlockCommand
298298
}
299299

300-
func diskUnlockAction(cmd *cobra.Command, args []string) error {
300+
func diskUnlockAction(_ *cobra.Command, args []string) error {
301301
for _, diskName := range args {
302302
disk, err := store.InspectDisk(diskName)
303303
if err != nil {

cmd/limactl/edit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func editAction(cmd *cobra.Command, args []string) error {
7777
hdr += "# and an empty file will abort the edit.\n"
7878
hdr += "\n"
7979
hdr += editutil.GenerateEditorWarningHeader()
80-
yBytes, err = editutil.OpenEditor(instName, yContent, hdr)
80+
yBytes, err = editutil.OpenEditor(yContent, hdr)
8181
if err != nil {
8282
return err
8383
}
@@ -138,6 +138,6 @@ func askWhetherToStart() (bool, error) {
138138
return ans, nil
139139
}
140140

141-
func editBashComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
141+
func editBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
142142
return bashCompleteInstanceNames(cmd)
143143
}

cmd/limactl/factory-reset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func newFactoryResetCommand() *cobra.Command {
2222
return resetCommand
2323
}
2424

25-
func factoryResetAction(cmd *cobra.Command, args []string) error {
25+
func factoryResetAction(_ *cobra.Command, args []string) error {
2626
instName := DefaultInstanceName
2727
if len(args) > 0 {
2828
instName = args[0]
@@ -56,6 +56,6 @@ func factoryResetAction(cmd *cobra.Command, args []string) error {
5656
return nil
5757
}
5858

59-
func factoryResetBashComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
59+
func factoryResetBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
6060
return bashCompleteInstanceNames(cmd)
6161
}

cmd/limactl/info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func newInfoCommand() *cobra.Command {
1818
return infoCommand
1919
}
2020

21-
func infoAction(cmd *cobra.Command, args []string) error {
21+
func infoAction(cmd *cobra.Command, _ []string) error {
2222
info, err := infoutil.GetInfo()
2323
if err != nil {
2424
return err

0 commit comments

Comments
 (0)