mirror of
https://github.com/langgenius/dify-sandbox.git
synced 2026-07-25 21:46:12 -04:00
[PR #207] refactor: reduce cognitive complexity across codebase #208
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-sandbox/pull/207
Author: @Galois123
Created: 1/12/2026
Status: 🔄 Open
Base:
main← Head:refactor/reduce-code-complexity📝 Commits (9)
fa94ad0refactor: reduce cognitive complexity of releaseLibBinary method2557bc5refactor: reduce complexity of output capture runnercb07461refactor: reuse error format string in output capture555c1b9refactor: simplify python releaseLibBinary flowff00772refactor: split InstallDependencies into focused helpers0c20710refactor: TempDirRunner to reduce complexitycec0684refactor: reduce cognitive complexity of InitConfig3bbc877refactor: deduplicate log file date format stringce822f4refactor: extract "unsupported language" to constant📊 Changes
7 files changed (+431 additions, -318 deletions)
View changed files
📝
internal/controller/run.go(+6 -4)📝
internal/core/runner/nodejs/setup.go(+59 -39)📝
internal/core/runner/output_capture.go(+102 -82)📝
internal/core/runner/python/setup.go(+116 -77)📝
internal/core/runner/temp_dir.go(+40 -33)📝
internal/static/config.go(+103 -80)📝
internal/utils/log/core.go(+5 -3)📄 Description
Summary
Refactor multiple components to reduce cognitive complexity and improve code maintainability by extracting functions, eliminating magic strings, and simplifying control flows.
Changes
This PR contains 9 focused refactor commits:
Constant Extraction
Function Decomposition
releaseLibBinaryinto focused helper functionsreleaseLibBinaryandInstallDependenciesflowsWithTempDirhelper methodsInitConfiginto focused configuration loadersFiles Changed
internal/controller/run.go(+6, -4)internal/core/runner/nodejs/setup.go(+59, -39)internal/core/runner/output_capture.go(+105, -85)internal/core/runner/python/setup.go(+116, -77)internal/core/runner/temp_dir.go(+40, -33)internal/static/config.go(+103, -80)internal/utils/log/core.go(+5, -3)Benefits
Testing
All existing tests pass. No functional changes - purely structural improvements.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.