From ae49f3983ca35e3a7e07cd19189c5a4339d68298 Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Thu, 31 Oct 2024 10:07:10 +0000 Subject: [PATCH 1/3] Enable misspell linter & rework findings Fix the mistakes found by the misspell linter: backend_qemu.go:55:56: `usefull` is a misspelling of `useful` (misspell) /* The default cpu is a 32 bit one, which isn't very usefull ^ machine.go:243:39: `especialy` is a misspelling of `especially` (misspell) // Mounts for java VM configuration, especialy security policies ^ Signed-off-by: Christopher Obbard --- .golangci.yml | 2 ++ backend_qemu.go | 2 +- machine.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9d44f1a..8d0890b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,5 +2,7 @@ linters: enable: - errorlint - gofmt + - misspell - stylecheck + - unused - whitespace diff --git a/backend_qemu.go b/backend_qemu.go index a52e2b4..52efa97 100644 --- a/backend_qemu.go +++ b/backend_qemu.go @@ -51,7 +51,7 @@ var qemuMachines = map[Arch]qemuMachine{ binary: "qemu-system-aarch64", console: "ttyAMA0", machine: "virt", - /* The default cpu is a 32 bit one, which isn't very usefull + /* The default cpu is a 32 bit one, which isn't very useful * for 64 bit arm. There is no cpu setting for "minimal" 64 * bit linux capable processor. The only generic setting * is "max", but that can be very slow to emulate. So pick diff --git a/machine.go b/machine.go index 4d6e6c2..44c032c 100644 --- a/machine.go +++ b/machine.go @@ -240,7 +240,7 @@ func NewMachineWithBackend(backendName string) (*Machine, error) { m.AddVolume("/etc/ssl") } - // Mounts for java VM configuration, especialy security policies + // Mounts for java VM configuration, especially security policies matches, _ := filepath.Glob("/etc/java*") for _, path := range matches { stat, err := os.Stat(path) From 2d3ceb7f8991c75c25b8e26de70a50b9af0111c7 Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Thu, 31 Oct 2024 10:09:47 +0000 Subject: [PATCH 2/3] Enable revive linter & rework findings Fix the mistakes found by the revive linter: cmd/fakemachine/main.go:149:10: superfluous-else: if block ends with call to os.Exit function, so drop this else and outdent its block (revive) } else { os.Exit(1) } decompressors_test.go:42:3: increment-decrement: should replace i += 1 with i++ (revive) i += 1 ^ backend_qemu.go:178:38: unused-parameter: parameter 'mount' seems to be unused, consider removing or renaming it as _ (revive) func (b qemuBackend) MountParameters(mount mountPoint) (string, []string) { ^ machine.go:569:3: increment-decrement: should replace i += 1 with i++ (revive) i += 1 ^ Signed-off-by: Christopher Obbard --- .golangci.yml | 1 + backend_qemu.go | 2 +- cmd/fakemachine/main.go | 3 +-- decompressors_test.go | 2 +- machine.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 8d0890b..3802c2c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,6 +3,7 @@ linters: - errorlint - gofmt - misspell + - revive - stylecheck - unused - whitespace diff --git a/backend_qemu.go b/backend_qemu.go index 52efa97..4f63050 100644 --- a/backend_qemu.go +++ b/backend_qemu.go @@ -174,7 +174,7 @@ func (b qemuBackend) JobOutputTTY() string { return "/dev/hvc0" } -func (b qemuBackend) MountParameters(mount mountPoint) (string, []string) { +func (b qemuBackend) MountParameters(_ mountPoint) (string, []string) { return "9p", []string{"trans=virtio", "version=9p2000.L", "cache=loose", "msize=262144"} } diff --git a/cmd/fakemachine/main.go b/cmd/fakemachine/main.go index 91d32eb..9a55419 100644 --- a/cmd/fakemachine/main.go +++ b/cmd/fakemachine/main.go @@ -146,9 +146,8 @@ func main() { var flagsErr *flags.Error if errors.As(err, &flagsErr) && flagsErr.Type == flags.ErrHelp { os.Exit(0) - } else { - os.Exit(1) } + os.Exit(1) } m, err := fakemachine.NewMachineWithBackend(options.Backend) diff --git a/decompressors_test.go b/decompressors_test.go index cd5aab8..da13d94 100644 --- a/decompressors_test.go +++ b/decompressors_test.go @@ -39,7 +39,7 @@ func checkStreamsMatch(t *testing.T, output, check io.Reader) error { i, ochar, cchar) return errors.New("Data mismatch") } - i += 1 + i++ } } diff --git a/machine.go b/machine.go index 44c032c..5ae5bcb 100644 --- a/machine.go +++ b/machine.go @@ -566,7 +566,7 @@ func (m *Machine) generateModulesDep(w *writerhelper.WriterHelper, moddir string deps[j] = deppath } output[i] = fmt.Sprintf("%s: %s", modpath, strings.Join(deps, " ")) - i += 1 + i++ } path := path.Join(moddir, "modules.dep") From 2faab3c17d8b63ddb159464b7920bfab2d12f7da Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Thu, 31 Oct 2024 10:11:44 +0000 Subject: [PATCH 3/3] Enable additional linters These linters seem to be useful. Enable them. Signed-off-by: Christopher Obbard --- .golangci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 3802c2c..c7043bd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,9 +1,14 @@ linters: enable: + - errcheck - errorlint - gofmt + - gosimple + - govet + - ineffassign - misspell - revive + - staticcheck - stylecheck - unused - whitespace