1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-09 13:47:11 +02:00

Appease linter

This commit is contained in:
Jesse Duffield 2023-08-02 08:21:55 +10:00
parent df0c3b3ea8
commit c92ed07082
6 changed files with 21 additions and 20 deletions

View File

@ -3,7 +3,6 @@ package oscommands
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
)
@ -106,7 +105,7 @@ func CopyDir(src string, dst string) (err error) {
return //nolint: nakedret
}
entries, err := ioutil.ReadDir(src)
entries, err := os.ReadDir(src)
if err != nil {
return //nolint: nakedret
}
@ -121,8 +120,14 @@ func CopyDir(src string, dst string) (err error) {
return //nolint: nakedret
}
} else {
var info os.FileInfo
info, err = entry.Info()
if err != nil {
return //nolint: nakedret
}
// Skip symlinks.
if entry.Mode()&os.ModeSymlink != 0 {
if info.Mode()&os.ModeSymlink != 0 {
continue
}

View File

@ -1,18 +1,17 @@
package config
import (
"io/ioutil"
"os"
"strings"
)
func isWSL() bool {
data, err := ioutil.ReadFile("/proc/sys/kernel/osrelease")
data, err := os.ReadFile("/proc/sys/kernel/osrelease")
return err == nil && strings.Contains(string(data), "microsoft")
}
func isContainer() bool {
data, err := ioutil.ReadFile("/proc/1/cgroup")
data, err := os.ReadFile("/proc/1/cgroup")
if strings.Contains(string(data), "docker") ||
strings.Contains(string(data), "/lxc/") ||

View File

@ -195,7 +195,7 @@ func getExplodeImage(width int, height int, frame int, max int) string {
var buf bytes.Buffer
// Initialize RNG seed
rand.Seed(time.Now().UnixNano())
random := rand.New(rand.NewSource(time.Now().UnixNano()))
// calculate the center of explosion
centerX, centerY := width/2, height/2
@ -223,9 +223,9 @@ func getExplodeImage(width int, height int, frame int, max int) string {
// if distance is less than radius and greater than innerRadius, draw explosion char
if distance <= radius && distance >= innerRadius {
// Make placement random and less likely as explosion progresses
if rand.Float64() > progress {
if random.Float64() > progress {
// Pick a random explosion char
char := explosionChars[rand.Intn(len(explosionChars))]
char := explosionChars[random.Intn(len(explosionChars))]
buf.WriteRune(char)
} else {
buf.WriteRune(' ')

View File

@ -10,7 +10,6 @@ import (
"bytes"
"errors"
"io"
"io/ioutil"
"os"
"os/exec"
"testing"
@ -82,7 +81,7 @@ func runCmdHeadless(cmd *exec.Cmd) error {
return err
}
_, _ = io.Copy(ioutil.Discard, f)
_, _ = io.Copy(io.Discard, f)
if cmd.Wait() != nil {
// return an error with the stderr output

View File

@ -2,7 +2,6 @@ package components
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@ -222,7 +221,7 @@ func findOrCreateDir(path string) {
func deleteAndRecreateEmptyDir(path string) {
// remove contents of integration test directory
dir, err := ioutil.ReadDir(path)
dir, err := os.ReadDir(path)
if err != nil {
if os.IsNotExist(err) {
err = os.Mkdir(path, 0o777)

View File

@ -12,7 +12,6 @@ import (
"fmt"
"go/format"
"io/fs"
"io/ioutil"
"os"
"strings"
@ -26,19 +25,19 @@ func main() {
if err != nil {
panic(err)
}
if err := ioutil.WriteFile("test_list.go", formattedCode, 0o644); err != nil {
if err := os.WriteFile("test_list.go", formattedCode, 0o644); err != nil {
panic(err)
}
}
func generateCode() []byte {
// traverse parent directory to get all subling directories
directories, err := ioutil.ReadDir("../tests")
directories, err := os.ReadDir("../tests")
if err != nil {
panic(err)
}
directories = lo.Filter(directories, func(file os.FileInfo, _ int) bool {
directories = lo.Filter(directories, func(file fs.DirEntry, _ int) bool {
// 'shared' is a special folder containing shared test code so we
// ignore it here
return file.IsDir() && file.Name() != "shared"
@ -62,8 +61,8 @@ func generateCode() []byte {
return buf.Bytes()
}
func appendDirTests(dir fs.FileInfo, buf *bytes.Buffer) {
files, err := ioutil.ReadDir(fmt.Sprintf("../tests/%s", dir.Name()))
func appendDirTests(dir fs.DirEntry, buf *bytes.Buffer) {
files, err := os.ReadDir(fmt.Sprintf("../tests/%s", dir.Name()))
if err != nil {
panic(err)
}
@ -77,7 +76,7 @@ func appendDirTests(dir fs.FileInfo, buf *bytes.Buffer) {
strings.TrimSuffix(file.Name(), ".go"),
)
fileContents, err := ioutil.ReadFile(fmt.Sprintf("../tests/%s/%s", dir.Name(), file.Name()))
fileContents, err := os.ReadFile(fmt.Sprintf("../tests/%s/%s", dir.Name(), file.Name()))
if err != nil {
panic(err)
}