Skip to content

Commit 2d5ce13

Browse files
committed
fix: address additional Copilot review feedback
- Add timeout parameters to subprocess calls in snapshot.py and git_analysis.py - Fix debt marker regex pattern (remove literal pipe from character class) - Fix import pattern regex to avoid cross-statement matches - Use astral-sh/setup-uv@v4 action instead of curl | sh
1 parent 93b7995 commit 2d5ce13

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

.github/workflows/code-analysis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ jobs:
2323
python-version: '3.12'
2424

2525
- name: Install uv
26-
run: |
27-
curl -LsSf https://astral.sh/uv/install.sh | sh
28-
echo "$HOME/.local/bin" >> $GITHUB_PATH
26+
uses: astral-sh/setup-uv@v4
2927

3028
- name: Install analysis dependencies
3129
working-directory: analysis

analysis/debt_indicators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ def to_dict(self) -> dict:
6969

7070
# Debt marker patterns
7171
DEBT_PATTERNS = [
72-
(r"#\s*(TODO|FIXME|HACK|XXX|BUG|REFACTOR|OPTIMIZE|REVIEW)[:|\s](.+)$", "python"),
72+
(r"#\s*(TODO|FIXME|HACK|XXX|BUG|REFACTOR|OPTIMIZE|REVIEW)[:\s](.+)$", "python"),
7373
(
74-
r"//\s*(TODO|FIXME|HACK|XXX|BUG|REFACTOR|OPTIMIZE|REVIEW)[:|\s](.+)$",
74+
r"//\s*(TODO|FIXME|HACK|XXX|BUG|REFACTOR|OPTIMIZE|REVIEW)[:\s](.+)$",
7575
"typescript",
7676
),
7777
(
78-
r"/\*\s*(TODO|FIXME|HACK|XXX|BUG|REFACTOR|OPTIMIZE|REVIEW)[:|\s](.+?)\*/",
78+
r"/\*\s*(TODO|FIXME|HACK|XXX|BUG|REFACTOR|OPTIMIZE|REVIEW)[:\s](.+?)\*/",
7979
"typescript",
8080
),
8181
]

analysis/dependency_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def extract_imports_typescript(
122122
# import './path'
123123
# const x = require('./path')
124124
import_patterns = [
125-
r'import\s+(?:.*?\s+from\s+)?[\'"]([^\'"]+)[\'"]',
125+
r'import\s+(?:[^\'";]+?\s+from\s+)?[\'"]([^\'"]+)[\'"]',
126126
r'require\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)',
127127
r'import\s*\(\s*[\'"]([^\'"]+)[\'"]\s*\)', # dynamic import
128128
]

analysis/git_analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def run_git_command(args: List[str], cwd: pathlib.Path) -> str:
9292
capture_output=True,
9393
text=True,
9494
check=True,
95+
timeout=60,
9596
)
9697
return result.stdout
9798

analysis/snapshot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def get_git_info(repo_root: pathlib.Path) -> dict:
3434
capture_output=True,
3535
text=True,
3636
check=True,
37+
timeout=10,
3738
).stdout.strip()
3839

3940
short_sha = subprocess.run(
@@ -42,6 +43,7 @@ def get_git_info(repo_root: pathlib.Path) -> dict:
4243
capture_output=True,
4344
text=True,
4445
check=True,
46+
timeout=10,
4547
).stdout.strip()
4648

4749
branch = subprocess.run(
@@ -50,6 +52,7 @@ def get_git_info(repo_root: pathlib.Path) -> dict:
5052
capture_output=True,
5153
text=True,
5254
check=True,
55+
timeout=10,
5356
).stdout.strip()
5457

5558
# Get commit message
@@ -59,6 +62,7 @@ def get_git_info(repo_root: pathlib.Path) -> dict:
5962
capture_output=True,
6063
text=True,
6164
check=True,
65+
timeout=10,
6266
).stdout.strip()
6367

6468
return {
@@ -67,7 +71,7 @@ def get_git_info(repo_root: pathlib.Path) -> dict:
6771
"branch": branch,
6872
"message": message[:200], # Truncate long messages
6973
}
70-
except subprocess.CalledProcessError:
74+
except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
7175
return {
7276
"sha": "unknown",
7377
"short_sha": "unknown",

0 commit comments

Comments
 (0)