-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyzer.py
More file actions
34 lines (22 loc) · 736 Bytes
/
Copy pathanalyzer.py
File metadata and controls
34 lines (22 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def analyze_code(file_name, code):
issues = []
lines = code.split("\n")
# Large file detection
if len(lines) > 500:
issues.append(f"{file_name}: Large file (>500 lines)")
# Long function detection
function_length = 0
for line in lines:
if "def " in line or "function " in line:
function_length = 0
function_length += 1
if function_length > 50:
issues.append(f"{file_name}: Long function detected")
break
# Deep nesting detection
for line in lines:
indent = len(line) - len(line.lstrip())
if indent > 12:
issues.append(f"{file_name}: Deep nesting detected")
break
return issues