Skip to content

Commit 202c02e

Browse files
Copilotmnkieferpelikhan
authored
Refactor safe outputs subsystem to reduce duplication (#9012)
* Initial plan * Refactor: Extract safe outputs config generation helpers Extract repetitive config generation patterns into reusable helper functions to reduce code duplication in safe_outputs_config_generation.go. Changes: - Created safe_outputs_config_generation_helpers.go with 9 helper functions - Reduced safe_outputs_config_generation.go from 991 to 854 lines (137 lines) - Extracted patterns for max config, allowed labels, target fields, etc. - All unit tests pass Impact: Reduced duplication, improved maintainability, easier to add new safe output types Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> * Refactor: Use reflection for safe outputs helper functions Replace manual field checking with reflection-based implementation for HasSafeOutputsEnabled and GetEnabledSafeOutputToolNames to reduce code duplication and improve maintainability. Changes: - Created safe_outputs_config_helpers_reflection.go with reflection helpers - Reduced safe_outputs_config_helpers.go from 196 to 77 lines (119 line reduction) - Total: 166 lines vs original 196 (30 line reduction) - Maintained field-to-tool mapping in single location - All unit tests pass Benefits: - Adding new safe output types now requires only updating the mapping - Eliminated 150+ lines of manual field checking - Improved code maintainability Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> Co-authored-by: Peli de Halleux <pelikhan@users.noreply.github.com>
1 parent b2e0de0 commit 202c02e

File tree

4 files changed

+338
-377
lines changed

4 files changed

+338
-377
lines changed

0 commit comments

Comments
 (0)