Skip to content

Commit fc4b439

Browse files
committed
fix: address more Copilot review feedback
- Use relative imports in snapshot.py for proper package structure - Add traceback.print_exc() for better CI debugging on failures - Add test file patterns to _should_skip_file in git_analysis.py - Include .tsx, .js, .jsx in complexity analysis (not just .ts) - Update workflow to use 'python -m analysis.snapshot' invocation - Update skill docs with new execution method
1 parent 2e5a275 commit fc4b439

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

.github/skills/generate-snapshot/SKILL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ This skill generates a comprehensive code health snapshot using the analysis mod
1919
## How to Generate
2020

2121
```powershell
22-
cd analysis
23-
python snapshot.py --output ../analysis-snapshot.json
22+
# From repository root
23+
python -m analysis.snapshot --output analysis-snapshot.json
2424
```
2525

2626
Add `--pretty` flag to also print the JSON to stdout.
2727

28-
**Note:** The snapshot is written to the repository root (`analysis-snapshot.json`), not inside the `analysis/` folder. This path is ignored by `.gitignore`.
28+
**Note:** The snapshot is written to the repository root (`analysis-snapshot.json`). This path is ignored by `.gitignore`.
2929

3030
## Snapshot Structure
3131

.github/workflows/code-analysis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ jobs:
3131
uv pip install --system .
3232
3333
- name: Generate snapshot
34-
working-directory: analysis
3534
run: |
36-
python snapshot.py --output ../analysis-snapshot.json
35+
python -m analysis.snapshot --output analysis-snapshot.json
3736
3837
- name: Upload snapshot artifact
3938
uses: actions/upload-artifact@v4

analysis/complexity_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ def analyze_complexity(repo_root: pathlib.Path) -> dict:
279279
if file_complexity:
280280
results["python"].append(file_complexity.to_dict())
281281

282-
# Analyze TypeScript files
283-
ts_files = find_source_files(repo_root, [".ts"])
282+
# Analyze TypeScript/JavaScript files
283+
ts_files = find_source_files(repo_root, [".ts", ".tsx", ".js", ".jsx"])
284284
for filepath in ts_files:
285285
file_complexity = analyze_typescript_file(filepath, repo_root)
286286
if file_complexity:

analysis/git_analysis.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ def _should_skip_file(filepath: str) -> bool:
207207
".git/",
208208
"package-lock.json",
209209
".vsix",
210+
# Skip test files and directories
211+
"/test/",
212+
"/tests/",
213+
"/__tests__/",
214+
".test.",
215+
".spec.",
216+
"_test.",
217+
"_spec.",
218+
"/mocks/",
210219
]
211220
return any(pattern in filepath for pattern in skip_patterns)
212221

analysis/snapshot.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
import pathlib
1313
import subprocess
1414
import sys
15+
import traceback
1516
from datetime import datetime, timezone
1617
from typing import Optional
1718

18-
# Import analysis modules
19-
from complexity_analysis import analyze_complexity
20-
from debt_indicators import analyze_debt
21-
from dependency_analysis import analyze_dependencies
22-
from git_analysis import analyze_repository as analyze_git
19+
# Import analysis modules (relative imports for package structure)
20+
from .complexity_analysis import analyze_complexity
21+
from .debt_indicators import analyze_debt
22+
from .dependency_analysis import analyze_dependencies
23+
from .git_analysis import analyze_repository as analyze_git
2324

2425
# Snapshot schema version - increment when breaking changes are made
2526
SCHEMA_VERSION = "1.0.0"
@@ -285,6 +286,7 @@ def main() -> int:
285286
return 0
286287
except Exception as e:
287288
print(f"Error generating snapshot: {e}", file=sys.stderr)
289+
traceback.print_exc()
288290
return 1
289291

290292

0 commit comments

Comments
 (0)