Files
pyscn/analyze_20250910_164727.html
DaisukeYoda b951910740 feat: improve HTML reports and health score calculation
## HTML Report Quality Improvements
- Fix dead code table displaying actual data instead of empty rows
- Correct file paths showing real paths instead of "unknown"
- Fix clone type display showing "Type-1", "Type-2" etc. instead of blank cells
- Improve template loop logic for proper item limiting

## Report Format Standardization
- Create shared FormatUtils for consistent formatting across all analysis types
- Standardize header widths, label alignment, and section structures
- Unify color schemes and risk level representations
- Add comprehensive summary statistics and warning sections

## Health Score Algorithm Enhancement
- Add project size normalization using logarithmic scaling for large projects
- Implement penalty caps: max 25 points per category (Complexity, Dead Code, Clones, CBO)
- Set minimum score threshold of 10 points to avoid complete failure
- Adjust grade thresholds: A(85+), B(70+), C(55+), D(40+), F(<40)
- Fix scoring issue where large projects always got 0/100 (Grade: F)

## Test Coverage Expansion
- Add comprehensive dead code test cases in testdata/python/
- Create simple, edge cases, and complex dead code pattern examples
- Improve test coverage for various unreachable code scenarios

## Results
- Large projects: 0/100 (F) → 50/100 (D)
- Small projects: appropriate scores (60-70 range)
- HTML reports now show detailed, accurate information
- Consistent professional formatting across all analysis types

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 20:10:37 +09:00

7951 lines
207 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>pyscn Analysis Report</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
line-height: 1.6;
color: #333;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.header {
background: white;
border-radius: 10px;
padding: 30px;
margin-bottom: 20px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.header h1 {
color: #667eea;
margin-bottom: 10px;
}
.score-badge {
display: inline-block;
padding: 10px 20px;
border-radius: 50px;
font-size: 24px;
font-weight: bold;
margin: 10px 0;
}
.grade-a { background: #4caf50; color: white; }
.grade-b { background: #8bc34a; color: white; }
.grade-c { background: #ff9800; color: white; }
.grade-d { background: #ff5722; color: white; }
.grade-f { background: #f44336; color: white; }
.tabs {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.tab-buttons {
display: flex;
background: #f5f5f5;
}
.tab-button {
flex: 1;
padding: 15px;
border: none;
background: transparent;
cursor: pointer;
font-size: 16px;
transition: all 0.3s;
}
.tab-button.active {
background: white;
color: #667eea;
font-weight: bold;
}
.tab-content {
display: none;
padding: 30px;
}
.tab-content.active {
display: block;
}
.metric-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin: 20px 0;
}
.metric-card {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
text-align: center;
}
.metric-value {
font-size: 32px;
font-weight: bold;
color: #667eea;
}
.metric-label {
color: #666;
margin-top: 5px;
}
.table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
.table th, .table td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
.table th {
background: #f8f9fa;
font-weight: 600;
}
.risk-low { color: #4caf50; }
.risk-medium { color: #ff9800; }
.risk-high { color: #f44336; }
.severity-critical { color: #f44336; }
.severity-warning { color: #ff9800; }
.severity-info { color: #2196f3; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>pyscn Analysis Report</h1>
<p>Generated: 2025-09-10 16:47:27</p>
<div class="score-badge grade-f">
Health Score: 0/100 (Grade: F)
</div>
</div>
<div class="tabs">
<div class="tab-buttons">
<button class="tab-button active" onclick="showTab('summary')">Summary</button>
<button class="tab-button" onclick="showTab('complexity')">Complexity</button>
<button class="tab-button" onclick="showTab('deadcode')">Dead Code</button>
<button class="tab-button" onclick="showTab('clone')">Clone Detection</button>
<button class="tab-button" onclick="showTab('cbo')">Dependency Analysis</button>
</div>
<div id="summary" class="tab-content active">
<h2>Analysis Summary</h2>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-value">14</div>
<div class="metric-label">Total Files</div>
</div>
<div class="metric-card">
<div class="metric-value">14</div>
<div class="metric-label">Analyzed Files</div>
</div>
<div class="metric-card">
<div class="metric-value">1.99</div>
<div class="metric-label">Avg Complexity</div>
</div>
<div class="metric-card">
<div class="metric-value">15</div>
<div class="metric-label">Dead Code Issues</div>
</div>
<div class="metric-card">
<div class="metric-value">3332</div>
<div class="metric-label">Clone Pairs</div>
</div>
<div class="metric-card">
<div class="metric-value">49.4%</div>
<div class="metric-label">Code Duplication</div>
</div>
<div class="metric-card">
<div class="metric-value">39</div>
<div class="metric-label">Total Classes</div>
</div>
<div class="metric-card">
<div class="metric-value">0</div>
<div class="metric-label">High Dependencies</div>
</div>
<div class="metric-card">
<div class="metric-value">0.18</div>
<div class="metric-label">Avg Dependencies</div>
</div>
</div>
</div>
<div id="complexity" class="tab-content">
<h2>Complexity Analysis</h2>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-value">177</div>
<div class="metric-label">Total Functions</div>
</div>
<div class="metric-card">
<div class="metric-value">1.99</div>
<div class="metric-label">Average</div>
</div>
<div class="metric-card">
<div class="metric-value">33</div>
<div class="metric-label">Maximum</div>
</div>
</div>
<h3>Top Complex Functions</h3>
<table class="table">
<thead>
<tr>
<th>Function</th>
<th>File</th>
<th>Complexity</th>
<th>Risk</th>
</tr>
</thead>
<tbody>
<tr>
<td>AbstractClass.abstract_method</td>
<td>testdata/python/simple/classes.py</td>
<td>2</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AbstractClass.concrete_method</td>
<td>testdata/python/simple/classes.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncClass.async_class_method</td>
<td>testdata/python/complex/async_await.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncClass.async_method</td>
<td>testdata/python/complex/async_await.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncClass.async_static_method</td>
<td>testdata/python/complex/async_await.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncContextManager.__aenter__</td>
<td>testdata/python/complex/async_await.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncContextManager.__aexit__</td>
<td>testdata/python/complex/async_await.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncRange.__aiter__</td>
<td>testdata/python/complex/async_await.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncRange.__anext__</td>
<td>testdata/python/complex/async_await.py</td>
<td>3</td>
<td class="risk-low">low</td>
</tr>
<tr>
<td>AsyncRange.__init__</td>
<td>testdata/python/complex/async_await.py</td>
<td>1</td>
<td class="risk-low">low</td>
</tr>
</tbody>
</table>
<p style="color: #666; margin-top: 10px;">Showing top 10 of 177 functions</p>
</div>
<div id="deadcode" class="tab-content">
<h2>Dead Code Detection</h2>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-value">15</div>
<div class="metric-label">Total Issues</div>
</div>
<div class="metric-card">
<div class="metric-value">14</div>
<div class="metric-label">Critical</div>
</div>
<div class="metric-card">
<div class="metric-value">1</div>
<div class="metric-label">Warnings</div>
</div>
</div>
<h3>Top Dead Code Issues</h3>
<table class="table">
<thead>
<tr>
<th>File</th>
<th>Function</th>
<th>Lines</th>
<th>Severity</th>
<th>Reason</th>
</tr>
</thead>
<tbody>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>exception_hierarchy_dead_code</td>
<td>160-160</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>async_dead_code</td>
<td>57-58</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>finally_block_patterns</td>
<td>168-168</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>finally_block_patterns</td>
<td>172-172</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>finally_block_patterns</td>
<td>179-179</td>
<td class="severity-warning">warning</td>
<td>unreachable_branch</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>complex_control_flow</td>
<td>30-31</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>generator_with_dead_code</td>
<td>45-46</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>context_manager_dead_code</td>
<td>74-74</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_raise</td>
</tr>
<tr>
<td>testdata/python/edge_cases/dead_code_examples.py</td>
<td>unreachable_after_continue</td>
<td>69-70</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_continue</td>
</tr>
<tr>
<td>testdata/python/edge_cases/dead_code_examples.py</td>
<td>unreachable_after_break</td>
<td>54-55</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_break</td>
</tr>
<tr>
<td>testdata/python/edge_cases/dead_code_examples.py</td>
<td>nested_dead_code</td>
<td>101-101</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/edge_cases/dead_code_examples.py</td>
<td>__init__</td>
<td>117-118</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/simple/dead_code_simple.py</td>
<td>nested_return_dead_code</td>
<td>60-60</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/simple/dead_code_simple.py</td>
<td>simple_dead_code</td>
<td>12-13</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_return</td>
</tr>
<tr>
<td>testdata/python/simple/dead_code_simple.py</td>
<td>loop_with_dead_code</td>
<td>34-34</td>
<td class="severity-critical">critical</td>
<td>unreachable_after_break</td>
</tr>
</tbody>
</table>
<p style="color: #666; margin-top: 10px;">Showing top 10 of 15 dead code issues</p>
</div>
<div id="clone" class="tab-content">
<h2>Clone Detection</h2>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-value">3332</div>
<div class="metric-label">Clone Pairs</div>
</div>
<div class="metric-card">
<div class="metric-value">2</div>
<div class="metric-label">Clone Groups</div>
</div>
<div class="metric-card">
<div class="metric-value">0.76</div>
<div class="metric-label">Avg Similarity</div>
</div>
</div>
<h3>Major Clone Pairs</h3>
<table class="table">
<thead>
<tr>
<th>File 1</th>
<th>File 2</th>
<th>Lines 1</th>
<th>Lines 2</th>
<th>Similarity</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>testdata/python/edge_cases/dead_code_examples.py</td>
<td>102-107</td>
<td>113-118</td>
<td>1.000</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/decorators.py</td>
<td>testdata/python/complex/decorators.py</td>
<td>8-12</td>
<td>157-161</td>
<td>1.000</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/edge_cases/nested_structures.py</td>
<td>testdata/python/edge_cases/nested_structures.py</td>
<td>90-94</td>
<td>171-180</td>
<td>1.000</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/simple/dead_code_simple.py</td>
<td>testdata/python/edge_cases/dead_code_examples.py</td>
<td>56-63</td>
<td>97-104</td>
<td>1.000</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/simple/control_flow.py</td>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>133-146</td>
<td>116-129</td>
<td>0.993</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>143-154</td>
<td>49-60</td>
<td>0.992</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>32-41</td>
<td>94-103</td>
<td>0.990</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>22-29</td>
<td>106-113</td>
<td>0.988</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>61-77</td>
<td>98-122</td>
<td>0.987</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/comprehensions.py</td>
<td>testdata/python/edge_cases/nested_structures.py</td>
<td>52-58</td>
<td>155-164</td>
<td>0.987</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>testdata/python/edge_cases/dead_code_examples.py</td>
<td>9-35</td>
<td>76-90</td>
<td>0.987</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>80-95</td>
<td>98-122</td>
<td>0.987</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/decorators.py</td>
<td>testdata/python/complex/exceptions.py</td>
<td>128-138</td>
<td>171-180</td>
<td>0.987</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/decorators.py</td>
<td>testdata/python/complex/decorators.py</td>
<td>7-13</td>
<td>156-162</td>
<td>0.986</td>
<td>Type-1</td>
</tr>
<tr>
<td>testdata/python/complex/dead_code_complex.py</td>
<td>testdata/python/edge_cases/nested_structures.py</td>
<td>113-119</td>
<td>155-164</td>
<td>0.985</td>
<td>Type-1</td>
</tr>
</tbody>
</table>
<p style="color: #666; margin-top: 10px;">Showing top 15 of 3332 clone pairs</p>
</div>
<div id="cbo" class="tab-content">
<h2>Dependency Analysis</h2>
<p style="margin-bottom: 20px; color: #666;">Class coupling metrics (CBO - Coupling Between Objects)</p>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-value">39</div>
<div class="metric-label">Total Classes</div>
</div>
<div class="metric-card">
<div class="metric-value">0</div>
<div class="metric-label">High Risk Classes</div>
</div>
<div class="metric-card">
<div class="metric-value">0.18</div>
<div class="metric-label">Average Dependencies</div>
</div>
<div class="metric-card">
<div class="metric-value">2</div>
<div class="metric-label">Max Dependencies</div>
</div>
</div>
<h3>Most Dependent Classes</h3>
<table class="table">
<thead>
<tr>
<th>Class</th>
<th>File</th>
<th>Dependencies</th>
<th>Risk Level</th>
<th>Dependent Classes</th>
</tr>
</thead>
<tbody>
<tr>
<td>MultipleInheritance</td>
<td>testdata/python/simple/classes.py</td>
<td>2</td>
<td class="risk-low">low</td>
<td>EmptyClass, SimpleClass</td>
</tr>
<tr>
<td>ValidationError</td>
<td>testdata/python/complex/exceptions.py</td>
<td>1</td>
<td class="risk-low">low</td>
<td>CustomError</td>
</tr>
<tr>
<td>ClassWithMagicMethods</td>
<td>testdata/python/simple/classes.py</td>
<td>1</td>
<td class="risk-low">low</td>
<td>ClassWithMagicMethods</td>
</tr>
<tr>
<td>InheritedClass</td>
<td>testdata/python/simple/classes.py</td>
<td>1</td>
<td class="risk-low">low</td>
<td>SimpleClass</td>
</tr>
<tr>
<td>ComplexClass</td>
<td>testdata/python/edge_cases/nested_structures.py</td>
<td>1</td>
<td class="risk-low">low</td>
<td>MethodClass</td>
</tr>
<tr>
<td>InnerClass</td>
<td>testdata/python/edge_cases/nested_structures.py</td>
<td>1</td>
<td class="risk-low">low</td>
<td>MethodClass</td>
</tr>
<tr>
<td>InnermostClass</td>
<td>testdata/python/edge_cases/nested_structures.py</td>
<td>0</td>
<td class="risk-low">low</td>
<td></td>
</tr>
<tr>
<td>Container</td>
<td>testdata/python/edge_cases/python310_features.py</td>
<td>0</td>
<td class="risk-low">low</td>
<td></td>
</tr>
<tr>
<td>CountCalls</td>
<td>testdata/python/complex/decorators.py</td>
<td>0</td>
<td class="risk-low">low</td>
<td></td>
</tr>
<tr>
<td>MaxCalls</td>
<td>testdata/python/complex/decorators.py</td>
<td>0</td>
<td class="risk-low">low</td>
<td></td>
</tr>
</tbody>
</table>
<p style="color: #666; margin-top: 10px;">Showing top 10 of 39 classes</p>
</div>
</div>
</div>
<script>
function showTab(tabName) {
const tabs = document.querySelectorAll('.tab-content');
tabs.forEach(tab => tab.classList.remove('active'));
const buttons = document.querySelectorAll('.tab-button');
buttons.forEach(btn => btn.classList.remove('active'));
document.getElementById(tabName).classList.add('active');
event.target.classList.add('active');
}
</script>
</body>
</html>