errcheck v1.30.0 reports a bare receive from an error channel as an
unchecked error. Each receive it flagged waits for a process or server
to exit after Lima has stopped or killed it, so the error adds nothing;
discard it with "_ = <-ch".
But staticcheck's S1005 flags "_ = <-ch" as an unnecessary blank
assignment, so each spelling of the discard fails one of the two
linters. Disable S1005. It also flags blank identifiers in range loops,
such as "for _ = range", but gofmt's simplify step and revive's range
rule still catch those.
Signed-off-by: Jan Dubois <jan.dubois@suse.com>
Add nolint directive for flag.Parse() in external driver server (the
Serve function is intended to be called from main). Add exclusion for
"api" package names in hostagent and guestagent.
Signed-off-by: Jan Dubois <jan.dubois@suse.com>
The major version is now updated to highlight the introduction of the
pluggable VM driver framework.
See issue 3712
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Also disallows the "admin" username by default (because it is a builtin
user in Ubuntu), but can be overridden by setting it explicitly in lima.yaml.
Signed-off-by: Jan Dubois <jan.dubois@suse.com>
```
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 <akihiro.suda.cz@hco.ntt.co.jp>
The `revive` linter was failing with the following errors:
```
pkg/osutil/user.go:19:2: var-naming: struct field Uid should be UID (revive)
Uid uint32
^
pkg/osutil/user.go:79:2: var-naming: const fallbackUid should be fallbackUID (revive)
fallbackUid = 1000
^
pkg/osutil/osutil_others.go:16:2: var-naming: struct field Uid should be UID (revive)
Uid uint32
^
cmd/limactl/start.go:178:10: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
} else {
if !errors.Is(err, os.ErrNotExist) {
return nil, err
}
if arg != "" && arg != DefaultInstanceName {
logrus.Infof("Creating an instance %q from template://default (Not from template://%s)", st.instName, st.instName)
logrus.Warnf("This form is deprecated. Use `limactl start --name=%s template://default` instead", st.instName)
}
// Read the default template for creating a new instance
st.yBytes, err = readDefaultTemplate()
if err != nil {
return nil, err
}
}
pkg/hostagent/dns/dns_test.go:70:5: var-naming: don't use underscores in Go names; var regex_match should be regexMatch (revive)
regex_match := func(value string, pattern string) cmp.Comparison {
^
pkg/networks/reconcile/reconcile.go:112:51: context-as-argument: context.Context should be the first parameter of a function (revive)
func startDaemon(config *networks.NetworksConfig, ctx context.Context, name, daemon string) error {
^
pkg/networks/reconcile/reconcile.go:176:52: context-as-argument: context.Context should be the first parameter of a function (revive)
func startNetwork(config *networks.NetworksConfig, ctx context.Context, name string) error {
^
pkg/networks/networks.go:5:6: exported: type name will be used as networks.NetworksConfig by other packages, and that stutters; consider calling this Config (revive)
type NetworksConfig struct {
^
pkg/networks/sudoers.go:84:10: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
} else {
return fmt.Errorf("passwordLessSudo error: %w", err)
}
pkg/networks/sudoers.go:96:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
} else {
logrus.Debugf("%q does not exist; passwordLessSudo error: %s", sudoersFile, err)
}
```
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>