Skip to content

Case Study Border Cleanup

rtd edited this page Jan 13, 2026 · 1 revision

Case Study: Border Window Cleanup

Type: REFACTOR Skills: cc-refactoring-guidance → cc-control-flow-quality (CHECKER) → cc-routine-and-class-design (CHECKER) Focus: Post-refactoring quality gates

Why This Case Study Matters

This example shows the CHECKER gates that run after refactoring to verify code quality wasn't degraded:

  1. Two skills as quality gates - Control flow + routine design checks
  2. McCabe complexity analysis - Quantified complexity with thresholds
  3. Pre-existing vs new issues - Checkers distinguish what you changed from what was already there
  4. Cohesion classification - Functional vs Temporal cohesion types

The Flow

[After refactoring work complete]

→ cc-control-flow-quality (CHECKER mode)
  → Analyzes nesting depth and McCabe complexity
  → Flags pre-existing issues separately from new code

→ cc-routine-and-class-design (CHECKER mode)
  → LSP test, parameter counts, naming, cohesion
  → Minimum viable compliance check

Control Flow Analysis

File Function Max Nesting McCabe Status
BorderWindow.swift updateStyle 1 (guard clauses) 6 ✓ Clean
SimpleBorderManager.swift debugBordersImpl 2 4 ✓ Clean
SimpleBorderManager.swift setCellAssignmentsImpl 3 ~14 ⚠️ Pre-existing

Key insight: The checker notes setCellAssignmentsImpl complexity is pre-existing - the refactoring only added a dictionary lookup without adding control flow.


Routine & Class Design Check

Minimum Viable Compliance (7 checks)

# Check Result Evidence
1 LSP test for inheritance ✓ PASS No new inheritance introduced
2 Inheritance depth < 3 ✓ PASS No inheritance changes
3 No empty overrides ✓ PASS No overrides in changes
4 Parameter count ≤ 7 ✓ PASS Max 4 params
5 Routine names describe function ✓ PASS debugBorders, updateStyle
6 Consistent abstraction ✓ PASS Single level
7 Implementation hidden ✓ PASS SkyLight details encapsulated

Cohesion Classification

Routine Type Status
updateStyle Functional ✓ ACCEPT - single operation
debugBorders Functional ✓ ACCEPT - single operation
debugBordersImpl Temporal ✓ ACCEPT - orchestration

CHECKER Gate Summary

Gate Result
cc-control-flow-quality PASS (max nesting 2, McCabe < 10 for new code)
cc-routine-and-class-design PASS (functional cohesion, ≤7 params, good naming)

Key Takeaways

  1. CHECKER gates after refactoring - Verify you didn't degrade quality
  2. McCabe complexity - Quantified threshold (< 10 for new code)
  3. Pre-existing vs new - Checkers don't blame you for existing issues
  4. Cohesion types - Functional (ideal) vs Temporal (acceptable for orchestration)
  5. 7-point compliance check - Systematic coverage of design principles

Clone this wiki locally