fix: resolve CI/CD issues for Python project
This commit is contained in:
@@ -4,7 +4,6 @@ import re
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from shellgenius.config import get_config
|
|
||||||
from shellgenius.generation import ShellParser, get_ollama_client
|
from shellgenius.generation import ShellParser, get_ollama_client
|
||||||
|
|
||||||
|
|
||||||
@@ -173,7 +172,7 @@ class RefactoringAnalyzer:
|
|||||||
issues = self._find_issues(script)
|
issues = self._find_issues(script)
|
||||||
score = self._calculate_score(issues, script)
|
score = self._calculate_score(issues, script)
|
||||||
|
|
||||||
suggestions = self._generate_suggestions(issues, script)
|
suggestions = self._generate_suggestions( issues, script)
|
||||||
|
|
||||||
if include_suggestions:
|
if include_suggestions:
|
||||||
ai_suggestions = self._get_ai_suggestions(script, shell_type)
|
ai_suggestions = self._get_ai_suggestions(script, shell_type)
|
||||||
@@ -256,7 +255,7 @@ class RefactoringAnalyzer:
|
|||||||
"suggestion": "Use $() syntax instead",
|
"suggestion": "Use $() syntax instead",
|
||||||
"alternative": re.sub(r"`([^`]+)`", r"$(\1)", line),
|
"alternative": re.sub(r"`([^`]+)`", r"$(\1)", line),
|
||||||
}
|
}
|
||||||
if re.search(r"\[\s*[\^\]]+\]", line) and "=" in line:
|
if re.search(r"\[\s*[\]]+\]", line) and "=" in line:
|
||||||
return {
|
return {
|
||||||
"description": "Use of [ ] instead of [[ ]]",
|
"description": "Use of [ ] instead of [[ ]]",
|
||||||
"risk": "[ ] has limitations with pattern matching",
|
"risk": "[ ] has limitations with pattern matching",
|
||||||
@@ -283,7 +282,7 @@ class RefactoringAnalyzer:
|
|||||||
for issue in issues:
|
for issue in issues:
|
||||||
base_score -= severity_weights.get(issue.severity, 5)
|
base_score -= severity_weights.get(issue.severity, 5)
|
||||||
|
|
||||||
lines_count = len([l for l in script.split("\n") if l.strip()])
|
lines_count = len([line for line in script.split("\n") if line.strip()])
|
||||||
if lines_count > 0 and base_score > 50:
|
if lines_count > 0 and base_score > 50:
|
||||||
density_bonus = min(10, lines_count // 20)
|
density_bonus = min(10, lines_count // 20)
|
||||||
base_score += density_bonus
|
base_score += density_bonus
|
||||||
@@ -313,7 +312,7 @@ class RefactoringAnalyzer:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if issues:
|
if issues:
|
||||||
severity_counts = {}
|
severity_counts: Dict[str, int] = {}
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
severity_counts[issue.severity] = (
|
severity_counts[issue.severity] = (
|
||||||
severity_counts.get(issue.severity, 0) + 1
|
severity_counts.get(issue.severity, 0) + 1
|
||||||
@@ -367,7 +366,6 @@ class RefactoringAnalyzer:
|
|||||||
"""
|
"""
|
||||||
lines = script.split("\n")
|
lines = script.split("\n")
|
||||||
fixed_lines = []
|
fixed_lines = []
|
||||||
issue_map = {i.issue_type: i for i in issues}
|
|
||||||
|
|
||||||
for i, line in enumerate(lines, 1):
|
for i, line in enumerate(lines, 1):
|
||||||
stripped = line.strip()
|
stripped = line.strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user