From d24bd5f4079e4a4010d2e880ce0dc2d3d44c920f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Jul 2026 15:12:10 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20remove=20dead=20functions=20=E2=80=94?= =?UTF-8?q?=204=20functions=20removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unreachable functions identified by deadcode analyzer: - FormatProgressMessageStderr, FormatPromptMessageStderr, FormatVerboseMessageStderr (pkg/console) - GetValidationConfigJSON (pkg/workflow) — thin wrapper only used by tests, updated tests to call GetValidationConfigJSONWithDataSchema directly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/console/console.go | 15 ------- pkg/console/console_wasm.go | 45 +++++++++---------- .../safe_output_validation_config_test.go | 12 ++--- .../safe_outputs_validation_config.go | 17 ++----- 4 files changed, 30 insertions(+), 59 deletions(-) diff --git a/pkg/console/console.go b/pkg/console/console.go index 7ec24e04c78..ec8a058952a 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -331,31 +331,16 @@ func FormatProgressMessage(message string) string { return applyStyle(styles.Progress, "▸ ") + message } -// FormatProgressMessageStderr formats a progress/activity message for stderr output. -func FormatProgressMessageStderr(message string) string { - return applyStyleWithTTY(styles.Progress, "▸ ", isStderrTTY) + message -} - // FormatPromptMessage formats a user prompt message func FormatPromptMessage(message string) string { return applyStyle(styles.Prompt, "? ") + message } -// FormatPromptMessageStderr formats a user prompt message for stderr output. -func FormatPromptMessageStderr(message string) string { - return applyStyleWithTTY(styles.Prompt, "? ", isStderrTTY) + message -} - // FormatVerboseMessage formats verbose debugging output func FormatVerboseMessage(message string) string { return applyStyle(styles.Verbose, "» ") + message } -// FormatVerboseMessageStderr formats verbose debugging output for stderr output. -func FormatVerboseMessageStderr(message string) string { - return applyStyleWithTTY(styles.Verbose, "» ", isStderrTTY) + message -} - // FormatListItem formats an item in a list func FormatListItem(item string) string { return formatListItemWithTTY(item, isTTY, stdoutEnviron()) diff --git a/pkg/console/console_wasm.go b/pkg/console/console_wasm.go index 856c487884a..383c8be13d0 100644 --- a/pkg/console/console_wasm.go +++ b/pkg/console/console_wasm.go @@ -65,30 +65,27 @@ func FormatError(err CompilerError) string { return output.String() } -func FormatSuccessMessage(message string) string { return "✓ " + message } -func FormatSuccessMessageStderr(message string) string { return "✓ " + message } -func FormatInfoMessage(message string) string { return "i " + message } -func FormatInfoMessageStderr(message string) string { return "i " + message } -func FormatTableHeaderStderr(text string) string { return text } -func FormatWarningMessage(message string) string { return "⚠ " + message } -func FormatWarningMessageStderr(message string) string { return "⚠ " + message } -func FormatErrorMessage(message string) string { return "✗ " + message } -func FormatErrorTextStderr(text string) string { return text } -func FormatLocationMessage(message string) string { return "~ " + message } -func FormatCommandMessage(command string) string { return "$ " + command } -func FormatCommandMessageStderr(command string) string { return "$ " + command } -func FormatProgressMessage(message string) string { return "▸ " + message } -func FormatProgressMessageStderr(message string) string { return "▸ " + message } -func FormatPromptMessage(message string) string { return "? " + message } -func FormatPromptMessageStderr(message string) string { return "? " + message } -func FormatCountMessage(message string) string { return "# " + message } -func FormatVerboseMessage(message string) string { return "» " + message } -func FormatVerboseMessageStderr(message string) string { return "» " + message } -func FormatListHeader(header string) string { return header } -func FormatListItem(item string) string { return " • " + item } -func FormatListItemStderr(item string) string { return " • " + item } -func FormatSectionHeader(header string) string { return header } -func FormatSectionHeaderStderr(header string) string { return header } +func FormatSuccessMessage(message string) string { return "✓ " + message } +func FormatSuccessMessageStderr(message string) string { return "✓ " + message } +func FormatInfoMessage(message string) string { return "i " + message } +func FormatInfoMessageStderr(message string) string { return "i " + message } +func FormatTableHeaderStderr(text string) string { return text } +func FormatWarningMessage(message string) string { return "⚠ " + message } +func FormatWarningMessageStderr(message string) string { return "⚠ " + message } +func FormatErrorMessage(message string) string { return "✗ " + message } +func FormatErrorTextStderr(text string) string { return text } +func FormatLocationMessage(message string) string { return "~ " + message } +func FormatCommandMessage(command string) string { return "$ " + command } +func FormatCommandMessageStderr(command string) string { return "$ " + command } +func FormatProgressMessage(message string) string { return "▸ " + message } +func FormatPromptMessage(message string) string { return "? " + message } +func FormatCountMessage(message string) string { return "# " + message } +func FormatVerboseMessage(message string) string { return "» " + message } +func FormatListHeader(header string) string { return header } +func FormatListItem(item string) string { return " • " + item } +func FormatListItemStderr(item string) string { return " • " + item } +func FormatSectionHeader(header string) string { return header } +func FormatSectionHeaderStderr(header string) string { return header } // FormatErrorChain formats an error and its full unwrapped chain. // In the WASM build there is no rich terminal styling; the top-level error diff --git a/pkg/workflow/safe_output_validation_config_test.go b/pkg/workflow/safe_output_validation_config_test.go index b9db74409d8..83e5c6e1844 100644 --- a/pkg/workflow/safe_output_validation_config_test.go +++ b/pkg/workflow/safe_output_validation_config_test.go @@ -9,7 +9,7 @@ import ( func TestGetValidationConfigJSON(t *testing.T) { // Test with nil (all types) - jsonStr, err := GetValidationConfigJSON(nil, nil) + jsonStr, err := GetValidationConfigJSONWithDataSchema(nil, nil, false, nil) if err != nil { t.Fatalf("GetValidationConfigJSON() error = %v", err) } @@ -73,7 +73,7 @@ func TestGetValidationConfigJSON(t *testing.T) { func TestGetValidationConfigJSONFiltered(t *testing.T) { // Test with filtered types enabledTypes := []string{"create_issue", "add_comment"} - jsonStr, err := GetValidationConfigJSON(enabledTypes, nil) + jsonStr, err := GetValidationConfigJSONWithDataSchema(enabledTypes, nil, false, nil) if err != nil { t.Fatalf("GetValidationConfigJSON() error = %v", err) } @@ -105,7 +105,7 @@ func TestGetValidationConfigJSONFiltered(t *testing.T) { func TestGetValidationConfigJSONEmpty(t *testing.T) { // Test with empty slice (should return all types, same as nil) - jsonStr, err := GetValidationConfigJSON([]string{}, nil) + jsonStr, err := GetValidationConfigJSONWithDataSchema([]string{}, nil, false, nil) if err != nil { t.Fatalf("GetValidationConfigJSON() error = %v", err) } @@ -131,7 +131,7 @@ func TestGetValidationConfigJSONWithMentions(t *testing.T) { "max": 5, } - jsonStr, err := GetValidationConfigJSON([]string{"add_comment"}, mentions) + jsonStr, err := GetValidationConfigJSONWithDataSchema([]string{"add_comment"}, mentions, false, nil) if err != nil { t.Fatalf("GetValidationConfigJSON() error = %v", err) } @@ -169,7 +169,7 @@ func TestGetValidationConfigJSONWithMentions(t *testing.T) { } // A second call without mentions must not include the key (cache safety). - plainJSON, err := GetValidationConfigJSON([]string{"add_comment"}, nil) + plainJSON, err := GetValidationConfigJSONWithDataSchema([]string{"add_comment"}, nil, false, nil) if err != nil { t.Fatalf("GetValidationConfigJSON() error = %v", err) } @@ -505,7 +505,7 @@ func TestAssignMilestoneValidationConfig(t *testing.T) { } func TestAssignMilestoneValidationConfigJSON(t *testing.T) { - jsonStr, err := GetValidationConfigJSON([]string{"assign_milestone"}, nil) + jsonStr, err := GetValidationConfigJSONWithDataSchema([]string{"assign_milestone"}, nil, false, nil) if err != nil { t.Fatalf("GetValidationConfigJSON() error = %v", err) } diff --git a/pkg/workflow/safe_outputs_validation_config.go b/pkg/workflow/safe_outputs_validation_config.go index 59d096b3092..0241b7fb233 100644 --- a/pkg/workflow/safe_outputs_validation_config.go +++ b/pkg/workflow/safe_outputs_validation_config.go @@ -483,24 +483,13 @@ var ValidationConfig = map[string]TypeValidationConfig{ }, } -// validationConfigJSONCache caches GetValidationConfigJSON results keyed by the sorted, -// comma-joined enabledTypes string. ValidationConfig is a package-level constant so +// validationConfigJSONCache caches GetValidationConfigJSONWithDataSchema results keyed by the +// sorted, comma-joined enabledTypes string. ValidationConfig is a package-level constant so // the output is deterministic for a given set of types; caching avoids repeated // json.MarshalIndent calls on every workflow compilation. var validationConfigJSONCache sync.Map // key: string → value: string -// GetValidationConfigJSON returns the validation configuration as indented JSON. -// If enabledTypes is empty or nil, returns all validation configs. -// If enabledTypes is provided, returns only configs for the specified types. -// If mentions is non-empty, a top-level "mentions" key is included in the JSON -// so that collect_ndjson_output.cjs honours the configured @mention allowlist -// during the initial sanitization pass (mirroring what the publish-side handlers -// receive via GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG). -func GetValidationConfigJSON(enabledTypes []string, mentions map[string]any) (string, error) { - return GetValidationConfigJSONWithDataSchema(enabledTypes, mentions, false, nil) -} - -// GetValidationConfigJSONWithDataSchema behaves like GetValidationConfigJSON and additionally +// GetValidationConfigJSONWithDataSchema behaves like GetValidationConfigJSONWithDataSchema and additionally // injects a normalized data schema into body-bearing safe-output types. func GetValidationConfigJSONWithDataSchema(enabledTypes []string, mentions map[string]any, dataEnabled bool, dataSchema map[string]any) (string, error) { safeOutputValidationLog.Printf("Getting validation config JSON for %d types (mentions=%t)", len(enabledTypes), len(mentions) > 0)