From 73185f2c969bb06a56d377e332e3aaa5e2363cb3 Mon Sep 17 00:00:00 2001 From: tegwick Date: Tue, 23 Sep 2025 03:48:51 +0200 Subject: [PATCH] fix: Correct coverage calculation to return 0% for untested issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, coverage analysis was incorrectly using keywords from all existing tests, causing false positives where untested issues showed coverage percentages instead of 0%. Changes: - Only count tests specifically related to the analyzed issue - Return 0% coverage when no issue-specific tests exist - Maintain accurate coverage calculation for tested issues This ensures that Issue #3 correctly shows 0.0% coverage instead of 33.3%, while Issue #11 still correctly shows 100.0% coverage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tddai/coverage_analyzer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tddai/coverage_analyzer.py b/tddai/coverage_analyzer.py index ecde2647..6790e6ac 100644 --- a/tddai/coverage_analyzer.py +++ b/tddai/coverage_analyzer.py @@ -353,8 +353,15 @@ class CoverageAnalyzer: # Get all covered keywords covered_keywords = set() + issue_related_tests = [] for test in existing_tests: - covered_keywords.update(test.coverage_keywords) + if test.related_issue: # Only count tests specifically for this issue + covered_keywords.update(test.coverage_keywords) + issue_related_tests.append(test) + + # If no issue-specific tests found, coverage should be 0% + if not issue_related_tests: + return 0.0 # Check coverage for each requirement for requirement in requirements: