Skip to content

Commit f604156

Browse files
authored
Merge pull request #71 from syou6162/remove_dead_code_lint
2 parents 27af134 + 650ed8e commit f604156

29 files changed

+344
-433
lines changed

actions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
// handleOutput processes an output action and returns ExitError if a non-zero exit status is specified.
88
// Exit status 2 outputs to stderr, while other non-zero statuses output to stdout with error.
9-
func handleOutput(message string, exitStatus *int, rawJSON interface{}) error {
9+
func handleOutput(message string, exitStatus *int, rawJSON any) error {
1010
processedMessage := unifiedTemplateReplace(message, rawJSON)
1111
status := getExitStatus(exitStatus, "output")
1212
if status != 0 {

actions_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestExecutePostToolUseAction_WithUseStdin(t *testing.T) {
3232
ToolName: "Edit",
3333
}
3434

35-
rawJSON := map[string]interface{}{
35+
rawJSON := map[string]any{
3636
"tool_name": "Edit",
3737
}
3838

actions_test.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@ import (
44
"testing"
55
)
66

7-
// stubRunner is a test implementation of CommandRunner that allows mocking command execution.
8-
type stubRunner struct {
9-
runFunc func(cmd string, useStdin bool, data interface{}) error
10-
}
11-
12-
func (s *stubRunner) RunCommand(cmd string, useStdin bool, data interface{}) error {
13-
if s.runFunc != nil {
14-
return s.runFunc(cmd, useStdin, data)
15-
}
16-
return nil
17-
}
18-
19-
func (s *stubRunner) RunCommandWithOutput(cmd string, useStdin bool, data interface{}) (stdout, stderr string, exitCode int, err error) {
20-
// For actions_test.go, we don't need this method to be functional
21-
// as it's only used in executor_test.go with stubRunnerWithOutput
22-
return "", "", 0, nil
23-
}
24-
257
func TestGetExitStatus(t *testing.T) {
268
tests := []struct {
279
name string
@@ -205,7 +187,7 @@ func TestHandleOutput(t *testing.T) {
205187

206188
for _, tt := range tests {
207189
t.Run(tt.name, func(t *testing.T) {
208-
rawJSON := map[string]interface{}{}
190+
rawJSON := map[string]any{}
209191
err := handleOutput(tt.message, tt.exitStatus, rawJSON)
210192

211193
if tt.wantErr {
@@ -303,7 +285,7 @@ func TestExecuteStopAction_CommandWithStubRunner(t *testing.T) {
303285
Command: tt.command,
304286
}
305287

306-
output, err := executor.ExecuteStopAction(action, &StopInput{}, map[string]interface{}{})
288+
output, err := executor.ExecuteStopAction(action, &StopInput{}, map[string]any{})
307289

308290
if err != nil {
309291
t.Fatalf("Expected no error, got %v", err)

conditions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func countUserPromptsFromTranscript(transcriptPath, sessionID string) (int, erro
227227
count := 0
228228

229229
for {
230-
var entry map[string]interface{}
230+
var entry map[string]any
231231
if err := decoder.Decode(&entry); err != nil {
232232
if err == io.EOF {
233233
break

executor.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewActionExecutor(runner CommandRunner) *ActionExecutor {
2525

2626
// ExecuteNotificationAction executes an action for the Notification event and returns JSON output.
2727
// Similar to SessionStart, Notification uses hookSpecificOutput with additionalContext.
28-
func (e *ActionExecutor) ExecuteNotificationAction(action Action, input *NotificationInput, rawJSON interface{}) (*ActionOutput, error) {
28+
func (e *ActionExecutor) ExecuteNotificationAction(action Action, input *NotificationInput, rawJSON any) (*ActionOutput, error) {
2929
switch action.Type {
3030
case "command":
3131
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -145,7 +145,7 @@ func (e *ActionExecutor) ExecuteNotificationAction(action Action, input *Notific
145145

146146
// ExecuteSubagentStartAction executes an action for the SubagentStart event and returns JSON output.
147147
// Similar to Notification, SubagentStart uses hookSpecificOutput with additionalContext.
148-
func (e *ActionExecutor) ExecuteSubagentStartAction(action Action, input *SubagentStartInput, rawJSON interface{}) (*ActionOutput, error) {
148+
func (e *ActionExecutor) ExecuteSubagentStartAction(action Action, input *SubagentStartInput, rawJSON any) (*ActionOutput, error) {
149149
switch action.Type {
150150
case "command":
151151
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -266,7 +266,7 @@ func (e *ActionExecutor) ExecuteSubagentStartAction(action Action, input *Subage
266266
// ExecuteStopAction executes an action for the Stop event.
267267
// Returns ActionOutput for JSON serialization with decision/reason fields.
268268
// Stop hooks use top-level decision pattern (no hookSpecificOutput).
269-
func (e *ActionExecutor) ExecuteStopAction(action Action, input *StopInput, rawJSON interface{}) (*ActionOutput, error) {
269+
func (e *ActionExecutor) ExecuteStopAction(action Action, input *StopInput, rawJSON any) (*ActionOutput, error) {
270270
switch action.Type {
271271
case "command":
272272
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -426,7 +426,7 @@ func (e *ActionExecutor) ExecuteStopAction(action Action, input *StopInput, rawJ
426426

427427
// ExecuteSubagentStopAction executes an action for the SubagentStop event.
428428
// Command failures result in exit status 2 to block the subagent stop operation.
429-
func (e *ActionExecutor) ExecuteSubagentStopAction(action Action, input *SubagentStopInput, rawJSON interface{}) (*ActionOutput, error) {
429+
func (e *ActionExecutor) ExecuteSubagentStopAction(action Action, input *SubagentStopInput, rawJSON any) (*ActionOutput, error) {
430430
switch action.Type {
431431
case "command":
432432
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -589,7 +589,7 @@ func (e *ActionExecutor) ExecuteSubagentStopAction(action Action, input *Subagen
589589
// ExecutePreCompactAction executes an action for the PreCompact event and returns ActionOutput.
590590
// PreCompact always returns continue=true (fail-safe: compaction cannot be blocked).
591591
// Errors are reported via systemMessage field, not by blocking execution.
592-
func (e *ActionExecutor) ExecutePreCompactAction(action Action, input *PreCompactInput, rawJSON interface{}) (*ActionOutput, error) {
592+
func (e *ActionExecutor) ExecutePreCompactAction(action Action, input *PreCompactInput, rawJSON any) (*ActionOutput, error) {
593593
switch action.Type {
594594
case "command":
595595
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -668,7 +668,7 @@ func (e *ActionExecutor) ExecutePreCompactAction(action Action, input *PreCompac
668668

669669
// ExecuteSessionStartAction executes an action for the SessionStart event.
670670
// Returns ActionOutput for JSON serialization.
671-
func (e *ActionExecutor) ExecuteSessionStartAction(action Action, input *SessionStartInput, rawJSON interface{}) (*ActionOutput, error) {
671+
func (e *ActionExecutor) ExecuteSessionStartAction(action Action, input *SessionStartInput, rawJSON any) (*ActionOutput, error) {
672672
switch action.Type {
673673
case "command":
674674
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -780,7 +780,7 @@ func (e *ActionExecutor) ExecuteSessionStartAction(action Action, input *Session
780780

781781
// ExecuteUserPromptSubmitAction executes an action for the UserPromptSubmit event and returns JSON output.
782782
// This method implements Phase 2 JSON output functionality for UserPromptSubmit hooks.
783-
func (e *ActionExecutor) ExecuteUserPromptSubmitAction(action Action, input *UserPromptSubmitInput, rawJSON interface{}) (*ActionOutput, error) {
783+
func (e *ActionExecutor) ExecuteUserPromptSubmitAction(action Action, input *UserPromptSubmitInput, rawJSON any) (*ActionOutput, error) {
784784
switch action.Type {
785785
case "command":
786786
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -940,7 +940,7 @@ func (e *ActionExecutor) ExecuteUserPromptSubmitAction(action Action, input *Use
940940
// ExecuteSessionEndAction executes an action for the SessionEnd event and returns ActionOutput.
941941
// SessionEnd always returns continue=true (fail-safe: session end cannot be blocked).
942942
// Errors are reported via systemMessage field, not by blocking execution.
943-
func (e *ActionExecutor) ExecuteSessionEndAction(action Action, input *SessionEndInput, rawJSON interface{}) (*ActionOutput, error) {
943+
func (e *ActionExecutor) ExecuteSessionEndAction(action Action, input *SessionEndInput, rawJSON any) (*ActionOutput, error) {
944944
switch action.Type {
945945
case "command":
946946
cmd := unifiedTemplateReplace(action.Command, rawJSON)
@@ -1022,7 +1022,7 @@ func (e *ActionExecutor) ExecuteSessionEndAction(action Action, input *SessionEn
10221022
// and logs warnings to stderr. Supported fields are: continue, stopReason, suppressOutput,
10231023
// systemMessage, and hookSpecificOutput.
10241024
func checkUnsupportedFieldsSessionStart(stdout string) {
1025-
var data map[string]interface{}
1025+
var data map[string]any
10261026
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
10271027
// JSON parsing failed - this will be caught by the main validation
10281028
return
@@ -1046,7 +1046,7 @@ func checkUnsupportedFieldsSessionStart(stdout string) {
10461046
// checkUnsupportedFieldsSessionEnd checks for unsupported fields in SessionEnd hook output
10471047
// SessionEnd uses Common JSON Fields only (no decision/reason/hookSpecificOutput)
10481048
func checkUnsupportedFieldsSessionEnd(stdout string) {
1049-
var data map[string]interface{}
1049+
var data map[string]any
10501050
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
10511051
return
10521052
}
@@ -1068,7 +1068,7 @@ func checkUnsupportedFieldsSessionEnd(stdout string) {
10681068

10691069
//nolint:unused // Will be used in Step 3
10701070
func checkUnsupportedFieldsPreCompact(stdout string) {
1071-
var data map[string]interface{}
1071+
var data map[string]any
10721072
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
10731073
return
10741074
}
@@ -1091,7 +1091,7 @@ func checkUnsupportedFieldsPreCompact(stdout string) {
10911091
// checkUnsupportedFieldsNotification checks for unsupported fields in Notification JSON output
10921092
// and logs warnings to stderr for any fields that are not in the supported list.
10931093
func checkUnsupportedFieldsNotification(stdout string) {
1094-
var data map[string]interface{}
1094+
var data map[string]any
10951095
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
10961096
// JSON parsing failed - this will be caught by the main validation
10971097
return
@@ -1115,7 +1115,7 @@ func checkUnsupportedFieldsNotification(stdout string) {
11151115
// checkUnsupportedFieldsSubagentStart checks for unsupported fields in SubagentStart JSON output
11161116
// and logs warnings to stderr for any fields that are not in the supported list.
11171117
func checkUnsupportedFieldsSubagentStart(stdout string) {
1118-
var data map[string]interface{}
1118+
var data map[string]any
11191119
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
11201120
// JSON parsing failed - this will be caught by the main validation
11211121
return
@@ -1139,7 +1139,7 @@ func checkUnsupportedFieldsSubagentStart(stdout string) {
11391139
// checkUnsupportedFieldsUserPromptSubmit checks for unsupported fields in UserPromptSubmit JSON output
11401140
// and logs warnings to stderr for any fields that are not in the supported list.
11411141
func checkUnsupportedFieldsUserPromptSubmit(stdout string) {
1142-
var data map[string]interface{}
1142+
var data map[string]any
11431143
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
11441144
// JSON parsing failed - this will be caught by the main validation
11451145
return
@@ -1164,7 +1164,7 @@ func checkUnsupportedFieldsUserPromptSubmit(stdout string) {
11641164
// checkUnsupportedFieldsStop checks for unsupported fields in Stop JSON output
11651165
// and logs warnings to stderr. Stop uses top-level decision/reason (no hookSpecificOutput).
11661166
func checkUnsupportedFieldsStop(stdout string) {
1167-
var data map[string]interface{}
1167+
var data map[string]any
11681168
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
11691169
return
11701170
}
@@ -1189,7 +1189,7 @@ func checkUnsupportedFieldsStop(stdout string) {
11891189
// checkUnsupportedFieldsSubagentStop checks for unsupported fields in SubagentStop hook output
11901190
// SubagentStop uses the same schema as Stop (no hookSpecificOutput)
11911191
func checkUnsupportedFieldsSubagentStop(stdout string) {
1192-
var data map[string]interface{}
1192+
var data map[string]any
11931193
if err := json.Unmarshal([]byte(stdout), &data); err != nil {
11941194
return
11951195
}

0 commit comments

Comments
 (0)