Skip to content

Conversation

@Galois123
Copy link

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

  • internal/controller/run.go - Extract "unsupported language" error message to constant
  • internal/core/runner/output_capture.go - Reuse error format string constant
  • internal/utils/log/core.go - Deduplicate log file date format string

Function Decomposition

  • internal/core/runner/nodejs/setup.go - Split releaseLibBinary into focused helper functions
  • internal/core/runner/python/setup.go - Refactor both releaseLibBinary and InstallDependencies flows
  • internal/core/runner/output_capture.go - Reduce complexity of output capture runner
  • internal/core/runner/temp_dir.go - Extract WithTempDir helper methods
  • internal/static/config.go - Split InitConfig into focused configuration loaders

Files 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

  • Improved Readability: Smaller, focused functions are easier to understand
  • Better Maintainability: Each function has a single responsibility
  • Easier Testing: Smaller functions can be tested independently
  • Reduced Cognitive Load: Less nesting and clearer control flow

Testing

All existing tests pass. No functional changes - purely structural improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant