行数の制限

This commit is contained in:
ry.yamafuji 2025-12-05 00:51:08 +09:00
parent 1d865583b2
commit 6828fe684d
2 changed files with 20 additions and 7 deletions

View File

@ -1,7 +1,9 @@
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
sys.path.append(
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src"))
)
from utils.custom_logger import get_logger

View File

@ -5,7 +5,9 @@ class GenerateCoverage:
"""カバレッジ結果を解析して Markdown テーブルを生成"""
def __init__(
self, coverage_file="pytest-coverage.txt", output_file="coverage_table.md"
self,
coverage_file="pytest-coverage.txt",
output_file="coverage_table.md",
):
"""
初期化
@ -38,18 +40,23 @@ class GenerateCoverage:
continue
# Coverage セクションの終わりを検出TOTAL行の次の空行
if in_coverage_section and (
line.strip().startswith("TOTAL") or line.strip().startswith("=")
line.strip().startswith("TOTAL")
or line.strip().startswith("=")
):
break
# Coverage データを抽出
if in_coverage_section:
match = re.match(r"(.+?)\s+(\d+)\s+(\d+)\s+(\d+%)\s*(.*)", line)
match = re.match(
r"(.+?)\s+(\d+)\s+(\d+)\s+(\d+%)\s*(.*)", line
)
if match:
filename = match.group(1).strip()
statements = match.group(2).strip()
missed = match.group(3).strip()
coverage = match.group(4).strip()
missing_lines = match.group(5).strip() if match.group(5) else "-"
missing_lines = (
match.group(5).strip() if match.group(5) else "-"
)
coverage_info.append(
{
"filename": filename,
@ -71,8 +78,12 @@ class GenerateCoverage:
print("Parsed coverage data.")
# Markdown テーブルヘッダー
table_header = "| File | Statements | Missed | Coverage | Missing Lines |\n"
table_header += "|------|------------|--------|----------|---------------|\n"
table_header = (
"| File | Statements | Missed | Coverage | Missing Lines |\n"
)
table_header += (
"|------|------------|--------|----------|---------------|\n"
)
# テーブル行を生成
table_rows = [