ci(lint): fix all lint issues on `main` (#1342)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Andrey Nering · committed by GitHub · parent bf1216d · Browse files · 7 files·+38 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+38 added−9 removed
- other:+38 added−9 removed
Provenance
- Commit
b224818- Tree
ab41efc- Author
Andrey Nering <andreynering@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
bf1216d
7 files changed+38 added−9 removed
modified:inputreader_other.go+6 added-1 removed
2 unmodified lines3 4 package tea5 6 import (7+ "fmt"8 "io"9 10 "github.com/muesli/cancelreader"11 )12 13 func newInputReader(r io.Reader, _ bool) (cancelreader.CancelReader, error) {13- return cancelreader.NewReader(r)14+ cr, err := cancelreader.NewReader(r)15+ if err != nil {16+ return nil, fmt.Errorf("bubbletea: error creating cancel reader: %w", err)17+ }18+ return cr, nil19 }modified:key_sequences.go+2 added-3 removed
117 unmodified lines118 return true, inputLen, KeyMsg(k)119 }120 121 // detectReportFocus detects a focus report sequence.122-// nolint: gomnd122 func detectReportFocus(input []byte) (hasRF bool, width int, msg Msg) {123 switch {124 case bytes.Equal(input, []byte("\x1b[I")):126- return true, 3, FocusMsg{}125+ return true, 3, FocusMsg{} //nolint:mnd126 case bytes.Equal(input, []byte("\x1b[O")):128- return true, 3, BlurMsg{}127+ return true, 3, BlurMsg{} //nolint:mnd128 }129 return false, 0, nil130 }modified:key.go+1 added-1 removed
620 unmodified lines621 return mouseEventX10Len, MouseMsg(parseX10MouseEvent(b))622 case '<':623 if matchIndices := mouseSGRRegex.FindSubmatchIndex(b[3:]); matchIndices != nil {624 // SGR mouse events length is the length of the match plus the length of the escape sequence625- mouseEventSGRLen := matchIndices[1] + 3 //nolint:gomnd625+ mouseEventSGRLen := matchIndices[1] + 3 //nolint:mnd626 return mouseEventSGRLen, MouseMsg(parseSGRMouseEvent(b))627 }628 }629 }86 unmodified linesmodified:logging.go+1 added-1 removed
31 unmodified lines32 }33 34 // LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter.35 func LogToFileWith(path string, prefix string, log LogOptionsSetter) (*os.File, error) {36- f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) //nolint:gomnd36+ f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) //nolint:mnd37 if err != nil {38 return nil, fmt.Errorf("error opening file for logging: %w", err)39 }40 log.SetOutput(f)13 unmodified linesmodified:mouse.go+1 added-1 removed
170 unmodified lines171 // https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates172 func parseSGRMouseEvent(buf []byte) MouseEvent {173 str := string(buf[3:])174 matches := mouseSGRRegex.FindStringSubmatch(str)175- if len(matches) != 5 { //nolint:gomnd175+ if len(matches) != 5 { //nolint:mnd176 // Unreachable, we already checked the regex in `detectOneMsg`.177 panic("invalid mouse event")178 }179 129 unmodified linesadded:Taskfile.yaml+25 added
12345678910111213141516171819202122232425# https://taskfile.dev
version: '3'
tasks: lint:all: desc: Run all linters cmds: - task: lint - task: lint:soft
lint: desc: Run base linters cmds: - golangci-lint run
lint:soft: desc: Run soft linters cmds: - golangci-lint run --config=.golangci-soft.yml
test: desc: Run tests cmds: - go test ./... {{.CLI_ARGS}}modified:tty.go+2 added-2 removed
50 unmodified lines51 if p.renderer.altScreen() {52 p.renderer.exitAltScreen()53 54 // give the terminal a moment to catch up55- time.Sleep(time.Millisecond * 10) //nolint:gomnd55+ time.Sleep(time.Millisecond * 10) //nolint:mnd56 }57 }58 59 return p.restoreInput()48 unmodified lines108 // waitForReadLoop waits for the cancelReader to finish its read loop.109 func (p *Program) waitForReadLoop() {110 select {111 case <-p.readLoopDone:112- case <-time.After(500 * time.Millisecond): //nolint:gomnd112+ case <-time.After(500 * time.Millisecond): //nolint:mnd113 // The read loop hangs, which means the input114 // cancelReader's cancel function has returned true even115 // though it was not able to cancel the read.116 }25 unmodified lines