test: _extract_content_units 仅统计功能章节表格行 - Closes #33
CI / test (pull_request) Successful in 9s

非功能章节(变更日志、术语解释等)的表格行不可能被
function_units 覆盖,计入分母会导致覆盖率虚低。

修复: table_rows 统计仅在 _is_functional_section
且 _has_section_content 的章节中进行。

Table 覆盖率: 54.2% → 72.2% (24行→18行分母)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 14:06:16 +08:00
parent 93e13e947c
commit 119c08faca
+11 -5
View File
@@ -137,16 +137,22 @@ def _extract_content_units(parsed_data: dict) -> dict:
for sec in sections:
name = sec.get("source", "")
if _is_functional_section(name) and _has_section_content(sec):
is_func = _is_functional_section(name) and _has_section_content(sec)
if is_func:
functional_sections.append({
"name": name,
"number": _section_number(name),
})
for block in sec.get("blocks", []):
if block.get("type") == "table":
rows = block.get("rows", [])
total_table_rows += len(rows)
# Only count table rows from functional sections
# (non-functional sections like changelog, glossary, references
# cannot be covered by function_units — counting them inflates
# the denominator and yields misleadingly low coverage.)
if is_func:
for block in sec.get("blocks", []):
if block.get("type") == "table":
rows = block.get("rows", [])
total_table_rows += len(rows)
# Diagram-type images from image_analysis
diagram_rids: list[str] = []