Add golangci-lint gate and fix its findings
Configure golangci-lint v2 for the whole tree (brlapi/duckdb build tags, curated linters, documented exclusions) and resolve what it reports: dead code, wrapped-error comparisons and %w wrapping, unclosed websocket handshake bodies, staticcheck SA/S items, ineffectual assignments, and explicit _ = discards for best-effort teardown errors. Document the gate in CONTRIBUTING and AGENTS.
This commit is contained in:
1 parent
b03cb8917d
commit
0459fb8e50
43 files changed
+166
-112
No files matched your search
@@ -111,7 +111,7 @@ func (worker *brailleWorker) session(ctx context.Context) (connectedFor time.Dur
|
||||
if detail := strings.TrimSpace(stderr.String()); detail != "" {
|
||||
result = fmt.Errorf("%w: %s", result, detail)
|
||||
} else if waitErr != nil {
|
||||
result = fmt.Errorf("%w: %v", result, waitErr)
|
||||
result = fmt.Errorf("%w: %w", result, waitErr)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -91,7 +91,7 @@ func watch_clipboard(ctx context.Context, live *liveSettings, gate *focusGate, s
|
||||
if err := command.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { cancel(); in.Close(); out.Close(); command.Wait() }()
|
||||
defer func() { cancel(); in.Close(); out.Close(); _ = command.Wait() }()
|
||||
changes := make(chan clipboard.TextChange, 128)
|
||||
failures := make(chan error, 1)
|
||||
readerDone := make(chan struct{})
|
||||
|
||||
@@ -76,23 +76,23 @@ func (speaker *echoSpeaker) UpdateConfiguration(ctx context.Context, settings co
|
||||
client := speech.NewWithSettings(speaker.socket, values)
|
||||
candidates[kind] = client
|
||||
if err := client.Connect(ctx); err != nil {
|
||||
closeClients(candidates)
|
||||
_ = closeClients(candidates)
|
||||
return err
|
||||
}
|
||||
}
|
||||
speaker.mu.Lock()
|
||||
defer speaker.mu.Unlock()
|
||||
if speaker.closed {
|
||||
closeClients(candidates)
|
||||
_ = closeClients(candidates)
|
||||
return errors.New("speech is closed")
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
closeClients(candidates)
|
||||
_ = closeClients(candidates)
|
||||
return err
|
||||
}
|
||||
for _, client := range speaker.voices {
|
||||
if err := client.Cancel(ctx); err != nil {
|
||||
closeClients(candidates)
|
||||
_ = closeClients(candidates)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,10 +270,6 @@ func (presenter *eventPresenter) speak(event atspi.Event, capturedIntent ...inpu
|
||||
}
|
||||
}
|
||||
|
||||
func presentationFallbackText(event atspi.Event, options presentation.Options) string {
|
||||
return presentationFallbackSpeech(event, options).Text
|
||||
}
|
||||
|
||||
func presentationFallbackSpeech(event atspi.Event, options presentation.Options) presentation.Speech {
|
||||
if options.RoleSoundPresentation != "sound_only" {
|
||||
return presentation.Speech{}
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ package app
|
||||
import (
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
@@ -31,7 +32,7 @@ func i3ModeName(name string, markup bool) string {
|
||||
var text strings.Builder
|
||||
for {
|
||||
token, err := decoder.Token()
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
+17
-17
@@ -187,7 +187,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
documentList = review.DocumentListSnapshot{}
|
||||
return closeErr
|
||||
}
|
||||
defer func() { finish(internalUIResult{Cancelled: true}) }()
|
||||
defer func() { _ = finish(internalUIResult{Cancelled: true}) }()
|
||||
// Native capture can be revoked by lock, focus change or handoff without a
|
||||
// command being delivered (secure input deliberately drains command queues).
|
||||
ticker := time.NewTicker(50 * time.Millisecond)
|
||||
@@ -197,10 +197,10 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-requestDone:
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
case <-ticker.C:
|
||||
if sessionID != 0 && ui.keys.InternalUISession() != sessionID {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
}
|
||||
case notice := <-ui.notices:
|
||||
if sessionID != 0 && requestDone == notice.ctx.Done() && ui.keys.InternalUISession() == sessionID {
|
||||
@@ -245,7 +245,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
}
|
||||
cancel()
|
||||
if sessionID == 0 || ui.keys.InternalUISession() != sessionID {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
continue
|
||||
}
|
||||
if err != nil || session == nil {
|
||||
@@ -253,7 +253,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
if err != nil {
|
||||
message = "Browser list unavailable"
|
||||
}
|
||||
finish(internalUIResult{Err: err})
|
||||
_ = finish(internalUIResult{Err: err})
|
||||
ui.browserListMessage(message)
|
||||
continue
|
||||
}
|
||||
@@ -269,13 +269,13 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
sessionID, err = ui.keys.BeginInternalUI(lookupCtx)
|
||||
cancel()
|
||||
if err != nil || sessionID == 0 || ui.keys.InternalUISession() != sessionID {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
ui.emoji_message("Emoji Menu unavailable")
|
||||
continue
|
||||
}
|
||||
session, err = emoji.NewSession(copyEmoji)
|
||||
if err != nil {
|
||||
finish(internalUIResult{Err: err})
|
||||
_ = finish(internalUIResult{Err: err})
|
||||
continue
|
||||
}
|
||||
emojiActive = true
|
||||
@@ -284,11 +284,11 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
}
|
||||
if event.Command == input.ShowActions {
|
||||
if sessionID != 0 {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
}
|
||||
sessionID = event.UISession
|
||||
if sessionID == 0 || ui.actions == nil || ui.interest == nil {
|
||||
finish(internalUIResult{Err: errors.New("actions unavailable")})
|
||||
_ = finish(internalUIResult{Err: errors.New("actions unavailable")})
|
||||
ui.speech.Enqueue(speechRequest{Text: "Actions unavailable", Role: "system", Cause: "internal-ui"})
|
||||
if ui.braille != nil {
|
||||
ui.braille.EnqueueMessage("Actions unavailable")
|
||||
@@ -303,11 +303,11 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
}
|
||||
cancel()
|
||||
if ui.keys.InternalUISession() != sessionID {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
continue
|
||||
}
|
||||
if err != nil || len(actions.Actions) == 0 {
|
||||
finish(internalUIResult{Err: err})
|
||||
_ = finish(internalUIResult{Err: err})
|
||||
message := "No actions found"
|
||||
if err != nil {
|
||||
message = "Actions unavailable"
|
||||
@@ -324,7 +324,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
}
|
||||
session, err = interaction.NewSession(interaction.Form{Title: "Actions", Elements: []interaction.Element{{ID: "actions", Label: "Actions", Kind: interaction.List, Items: items}}})
|
||||
if err != nil {
|
||||
finish(internalUIResult{Err: err})
|
||||
_ = finish(internalUIResult{Err: err})
|
||||
continue
|
||||
}
|
||||
target = actions.Target
|
||||
@@ -335,17 +335,17 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
if event.Command == input.InternalUIDismiss {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
continue
|
||||
}
|
||||
key := internal_ui_event(event)
|
||||
effect := session.Handle(key)
|
||||
if effect.Cancelled {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
continue
|
||||
}
|
||||
if ui.keys.InternalUISession() != sessionID {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
continue
|
||||
}
|
||||
if effect.Paste {
|
||||
@@ -353,7 +353,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
text, err := read_internal_clipboard(clipboardCtx)
|
||||
cancel()
|
||||
if ui.keys.InternalUISession() != sessionID {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
continue
|
||||
}
|
||||
if err == nil {
|
||||
@@ -367,7 +367,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
||||
err := (xclipOCRCopier{}).Copy(copyCtx, *effect.Copy)
|
||||
cancel()
|
||||
if ui.keys.InternalUISession() != sessionID {
|
||||
finish(internalUIResult{Cancelled: true})
|
||||
_ = finish(internalUIResult{Cancelled: true})
|
||||
continue
|
||||
}
|
||||
message := "Copied"
|
||||
|
||||
@@ -129,13 +129,13 @@ func TestNativeBrowserNamedLinks(t *testing.T) {
|
||||
if _, err := cursor.SyncFocus(ctx, labelOnly.ID()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, want := range []rune("xample Info Page.") {
|
||||
for _, want := range "xample Info Page." {
|
||||
move, err := cursor.MoveCaret(ctx, adapter, review.CaretNextCharacter)
|
||||
if err != nil || !move.Moved || move.Text != string(want) {
|
||||
t.Fatalf("label-only character: %+v, %v; want %q", move, err, want)
|
||||
}
|
||||
}
|
||||
for _, want := range []rune("egaP ofnI elpmaxE") {
|
||||
for _, want := range "egaP ofnI elpmaxE" {
|
||||
move, err := cursor.MoveCaret(ctx, adapter, review.CaretPreviousCharacter)
|
||||
if err != nil || !move.Moved || move.Text != string(want) {
|
||||
t.Fatalf("reverse label-only character: %+v, %v; want %q", move, err, want)
|
||||
|
||||
@@ -270,7 +270,7 @@ func (session *ocrSession) refresh_locked(automatic bool) {
|
||||
// interruption are observed without waiting on the speech worker.
|
||||
if automatic && session.readAllContext != nil && session.readAllContext.Err() == nil {
|
||||
select {
|
||||
case <-session.readAllDone:
|
||||
case _ = <-session.readAllDone:
|
||||
default:
|
||||
session.schedule_refresh_locked()
|
||||
return
|
||||
|
||||
@@ -85,10 +85,14 @@ func (worker *preferencesWorker) window(ctx context.Context) (result error) {
|
||||
result = fmt.Errorf("preferences helper exited: %w", waitErr)
|
||||
}
|
||||
if result != nil {
|
||||
helperExit := "<nil>"
|
||||
if waitErr != nil {
|
||||
helperExit = waitErr.Error()
|
||||
}
|
||||
if detail := diagnostic.String(); detail != "" {
|
||||
result = fmt.Errorf("%w (helper exit: %v; stderr: %s)", result, waitErr, detail)
|
||||
result = fmt.Errorf("%w (helper exit: %s; stderr: %s)", result, helperExit, detail)
|
||||
} else {
|
||||
result = fmt.Errorf("%w (helper exit: %v)", result, waitErr)
|
||||
result = fmt.Errorf("%w (helper exit: %s)", result, helperExit)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -147,7 +147,7 @@ func run_remote_speech_stream(ctx context.Context, incoming <-chan tentacle.Remo
|
||||
defer func() {
|
||||
interrupt()
|
||||
if active != nil {
|
||||
<-finished // Renderer owns cleanup; no replacement can overtake it.
|
||||
_ = <-finished // Renderer owns cleanup; no replacement can overtake it.
|
||||
release(active)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
@@ -222,7 +223,7 @@ func (w *speechHistoryWindows) window(ctx context.Context, mode string, updates
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case err := <-readDone:
|
||||
if err == nil || err == io.EOF {
|
||||
if err == nil || errors.Is(err, io.EOF) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -28,8 +28,8 @@ func readClipboardTarget(ctx context.Context, target string) (string, error) {
|
||||
}
|
||||
data, readErr := io.ReadAll(io.LimitReader(pipe, 8193))
|
||||
if readErr != nil || len(data) > 8192 {
|
||||
command.Process.Kill()
|
||||
command.Wait()
|
||||
_ = command.Process.Kill()
|
||||
_ = command.Wait()
|
||||
return "", errors.New("clipboard too large")
|
||||
}
|
||||
err = command.Wait()
|
||||
@@ -94,7 +94,7 @@ func clipboardPNG(ctx context.Context) (tentaclewire.Item, error) {
|
||||
keep := false
|
||||
defer func() {
|
||||
if !keep {
|
||||
os.RemoveAll(directory)
|
||||
_ = os.RemoveAll(directory)
|
||||
}
|
||||
}()
|
||||
path := filepath.Join(directory, "clipboard.png")
|
||||
@@ -114,8 +114,8 @@ func clipboardPNG(ctx context.Context) (tentaclewire.Item, error) {
|
||||
}
|
||||
count, copyErr := io.Copy(file, io.LimitReader(pipe, 32*1024*1024+1))
|
||||
if copyErr != nil || count > 32*1024*1024 {
|
||||
command.Process.Kill()
|
||||
command.Wait()
|
||||
_ = command.Process.Kill()
|
||||
_ = command.Wait()
|
||||
return tentaclewire.Item{}, errors.New("clipboard image too large")
|
||||
}
|
||||
if err = command.Wait(); err != nil {
|
||||
|
||||
@@ -56,13 +56,13 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
if len(command.session.RemoteGrants()) != 0 && cleanupNext != "" && command.session.OutputContext().Err() == nil {
|
||||
cleanupCtx, stopCleanup := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer stopCleanup()
|
||||
runtime.callInteraction(cleanupCtx, command, cleanupNext, tentaclewire.Submission{Cancelled: true})
|
||||
_, _ = runtime.callInteraction(cleanupCtx, command, cleanupNext, tentaclewire.Submission{Cancelled: true})
|
||||
}
|
||||
}()
|
||||
var temporaryFiles []string
|
||||
defer func() {
|
||||
for _, path := range temporaryFiles {
|
||||
os.RemoveAll(filepath.Dir(path))
|
||||
_ = os.RemoveAll(filepath.Dir(path))
|
||||
}
|
||||
}()
|
||||
for transitions := 0; transitions < 1024 && ctx.Err() == nil; transitions++ {
|
||||
@@ -147,7 +147,7 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
var submission tentaclewire.Submission
|
||||
if value.Form != nil {
|
||||
if runtime.forms == nil {
|
||||
runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||
_, _ = runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||
cleanupNext = ""
|
||||
runtime.report("Internal UI unavailable.")
|
||||
return
|
||||
@@ -156,7 +156,7 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
replies, openErr := runtime.open_tentacle_form(formCtx, command, *value.Form)
|
||||
if openErr != nil {
|
||||
closeForm()
|
||||
runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||
_, _ = runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||
cleanupNext = ""
|
||||
runtime.report("Internal UI unavailable.")
|
||||
return
|
||||
|
||||
@@ -138,7 +138,7 @@ func (runtime *tentacleRuntime) Manage(ctx context.Context, request tentacle.Man
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer prepared.Discard()
|
||||
defer func() { _ = prepared.Discard() }()
|
||||
operation := "add"
|
||||
if request.Action == "upgrade" {
|
||||
operation = "update"
|
||||
|
||||
@@ -205,7 +205,7 @@ func TestWineReviewEmptyFocusCanReachOutput(t *testing.T) {
|
||||
if err = cursor.Refresh(context.Background(), tree, w.Focus()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, _, err = cursor.Read(review.Line, 0)
|
||||
_, _, _ = cursor.Read(review.Line, 0)
|
||||
position, _, err := cursor.Read(review.Line, 1)
|
||||
if err != nil || position.Text != "alpha beta!" {
|
||||
t.Fatalf("empty anchor: %+v %v", position, err)
|
||||
|
||||
Reference in new issue
Block a user