refactor: replace fragile io.StringIO output suppression with validate_all_detailed - #23
Conversation
…e_all_detailed _run_checks() was using io.StringIO + redirect_stdout/redirect_stderr to suppress terminal output while running ValidationEngine.validate_all(). This approach was fragile and manually reconstructed check dicts from rule templates rather than actual failure details. Switch to ValidationEngine.validate_all_detailed() which: - Internally sets _suppress_output on each validator - Returns structured CheckOutcome objects with real failure details - Provides to_dict() for direct serialization - Runs all rules through a single engine call instead of one per rule
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe commit-check MCP server now runs filtered checks through ChangesDetailed validation flow
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 209 203 -6
=========================================
- Hits 209 203 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
_run_checks()was usingio.StringIO+redirect_stdout/redirect_stderrto suppress terminal output while callingValidationEngine.validate_all(). This approach was fragile and reconstructed check dicts manually from rule templates instead of using actual failure details.Changes
io.StringIO+redirect_stdout/stderrValidationEngine.validate_all_detailed()ValidationEngineper rulerule.error/rule.suggestCheckOutcomefrom_last_failure(real failure details)CheckOutcome.to_dict()Files changed:
src/commit_check_mcp/server.py— 9 insertions, 19 deletions.Benefits
io.StringIO/redirect_stdout/redirect_stderrpatternvalidate_all_detailed()which internally sets_suppress_outputon each validatorCheckOutcomecarries the actualvalue/error/suggestfrom validation, not rule templatesVerification
io,redirect_stdout,redirect_stderr, unusedValidationResultremoved)Summary by CodeRabbit