]> git.giacomolli.uk - onechat/commitdiff
Check Go names and declarations with revive
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 20:54:59 +0000 (17:54 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 21:28:42 +0000 (18:28 -0300)
The lint check applies revive to Go declarations and common style rules.
Unused callback and interface parameters have blank names, and the
command has a package comment for its entry points.

15 files changed:
.golangci.yml
build_run_test.go
compactor_test.go
daemon_test.go
main.go
model_fake_helper_test.go
model_test.go
subagent_run_test.go
telegram_api_test.go
telegram_test.go
turn_test.go
view_test.go
whatsapp_fake_helper_test.go
whatsapp_inbox_test.go
whatsapp_test.go

index 1a7a596e15cbc0bc972760258c61626ad2d4f0ab..58a78b4c823a256468182eee56ffd0ce06e993a0 100644 (file)
@@ -6,3 +6,4 @@ linters:
     - errorlint
     - gocritic
     - testifylint
     - errorlint
     - gocritic
     - testifylint
+    - revive
index 64d0d867790d569795f113895599b6ee868c08ce..aef89225211dca1b4b908c0bfd4e93b786ffa202 100644 (file)
@@ -114,7 +114,7 @@ func TestBuildRunWaitsOnlyBeforeUserMessages(t *testing.T) {
        var mutex sync.Mutex
        running, most := 0, 0
        server := newModelFake(t)
        var mutex sync.Mutex
        running, most := 0, 0
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                mutex.Lock()
                running++
                most = max(most, running)
                mutex.Lock()
                running++
                most = max(most, running)
index 8bdf45c68d7fcd308a8ad7a173e0deb81908641c..f4c51f4af12621e3b64ffd853955a1afa119f773 100644 (file)
@@ -209,7 +209,7 @@ func TestCompactorFailsWithoutALine(t *testing.T) {
        }{
                {
                        name: "failed call",
        }{
                {
                        name: "failed call",
-                       reply: func(w http.ResponseWriter, call ModelFakeCall) {
+                       reply: func(w http.ResponseWriter, _ ModelFakeCall) {
                                w.WriteHeader(http.StatusInternalServerError)
                                _, _ = io.WriteString(w, "down")
                        },
                                w.WriteHeader(http.StatusInternalServerError)
                                _, _ = io.WriteString(w, "down")
                        },
@@ -217,7 +217,7 @@ func TestCompactorFailsWithoutALine(t *testing.T) {
                },
                {
                        name: "tool call and no text",
                },
                {
                        name: "tool call and no text",
-                       reply: func(w http.ResponseWriter, call ModelFakeCall) {
+                       reply: func(w http.ResponseWriter, _ ModelFakeCall) {
                                modelWriteEvents(w, modelCompletedEvent([]any{map[string]any{"type": "function_call", "name": "zoom", "arguments": "{}"}}, 100, 0, 5))
                        },
                        want: "no line",
                                modelWriteEvents(w, modelCompletedEvent([]any{map[string]any{"type": "function_call", "name": "zoom", "arguments": "{}"}}, 100, 0, 5))
                        },
                        want: "no line",
index 9f457927124674c505a377fdc6b264c1630be245..6a8cd3e5337b07c14e17a7d3125668f2704e7e54 100644 (file)
@@ -50,7 +50,7 @@ func TestStopInterruptsTheTurn(t *testing.T) {
                close(release)
        })
 
                close(release)
        })
 
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(_ http.ResponseWriter, _ ModelFakeCall) {
                close(arrived)
                <-release
        }
                close(arrived)
                <-release
        }
diff --git a/main.go b/main.go
index f4f09c47ba7f78919630a61b11b1899216715d31..ac4afe48d19185265c0053741acb4442a2734aa6 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,3 +1,4 @@
+// Command onechat runs the agent daemon and its terminal client.
 package main
 
 import (
 package main
 
 import (
index e3fb4c6f8caf156831e6751305545c5fb966ae67..08c4732a2c9bd80147815de738b469b1b2eb165a 100644 (file)
@@ -81,7 +81,7 @@ func newModelFake(t *testing.T) *ModelFake {
        t.Helper()
 
        f := &ModelFake{
        t.Helper()
 
        f := &ModelFake{
-               reply: func(w http.ResponseWriter, call ModelFakeCall) {
+               reply: func(w http.ResponseWriter, _ ModelFakeCall) {
                        modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("a line")}, 100, 0, 5))
                },
        }
                        modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("a line")}, 100, 0, 5))
                },
        }
index 11a7d00bcddf7ad8f68373675a8428111fa81fb4..e9321073ab4e753fa7a37a76e67b49a5733a28ff 100644 (file)
@@ -104,7 +104,7 @@ func TestClientSendsTheSessionHeaderToChatGPT(t *testing.T) {
 
 func TestClientReadsTheStream(t *testing.T) {
        server := newModelFake(t)
 
 func TestClientReadsTheStream(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w,
                        map[string]any{"type": "response.created", "response": map[string]any{}},
                        map[string]any{"type": "response.output_item.done", "item": map[string]any{"type": "reasoning", "encrypted_content": "opaque"}},
                modelWriteEvents(w,
                        map[string]any{"type": "response.created", "response": map[string]any{}},
                        map[string]any{"type": "response.output_item.done", "item": map[string]any{"type": "reasoning", "encrypted_content": "opaque"}},
@@ -129,7 +129,7 @@ func TestClientReadsTheStream(t *testing.T) {
 
 func TestClientTakesTheOutputOfTheCompletedResponse(t *testing.T) {
        server := newModelFake(t)
 
 func TestClientTakesTheOutputOfTheCompletedResponse(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("only here")}, 10, 0, 2))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("only here")}, 10, 0, 2))
        }
 
@@ -255,7 +255,7 @@ func TestClientFailsWhenTheResponseFails(t *testing.T) {
        for _, tc := range testCases {
                t.Run(tc.name, func(t *testing.T) {
                        server := newModelFake(t)
        for _, tc := range testCases {
                t.Run(tc.name, func(t *testing.T) {
                        server := newModelFake(t)
-                       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+                       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                                modelWriteEvents(w, tc.events...)
                        }
 
                                modelWriteEvents(w, tc.events...)
                        }
 
index a39d81c7b7fc990cf644454c267e35aa823262d4..0341ba6dde6e8fd77deb1f3ca48ae44c2855c140 100644 (file)
@@ -344,7 +344,7 @@ func TestTellToAFinishedSubagentGoesOnFromItsLog(t *testing.T) {
 
 func TestStopEndsASubagentAndItsCommand(t *testing.T) {
        server := newModelFake(t)
 
 func TestStopEndsASubagentAndItsCommand(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelFunctionCallItem("fc_1", "call_1", "shell", `{"command":"touch started && sleep 30"}`)}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelFunctionCallItem("fc_1", "call_1", "shell", `{"command":"touch started && sleep 30"}`)}, 100, 0, 5))
        }
 
@@ -396,7 +396,7 @@ func TestCloseEndsTheSubagentsWithNoReport(t *testing.T) {
                close(release)
        })
 
                close(release)
        })
 
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(_ http.ResponseWriter, _ ModelFakeCall) {
                close(arrived)
                <-release
        }
                close(arrived)
                <-release
        }
index 9b66aa45937984a3b9397332974e7e75aefff1aa..43e952e5f58480ea53268253de0bda944d6c8bc5 100644 (file)
@@ -220,7 +220,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
 
        for _, tc := range testCases {
                t.Run(tc.name, func(t *testing.T) {
 
        for _, tc := range testCases {
                t.Run(tc.name, func(t *testing.T) {
-                       server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+                       server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
                                tc.reply(w)
                        }))
                        t.Cleanup(server.Close)
                                tc.reply(w)
                        }))
                        t.Cleanup(server.Close)
index 5ced143eae9b1d8dbd55916ead35f3e6becdc4cc..e360045f50341bd027b29ff631ec456ae6e1638c 100644 (file)
@@ -16,7 +16,7 @@ import (
 
 func TestOwnerTalksToTheAgentThroughTelegram(t *testing.T) {
        server := newModelFake(t)
 
 func TestOwnerTalksToTheAgentThroughTelegram(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("Hello from the agent.")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("Hello from the agent.")}, 100, 0, 5))
        }
 
@@ -100,7 +100,7 @@ func TestStopFromTelegramInterruptsTheTurn(t *testing.T) {
                close(release)
        })
 
                close(release)
        })
 
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(_ http.ResponseWriter, _ ModelFakeCall) {
                close(arrived)
                <-release
        }
                close(arrived)
                <-release
        }
@@ -200,7 +200,7 @@ func TestBotSkipsTheWorkOfWhatsAppAndTheSchedules(t *testing.T) {
 
 func TestBotStartsAtTheStoredOffset(t *testing.T) {
        server := newModelFake(t)
 
 func TestBotStartsAtTheStoredOffset(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
@@ -234,7 +234,7 @@ func TestBotStartsAtTheStoredOffset(t *testing.T) {
 
 func TestBotTriesAgainAfterFailures(t *testing.T) {
        server := newModelFake(t)
 
 func TestBotTriesAgainAfterFailures(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
@@ -301,7 +301,7 @@ func TestDeliverTriesAgainAfterATimeout(t *testing.T) {
 func TestRepliesGoAsRichMessages(t *testing.T) {
        reply := "**Done.** The table:\n\n| Name | Size |\n|:-----|-----:|\n| `a.go` | 10 |\n\n- one\n- two\n\n```go\nx := 1\n```"
        server := newModelFake(t)
 func TestRepliesGoAsRichMessages(t *testing.T) {
        reply := "**Done.** The table:\n\n| Name | Size |\n|:-----|-----:|\n| `a.go` | 10 |\n\n- one\n- two\n\n```go\nx := 1\n```"
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem(reply)}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem(reply)}, 100, 0, 5))
        }
 
@@ -615,7 +615,7 @@ func TestBotLogsNoTokenWhenTheNetworkFails(t *testing.T) {
 
 func TestBotLogsAnOutageOnlyAtItsStartAndEnd(t *testing.T) {
        server := newModelFake(t)
 
 func TestBotLogsAnOutageOnlyAtItsStartAndEnd(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("ok")}, 100, 0, 5))
        }
 
index 2763965ea6ad1d6343f49af0f2cfb2685fe28a36..5d93e08709f4432ff982f55908b1cb19d388a34b 100644 (file)
@@ -208,7 +208,7 @@ func TestInterruptEndsTheTurn(t *testing.T) {
 
 func TestFailedCallEndsTheTurnWithoutARetry(t *testing.T) {
        server := newModelFake(t)
 
 func TestFailedCallEndsTheTurnWithoutARetry(t *testing.T) {
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                http.Error(w, "busy", http.StatusServiceUnavailable)
        }
 
                http.Error(w, "busy", http.StatusServiceUnavailable)
        }
 
index 56abdd6b81e12e72d0db7ad5a5e72e4b6d5f9537..f3d4e2a211afbb111ab2b5bd44b0cca5b222358d 100644 (file)
@@ -144,7 +144,7 @@ func TestRestoreViewRejectsAGap(t *testing.T) {
 // ViewBuiltTree is a tree with each node built, with 1 byte of text.
 type ViewBuiltTree struct{}
 
 // ViewBuiltTree is a tree with each node built, with 1 byte of text.
 type ViewBuiltTree struct{}
 
-func (ViewBuiltTree) Built(level, index int) (bool, error) {
+func (v ViewBuiltTree) Built(_, _ int) (bool, error) {
        return true, nil
 }
 
        return true, nil
 }
 
index 7aa558bffa0da8e213d78a1a373c7f044601fbf6..8e1da1378ed81fe97f9dcab917f13843bb29dba9 100644 (file)
@@ -132,7 +132,7 @@ func (f *WhatsAppFake) Disconnect() {
 }
 
 // GetQRChannel gives a new channel of pairing items to the test.
 }
 
 // GetQRChannel gives a new channel of pairing items to the test.
-func (f *WhatsAppFake) GetQRChannel(ctx context.Context) (<-chan whatsmeow.QRChannelItem, error) {
+func (f *WhatsAppFake) GetQRChannel(_ context.Context) (<-chan whatsmeow.QRChannelItem, error) {
        items := make(chan whatsmeow.QRChannelItem, 8)
        f.pairings <- items
 
        items := make(chan whatsmeow.QRChannelItem, 8)
        f.pairings <- items
 
@@ -140,7 +140,7 @@ func (f *WhatsAppFake) GetQRChannel(ctx context.Context) (<-chan whatsmeow.QRCha
 }
 
 // PairPhone keeps phone and returns whatsappTestCode.
 }
 
 // PairPhone keeps phone and returns whatsappTestCode.
-func (f *WhatsAppFake) PairPhone(ctx context.Context, phone string, showPushNotification bool, clientType whatsmeow.PairClientType, clientDisplayName string) (string, error) {
+func (f *WhatsAppFake) PairPhone(_ context.Context, phone string, _ bool, _ whatsmeow.PairClientType, _ string) (string, error) {
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
@@ -150,7 +150,7 @@ func (f *WhatsAppFake) PairPhone(ctx context.Context, phone string, showPushNoti
 }
 
 // Logout counts the logouts and returns logoutErr.
 }
 
 // Logout counts the logouts and returns logoutErr.
-func (f *WhatsAppFake) Logout(ctx context.Context) error {
+func (f *WhatsAppFake) Logout(_ context.Context) error {
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
@@ -160,7 +160,7 @@ func (f *WhatsAppFake) Logout(ctx context.Context) error {
 }
 
 // GetJoinedGroups returns groups.
 }
 
 // GetJoinedGroups returns groups.
-func (f *WhatsAppFake) GetJoinedGroups(ctx context.Context) ([]*types.GroupInfo, error) {
+func (f *WhatsAppFake) GetJoinedGroups(_ context.Context) ([]*types.GroupInfo, error) {
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
@@ -176,7 +176,7 @@ func (f *WhatsAppFake) GenerateMessageID() types.MessageID {
 }
 
 // SendMessage keeps the send and returns sendErr.
 }
 
 // SendMessage keeps the send and returns sendErr.
-func (f *WhatsAppFake) SendMessage(ctx context.Context, to types.JID, message *waE2E.Message, extra ...whatsmeow.SendRequestExtra) (whatsmeow.SendResponse, error) {
+func (f *WhatsAppFake) SendMessage(_ context.Context, to types.JID, message *waE2E.Message, extra ...whatsmeow.SendRequestExtra) (whatsmeow.SendResponse, error) {
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
@@ -229,7 +229,7 @@ func (f *WhatsAppFake) Emit(event any) bool {
 }
 
 // newClient keeps handle and returns the fake as the client of device.
 }
 
 // newClient keeps handle and returns the fake as the client of device.
-func (f *WhatsAppFake) newClient(device *store.Device, handle func(event any) bool) WhatsAppClient {
+func (f *WhatsAppFake) newClient(_ *store.Device, handle func(event any) bool) WhatsAppClient {
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
        f.mutex.Lock()
        defer f.mutex.Unlock()
 
index 7e9d3a31ff973fc45bd8360059538ac7fe6b2253..6264d1980a021c95dc8169a77629e171035c815a 100644 (file)
@@ -17,7 +17,7 @@ func TestWhatsAppPrivateBatchStartsATurnWithAnEmptyReply(t *testing.T) {
        require.NoError(t, whatsapp.device.Contacts.PutContactName(t.Context(), whatsappTestAna, "Ana", "Ana Souza"))
 
        server := newModelFake(t)
        require.NoError(t, whatsapp.device.Contacts.PutContactName(t.Context(), whatsappTestAna, "Ana", "Ana Souza"))
 
        server := newModelFake(t)
-       server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+       server.reply = func(w http.ResponseWriter, _ ModelFakeCall) {
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("")}, 100, 0, 5))
        }
 
                modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("")}, 100, 0, 5))
        }
 
@@ -56,7 +56,7 @@ func TestWhatsAppGroupTurns(t *testing.T) {
        }{
                {
                        name: "plain",
        }{
                {
                        name: "plain",
-                       message: func(event *events.Message) {
+                       message: func(_ *events.Message) {
                        },
                        line: "12:00 Bruno Lima: Who brings the cake?",
                },
                        },
                        line: "12:00 Bruno Lima: Who brings the cake?",
                },
index db04dc7424737406782dbb439f365b3db0279e39..dca137b8a55bf6d2dd2d87ea2f8cd206087e3170 100644 (file)
@@ -143,7 +143,8 @@ func TestWhatsAppFirstConnectionRetriesStopForLinkChanges(t *testing.T) {
                {
                        name: "unlink",
                        stop: func(test *WhatsAppRetryTest) {
                {
                        name: "unlink",
                        stop: func(test *WhatsAppRetryTest) {
-                               test.whatsapp.Command("unlink", func(text string) {})
+                               test.whatsapp.Command("unlink", func(_ string) {
+                               })
                        },
                },
                {
                        },
                },
                {
@@ -183,14 +184,16 @@ func TestWhatsAppPairsAfterFirstConnectionRetriesStop(t *testing.T) {
                test.fake.connectErr = errors.New("network unavailable")
                test.start(t)
                synctest.Wait()
                test.fake.connectErr = errors.New("network unavailable")
                test.start(t)
                synctest.Wait()
-               test.whatsapp.Command("unlink", func(text string) {})
+               test.whatsapp.Command("unlink", func(_ string) {
+               })
                synctest.Wait()
                require.False(t, test.whatsapp.isLinked())
 
                test.fake.mutex.Lock()
                test.fake.connectErr = nil
                test.fake.mutex.Unlock()
                synctest.Wait()
                require.False(t, test.whatsapp.isLinked())
 
                test.fake.mutex.Lock()
                test.fake.connectErr = nil
                test.fake.mutex.Unlock()
-               test.whatsapp.Command("pair 15550001111", func(text string) {})
+               test.whatsapp.Command("pair 15550001111", func(_ string) {
+               })
                items := <-test.fake.pairings
                items <- whatsmeow.QRChannelItem{Event: whatsmeow.QRChannelEventCode}
                synctest.Wait()
                items := <-test.fake.pairings
                items <- whatsmeow.QRChannelItem{Event: whatsmeow.QRChannelEventCode}
                synctest.Wait()
@@ -298,7 +301,7 @@ func TestWhatsAppIsNotLinkedWithoutALinkedDevice(t *testing.T) {
        }{
                {
                        name: "no session file",
        }{
                {
                        name: "no session file",
-                       session: func(t *testing.T, dir string) {
+                       session: func(_ *testing.T, _ string) {
                        },
                },
                {
                        },
                },
                {