Generate the summary table matching bash script format. Returns: Formatted summary table as a string
(self)
| 42 | self.record_stage(name, 0.0, skipped) |
| 43 | |
| 44 | def generate_summary(self) -> str: |
| 45 | """ |
| 46 | Generate the summary table matching bash script format. |
| 47 | |
| 48 | Returns: |
| 49 | Formatted summary table as a string |
| 50 | """ |
| 51 | if not self.results: |
| 52 | return "" |
| 53 | |
| 54 | # Calculate column widths |
| 55 | max_name_width = max(len(r.name) for r in self.results) |
| 56 | header_width = len("Linter Name") |
| 57 | max_name_width = max(max_name_width, header_width) |
| 58 | |
| 59 | # Build separator line |
| 60 | separator = "-" * max_name_width + "-+-" + "-" * 24 |
| 61 | |
| 62 | # Build table |
| 63 | lines = [ |
| 64 | "", |
| 65 | "Linting Execution Summary:", |
| 66 | separator, |
| 67 | f"{'Linter Name':<{max_name_width}} | {'Duration':>24}", |
| 68 | separator, |
| 69 | ] |
| 70 | |
| 71 | # Add each result |
| 72 | for result in self.results: |
| 73 | if result.skipped: |
| 74 | lines.append( |
| 75 | f"{result.name:<{max_name_width}} | {'Skipped (no changes)':>24}" |
| 76 | ) |
| 77 | else: |
| 78 | lines.append( |
| 79 | f"{result.name:<{max_name_width}} | {int(result.duration):>23}s" |
| 80 | ) |
| 81 | |
| 82 | lines.append(separator) |
| 83 | |
| 84 | return "\n".join(lines) |