Skip to content

Commit edeb9bb

Browse files
authored
fix: appease linter on darwin (#11154)
Fixing up some linting errors that show up on Darwin, but not in CI.
1 parent 2883cad commit edeb9bb

8 files changed

+20
-11
lines changed

agent/agentproc/proc_other.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import (
77
"github.com/spf13/afero"
88
)
99

10-
func (p *Process) Niceness(sc Syscaller) (int, error) {
10+
func (*Process) Niceness(Syscaller) (int, error) {
1111
return 0, errUnimplemented
1212
}
1313

14-
func (p *Process) SetNiceness(sc Syscaller, score int) error {
14+
func (*Process) SetNiceness(Syscaller, int) error {
1515
return errUnimplemented
1616
}
1717

18-
func (p *Process) Cmd() string {
18+
func (*Process) Cmd() string {
1919
return ""
2020
}
2121

22-
func List(fs afero.Fs, syscaller Syscaller) ([]*Process, error) {
22+
func List(afero.Fs, Syscaller) ([]*Process, error) {
2323
return nil, errUnimplemented
2424
}

agent/agentproc/syscaller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Syscaller interface {
1010
Kill(pid int32, sig syscall.Signal) error
1111
}
1212

13+
// nolint: unused // used on some but no all platforms
1314
const defaultProcDir = "/proc"
1415

1516
type Process struct {

agent/agentproc/syscaller_other.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ var errUnimplemented = xerrors.New("unimplemented")
1717

1818
type nopSyscaller struct{}
1919

20-
func (nopSyscaller) SetPriority(pid int32, priority int) error {
20+
func (nopSyscaller) SetPriority(int32, int) error {
2121
return errUnimplemented
2222
}
2323

24-
func (nopSyscaller) GetPriority(pid int32) (int, error) {
24+
func (nopSyscaller) GetPriority(int32) (int, error) {
2525
return 0, errUnimplemented
2626
}
2727

28-
func (nopSyscaller) Kill(pid int32, sig syscall.Signal) error {
28+
func (nopSyscaller) Kill(int32, syscall.Signal) error {
2929
return errUnimplemented
3030
}

agent/agentssh/jetbrainstrack.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
"strings"
55
"sync"
66

7-
"cdr.dev/slog"
87
"github.com/gliderlabs/ssh"
98
"go.uber.org/atomic"
109
gossh "golang.org/x/crypto/ssh"
10+
11+
"cdr.dev/slog"
1112
)
1213

1314
// localForwardChannelData is copied from the ssh package.

agent/agentssh/portinspection_unsupported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package agentssh
44

5-
func getListeningPortProcessCmdline(port uint32) (string, error) {
5+
func getListeningPortProcessCmdline(uint32) (string, error) {
66
// We are not worrying about other platforms at the moment because Gateway
77
// only supports Linux anyway.
88
return "", nil

agent/api.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ type listeningPortsHandler struct {
4444
ignorePorts map[int]string
4545
cacheDuration time.Duration
4646

47-
mut sync.Mutex
47+
//nolint: unused // used on some but not all platforms
48+
mut sync.Mutex
49+
//nolint: unused // used on some but not all platforms
4850
ports []codersdk.WorkspaceAgentListeningPort
51+
//nolint: unused // used on some but not all platforms
4952
mtime time.Time
5053
}
5154

agent/ports_unsupported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package agent
44

55
import "github.com/coder/coder/v2/codersdk"
66

7-
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
7+
func (*listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
88
// Can't scan for ports on non-linux or non-windows_amd64 systems at the
99
// moment. The UI will not show any "no ports found" message to the user, so
1010
// the user won't suspect a thing.

agent/usershell/usershell_darwin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import (
1313
func Get(username string) (string, error) {
1414
// This command will output "UserShell: /bin/zsh" if successful, we
1515
// can ignore the error since we have fallback behavior.
16+
if !filepath.IsLocal(username) {
17+
return "", xerrors.Errorf("username is nonlocal path: %s", username)
18+
}
19+
//nolint: gosec // input checked above
1620
out, _ := exec.Command("dscl", ".", "-read", filepath.Join("/Users", username), "UserShell").Output()
1721
s, ok := strings.CutPrefix(string(out), "UserShell: ")
1822
if ok {

0 commit comments

Comments
 (0)