MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / parse_similarity_report

Function parse_similarity_report

scripts/inspect-unity.py:191–218  ·  view source on GitHub ↗

Parse similarity report to count groups and total impact lines. Expected summary line at end of report: Found 19 duplicate groups with 48 total methods Total impact: 831 duplicate lines

(report_path: Path)

Source from the content-addressed store, hash-verified

189
190
191def parse_similarity_report(report_path: Path) -> tuple[int, int]:
192 """Parse similarity report to count groups and total impact lines.
193
194 Expected summary line at end of report:
195 Found 19 duplicate groups with 48 total methods
196 Total impact: 831 duplicate lines
197 """
198 text = report_path.read_text()
199 if not text.strip():
200 return 0, 0
201
202 groups = 0
203 total_lines = 0
204
205 # Try to parse the summary line at the end
206 m_groups = re.search(r"Found\s+(\d+)\s+duplicate groups", text)
207 m_lines = re.search(r"Total impact:\s+(\d+)\s+duplicate lines", text)
208
209 if m_groups:
210 groups = int(m_groups.group(1))
211 if m_lines:
212 total_lines = int(m_lines.group(1))
213
214 # Fallback: count "Duplicate Group" headers if summary not found
215 if not m_groups:
216 groups = text.count("Duplicate Group")
217
218 return groups, total_lines
219
220
221def print_similarity_summary(groups: int, total_lines: int) -> None:

Callers 1

run_similarityFunction · 0.85

Calls 1

countMethod · 0.80

Tested by

no test coverage detected