fix: resolve CI linting errors
This commit is contained in:
@@ -81,7 +81,9 @@ class CodeAnalyzer:
|
|||||||
node_type = node.type
|
node_type = node.type
|
||||||
node_text = node.text.decode() if isinstance(node.text, bytes) else node.text
|
node_text = node.text.decode() if isinstance(node.text, bytes) else node.text
|
||||||
|
|
||||||
function_keywords = ['function_definition', 'function_declaration', 'method_definition', 'func']
|
function_keywords = [
|
||||||
|
'function_definition', 'function_declaration', 'method_definition', 'func'
|
||||||
|
]
|
||||||
class_keywords = ['class_definition', 'class_declaration', 'struct', 'impl']
|
class_keywords = ['class_definition', 'class_declaration', 'struct', 'impl']
|
||||||
import_keywords = ['import_statement', 'import_from_statement', 'import', 'require']
|
import_keywords = ['import_statement', 'import_from_statement', 'import', 'require']
|
||||||
call_keywords = ['call_expression', 'function_call', 'method_call', 'expression_statement']
|
call_keywords = ['call_expression', 'function_call', 'method_call', 'expression_statement']
|
||||||
@@ -157,34 +159,45 @@ class CodeAnalyzer:
|
|||||||
lines = code.splitlines()
|
lines = code.splitlines()
|
||||||
summary_parts = []
|
summary_parts = []
|
||||||
|
|
||||||
added_lines = [l for l in lines if l.strip().startswith('+') and not l.strip().startswith('+++')]
|
added_lines = [
|
||||||
removed_lines = [l for l in lines if l.strip().startswith('-') and not l.strip().startswith('---')]
|
line for line in lines
|
||||||
|
if line.strip().startswith('+') and not line.strip().startswith('+++')
|
||||||
|
]
|
||||||
|
removed_lines = [
|
||||||
|
line for line in lines
|
||||||
|
if line.strip().startswith('-') and not line.strip().startswith('---')
|
||||||
|
]
|
||||||
|
|
||||||
if added_lines or removed_lines:
|
if added_lines or removed_lines:
|
||||||
summary_parts.append(f"Added {len(added_lines)} lines, removed {len(removed_lines)} lines")
|
summary_parts.append(
|
||||||
|
f"Added {len(added_lines)} lines, removed {len(removed_lines)} lines"
|
||||||
|
)
|
||||||
|
|
||||||
func_patterns = {
|
func_patterns = {
|
||||||
'python': r'^def\s+(\w+)',
|
'python': r'^def\\s+(\\w+)',
|
||||||
'javascript': r'^function\s+(\w+)|const\s+(\w+)\s*=\s*function',
|
'javascript': r'^function\\s+(\\w+)|const\\s+(\\w+)\\s*=\\s*function',
|
||||||
'java': r'^\s*(public|private|protected)?\s*(static\s+)?\s*\w+\s+(\w+)\s*\(',
|
'java': r'^\\s*(public|private|protected)?\\s*(static\\s+)?\\s*\\w+\\s+(\\w+)\\s*\\(',
|
||||||
'go': r'^func\s+(\w+)',
|
'go': r'^func\\s+(\\w+)',
|
||||||
'rust': r'^fn\s+(\w+)',
|
'rust': r'^fn\\s+(\\w+)',
|
||||||
}
|
}
|
||||||
|
|
||||||
for lang, pattern in func_patterns.items():
|
for lang, pattern in func_patterns.items():
|
||||||
funcs = re.findall(pattern, code, re.MULTILINE)
|
funcs = re.findall(pattern, code, re.MULTILINE)
|
||||||
if funcs:
|
if funcs:
|
||||||
func_names = [f if isinstance(f, str) else next((x for x in f if x), '') for f in funcs]
|
func_names = [
|
||||||
|
f if isinstance(f, str) else next((x for x in f if x), '')
|
||||||
|
for f in funcs
|
||||||
|
]
|
||||||
func_names = [n for n in func_names if n]
|
func_names = [n for n in func_names if n]
|
||||||
if func_names:
|
if func_names:
|
||||||
summary_parts.append(f"Functions: {', '.join(func_names[:5])}")
|
summary_parts.append(f"Functions: {', '.join(func_names[:5])}")
|
||||||
break
|
break
|
||||||
|
|
||||||
class_patterns = {
|
class_patterns = {
|
||||||
'python': r'^class\s+(\w+)',
|
'python': r'^class\\s+(\\w+)',
|
||||||
'javascript': r'^class\s+(\w+)',
|
'javascript': r'^class\\s+(\\w+)',
|
||||||
'java': r'^\s*class\s+(\w+)',
|
'java': r'^\\s*class\\s+(\\w+)',
|
||||||
'rust': r'^struct\s+(\w+)',
|
'rust': r'^struct\\s+(\\w+)',
|
||||||
}
|
}
|
||||||
|
|
||||||
for lang, pattern in class_patterns.items():
|
for lang, pattern in class_patterns.items():
|
||||||
|
|||||||
Reference in New Issue
Block a user