MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / analyze_coverage_gaps

Method analyze_coverage_gaps

testing/test_generator.py:223–253  ·  view source on GitHub ↗

Analyze coverage data to identify functions needing tests.

(self)

Source from the content-addressed store, hash-verified

221 }
222
223 def analyze_coverage_gaps(self) -> List[FunctionInfo]:
224 """Analyze coverage data to identify functions needing tests."""
225 coverage_file = self.project_root / "coverage.json"
226 if not coverage_file.exists():
227 print("Warning: coverage.json not found. Run tests with --coverage first.")
228 return []
229
230 try:
231 with open(coverage_file, 'r') as f:
232 coverage_data = json.load(f)
233 except json.JSONDecodeError:
234 print("Warning: Could not parse coverage.json")
235 return []
236
237 functions_needing_tests = []
238
239 for file_path, file_data in coverage_data.get('files', {}).items():
240 if not file_path.startswith('src/'):
241 continue
242
243 missing_lines = set(file_data.get('missing_lines', []))
244 if not missing_lines:
245 continue
246
247 # Analyze the source file
248 full_path = self.project_root / file_path
249 if full_path.exists():
250 functions = self._extract_functions_from_file(full_path, missing_lines)
251 functions_needing_tests.extend(functions)
252
253 return sorted(functions_needing_tests, key=lambda x: x.complexity_score, reverse=True)
254
255 def _extract_functions_from_file(self, file_path: Path, missing_lines: Set[int]) -> List[FunctionInfo]:
256 """Extract function information from a source file."""

Callers 2

analyze_and_generateMethod · 0.95
mainFunction · 0.95

Calls 2

loadMethod · 0.80

Tested by

no test coverage detected