--- /dev/null
+linters:
+ disable-all: true
+ enable:
+ # Enabled by default
+ - deadcode
+ - errcheck
+ - gosimple
+ - govet
+ - ineffassign
+ - staticcheck
+ - structcheck
+ - typecheck
+ - unused
+ - varcheck
+ # Additional checks
+ - bodyclose
+ - contextcheck
+ - durationcheck
+ - errname
+ - exhaustive
+ - exportloopref
+ - gofmt
+ - nilerr
+ - nolintlint
+ - predeclared
+ - rowserrcheck
+ - unconvert
+ - wastedassign
+
+ issues:
+ # Don't hide potential important issues
+ exclude-use-default: false
+
+linters-settings:
+ exhaustive:
+ # "default" is good enough to be exhaustive
+ default-signifies-exhaustive: true
# Additional static checks only run in CI
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./...
+go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
+golangci-lint run
test -z "$(git clean -nd)" # any untracked files left?
make clean
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.Chdir("../testdata/project")
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.Chdir("../testdata/project")
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.Chdir("../testdata/project")
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
sliceToHosts := func(hosts []*Host) *Hosts {
res := &Hosts{
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.Chdir("../testdata/project")
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.Chdir("../testdata/project")
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.Chdir("../testdata/project")
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
var suffix string
// Needs different options in sshd_config
if err != nil {
t.Fatal(err)
}
- defer sshCmd.Process.Kill()
+ defer sshCmd.Process.Kill() //nolint:errcheck
// Wait until SSH server is ready (up to 30 seconds)
for i := 0; i < 30; i++ {
optionSshConfig := flag.String("sshconfig", "",
"`path` to ssh configuration file; used for tests")
- flag.CommandLine.Parse(args[2:])
+ flag.CommandLine.Parse(args[2:]) //nolint:errcheck
level, err := safcm.ParseLogLevel(*optionLog)
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
tests := []struct {
name string
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.Chdir("testdata/project")
if err != nil {
err := host.Dial(conn)
if err != nil {
- conn.Kill()
+ conn.Kill() //nolint:errcheck
return err
}
- defer conn.Kill()
+ defer conn.Kill() //nolint:errcheck
err = l.SyncHostFunc(conn, host)
if err != nil {
optionCreate := flag.Bool("create", false,
"create the path if it does not exist")
- flag.CommandLine.Parse(args[2:])
+ flag.CommandLine.Parse(args[2:]) //nolint:errcheck
if flag.NArg() != 2 {
flag.Usage()
gid = int(x.Gid)
mode = stat.Mode()
}
- stat = nil // prevent accidental use
+ stat = nil //nolint:wastedassign // prevent accidental use
// Check if the expected line is present
var found bool
}
err = unix.Renameat(parentFd, tmpBase, parentFd, baseName)
if err != nil {
- unix.Unlinkat(parentFd, tmpBase, 0)
+ unix.Unlinkat(parentFd, tmpBase, 0) //nolint:errcheck
return nil, err
}
err = unix.Fsync(parentFd)
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.RemoveAll("testdata")
if err != nil {
var logLevel safcm.LogLevel
logFunc := func(level safcm.LogLevel, msg string) {
if logLevel >= level {
- conn.Send(safcm.MsgLog{
+ // Handling errors here is complex and quite verbose.
+ // If it happens the connection is gone anyway so skip
+ // the error handling.
+ conn.Send(safcm.MsgLog{ //nolint:errcheck
Level: level,
Text: msg,
})
}
// Compare file content (if possible)
- switch change.Old.Mode.Type() {
+ switch change.Old.Mode.Type() { //nolint:exhaustive
case 0: // regular file
x, err := io.ReadAll(oldFh)
if err != nil {
err = unix.Fchownat(parentFd, tmpBase, file.Uid, file.Gid,
unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
- unix.Unlinkat(parentFd, tmpBase, 0)
+ unix.Unlinkat(parentFd, tmpBase, 0) //nolint:errcheck
return err
}
// Permissions are irrelevant for symlinks (on most systems)
debugf("renaming %q", slashpath.Join(dir, tmpBase))
err = unix.Renameat(parentFd, tmpBase, parentFd, baseName)
if err != nil {
- unix.Unlinkat(parentFd, tmpBase, 0)
+ unix.Unlinkat(parentFd, tmpBase, 0) //nolint:errcheck
return err
}
// To guarantee durability fsync must be called on a parent directory
_, err = fh.Write(data)
if err != nil {
fh.Close()
- unix.Unlinkat(dirFd, tmpBase, 0)
+ unix.Unlinkat(dirFd, tmpBase, 0) //nolint:errcheck
return "", err
}
// createTempAt() creates the file with 0600
err = fh.Chown(uid, gid)
if err != nil {
fh.Close()
- unix.Unlinkat(dirFd, tmpBase, 0)
+ unix.Unlinkat(dirFd, tmpBase, 0) //nolint:errcheck
return "", err
}
err = fh.Chmod(mode)
if err != nil {
fh.Close()
- unix.Unlinkat(dirFd, tmpBase, 0)
+ unix.Unlinkat(dirFd, tmpBase, 0) //nolint:errcheck
return "", err
}
err = fh.Sync()
if err != nil {
fh.Close()
- unix.Unlinkat(dirFd, tmpBase, 0)
+ unix.Unlinkat(dirFd, tmpBase, 0) //nolint:errcheck
return "", err
}
err = fh.Close()
if err != nil {
- unix.Unlinkat(dirFd, tmpBase, 0)
+ unix.Unlinkat(dirFd, tmpBase, 0) //nolint:errcheck
return "", err
}
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.RemoveAll("testdata")
if err != nil {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(cwd)
+ defer os.Chdir(cwd) //nolint:errcheck
err = os.RemoveAll("testdata")
if err != nil {
c.debugf("Kill: killing connection")
- c.cmd.Process.Kill()
+ c.cmd.Process.Kill() //nolint:errcheck
return c.wait()
}
err = c.dialSSH(stdin, stdout)
if err != nil {
- c.Kill()
+ c.Kill() //nolint:errcheck
return err
}
c.conn = safcm.NewGobConn(stdout, stdin)