get_validation_summary
Generate a high-level quality summary with health score for TwinCAT XML files to assess structural validation and code quality.
Instructions
Get high-level file quality summary with health score.
Args: file_path: Path to TwinCAT file
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The handler function 'get_validation_summary' which calculates a health score and provides a summary of validation issues for a TwinCAT file.
def get_validation_summary(file_path: str) -> str: """Get high-level file quality summary with health score. Args: file_path: Path to TwinCAT file """ _t0 = time.monotonic() try: path, error = _validate_file_path(file_path, start_time=_t0) if error: return error file = TwinCATFile.from_path(path) engine_result = validation_engine.validate(file, "all") health_score = 100 health_score -= engine_result.errors * 25 health_score -= engine_result.warnings * 5 health_score -= engine_result.infos * 1 health_score = max(0, min(100, health_score)) if health_score >= 90: status = "excellent" elif health_score >= 70: status = "good" elif health_score >= 50: status = "needs_work" else: status = "critical_issues" quick_fixes = sum(1 for issue in engine_result.issues if issue.fix_available) if quick_fixes == 0: fix_time = "No fixes needed" elif quick_fixes <= 3: fix_time = "< 1 minute" elif quick_fixes <= 10: fix_time = "1-2 minutes" else: fix_time = "2-5 minutes" result = { "success": True, "file_path": str(path), "health_score": health_score, "status": status, "issue_breakdown": { "critical": engine_result.errors, "warnings": engine_result.warnings, "info": engine_result.infos, }, "quick_fixes_available": quick_fixes, "estimated_fix_time": fix_time, } return _with_meta(result, _t0) except Exception as e: return _tool_error(str(e), file_path=file_path, start_time=_t0)