Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Jun 5, 2024
1 parent 8e50fb6 commit 755b420
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .golangci-soft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ linters:
- goconst
- godot
- godox
- gomnd
- mnd
- gomoddirectives
- goprintffuncname
- misspell
Expand Down
2 changes: 1 addition & 1 deletion blocking/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (r Reader) Read(data []byte) (int, error) {
return n, err
}
// 10ms is not that much a magic number, more like a guess.
//nolint:gomnd
//nolint:mnd
time.Sleep(10 * time.Millisecond)
}
}
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,5 @@ func (c closers) close() {
func resetPty(w io.Writer) {
fmt.Fprint(w, termenv.CSI+termenv.ExitAltScreenSeq)
fmt.Fprint(w, termenv.CSI+termenv.ResetSeq+"m")
fmt.Fprintf(w, termenv.CSI+termenv.EraseDisplaySeq, 2) //nolint:gomnd
fmt.Fprintf(w, termenv.CSI+termenv.EraseDisplaySeq, 2) //nolint:mnd

Check failure on line 115 in client.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `fmt.Fprintf` is not checked (errcheck)
}
2 changes: 1 addition & 1 deletion client_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func parsePrivateKey(path string, password []byte) (gossh.AuthMethod, error) {
// if the host does not exist there, it adds it so its available next time, as plain old `ssh` does.
func hostKeyCallback(e *Endpoint, path string) gossh.HostKeyCallback {
return func(hostname string, remote net.Addr, key gossh.PublicKey) error {
kh, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) //nolint:gomnd
kh, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) //nolint:mnd
if err != nil {
return fmt.Errorf("failed to open known_hosts: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/wishlist/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ It's also possible to serve the TUI over SSH using the server command.
if err != nil {
return fmt.Errorf("could not create log file: %w", err)
}
f, err := os.OpenFile(filepath.Join(cache, "wishlist.log"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644) //nolint:gomnd
f, err := os.OpenFile(filepath.Join(cache, "wishlist.log"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644) //nolint:mnd
if err != nil {
return err //nolint: wrapcheck
}
Expand Down Expand Up @@ -174,7 +174,6 @@ var serverCmd = &cobra.Command{
}

config.Factory = func(e wishlist.Endpoint) (*ssh.Server, error) {
//nolint:wrapcheck
return wish.NewServer(
wish.WithAddress(e.Address),
wish.WithHostKeyPath(".wishlist/server_ed25519"),
Expand Down
2 changes: 1 addition & 1 deletion jump.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func splitJump(jump string) (string, string) {
switch len(parts) {
case 1:
return "", ensureJumpPort(parts[0]) // jump with no username
case 2: //nolint: gomnd
case 2: //nolint: mnd
return parts[0], ensureJumpPort(parts[1]) // jump with user and host
default:
return strings.Join(parts[0:len(parts)-1], "@"), ensureJumpPort(parts[len(parts)-1])
Expand Down
8 changes: 4 additions & 4 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Serve(config *Config) error {
signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

if config.Port == 0 {
port, err := getFirstOpenPort(config.Listen, 22, 2222) //nolint:gomnd
port, err := getFirstOpenPort(config.Listen, 22, 2222) //nolint:mnd
if err != nil {
return fmt.Errorf("could not get an open port and none was provided: %w", err)
}
Expand All @@ -37,7 +37,7 @@ func Serve(config *Config) error {
config.Listen = "0.0.0.0"
}

if err := os.MkdirAll(".wishlist", 0o700); err != nil { //nolint:gomnd
if err := os.MkdirAll(".wishlist", 0o700); err != nil { //nolint:mnd
return fmt.Errorf("could not create .wishlist dir: %w", err)
}

Expand Down Expand Up @@ -114,9 +114,9 @@ func listenAndServe(config *Config, endpoint Endpoint) (func() error, error) {
}()

return func() error {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) //nolint:gomnd
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) //nolint:mnd
defer func() { cancel() }()
return s.Shutdown(ctx) //nolint:wrapcheck
return s.Shutdown(ctx)
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions sshconfig/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ func parseInternal(r NamedReader) (*hostinfoMap, error) {
continue
}

parts := strings.SplitN(node, " ", 2) //nolint:gomnd
if len(parts) != 2 { //nolint:gomnd
parts := strings.SplitN(node, " ", 2) //nolint:mnd
if len(parts) != 2 { //nolint:mnd
return nil, fmt.Errorf("invalid node on app %q: %q", name, node)
}

Expand Down
2 changes: 1 addition & 1 deletion styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package wishlist

import "github.com/charmbracelet/lipgloss"

//nolint:gomnd
//nolint:mnd
func makeStyles(r *lipgloss.Renderer) styles {
return styles{
Logo: r.NewStyle().
Expand Down

0 comments on commit 755b420

Please sign in to comment.