Reduce complexity of this code step by step. Complex code: {{complex_code}} Complexity metrics: - Cyclomatic complexity: {{cyclomatic}} - Cognitive complexity: {{cognitive}} - Lines of code: {{loc}} Think through systematically: 1. SMELL IDENTIFICATION: What code smells are present? 2. RESPONSIBILITY ANALYSIS: Does this code do too many things? 3. CONTROL FLOW: Can nested conditionals be simplified? 4. EXTRACTION: What methods or classes should be extracted? 5. POLYMORPHISM: Can conditionals be replaced with polymorphism? 6. EARLY RETURNS: Can guard clauses reduce nesting? 7. NAMING: Do names clearly express intent? 8. DUPLICATION: Is there hidden duplication? 9. TESTING: Will refactoring improve testability? 10. REFACTORING PLAN: Ordered sequence of refactoring steps. 11. EXPECTED IMPROVEMENT: Target complexity after refactoring.
Code Complexity Reduction
Reduce code complexity by reasoning through refactoring approaches.
99 copies0 forks
Share this prompt:
Details
Category
CodingUse Cases
Code refactoring guidanceComplexity reduction planningCode quality improvement
Works Best With
claude-opus-4.5gpt-5.2gemini-2.0-flash
Created Updated Shared