Skip to content

Commit 8571da7

Browse files
committed
add new analyzers to menu
1 parent 65f5e51 commit 8571da7

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

cli/commands/analyze.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def analyze_command(file, all, json_output, LANG_FILE):
6363
# load translations
6464
messages = get_translation(LANG_FILE)
6565

66-
# define available stats
66+
# define available stats (updated with new features)
6767
available_stats = [
6868
"line_count",
6969
"function_count",
@@ -73,9 +73,12 @@ def analyze_command(file, all, json_output, LANG_FILE):
7373
"external_dependencies_count",
7474
"method_type_count",
7575
"comment_ratio",
76+
"average_function_size",
77+
"duplicate_code_detection",
78+
"asymptotic_complexity"
7679
]
7780

78-
# dictionary for the stats
81+
# dictionary for the stats (updated with new features)
7982
stats_labels = {
8083
"line_count": messages.get("line_count_option", "Line Count"),
8184
"function_count": messages.get("function_count_option", "Function Count"),
@@ -87,6 +90,9 @@ def analyze_command(file, all, json_output, LANG_FILE):
8790
"private_methods_count": messages.get("private_methods_count_option", "Private Methods Count"),
8891
"public_methods_count": messages.get("public_methods_count_option", "Public Methods Count"),
8992
"comment_ratio": messages.get("comment_ratio_option", "Comment to Code Ratio"),
93+
"average_function_size": messages.get("average_function_size_option", "Average Function Size"),
94+
"duplicate_code_detection": messages.get("duplicate_code_detection_option", "Duplicate Code Detection"),
95+
"asymptotic_complexity": messages.get("asymptotic_complexity_option", "Asymptotic Complexity Analysis")
9096
}
9197

9298
# If --all flag is used, skip the selection menu and use all stats
@@ -156,10 +162,26 @@ def analyze_command(file, all, json_output, LANG_FILE):
156162
print(f"{messages.get('private_methods_count_option', 'Private Methods Count')}: {mtc['private']}")
157163
continue
158164

159-
if stat == "indentation_level" and "indentation_type" in results:
165+
elif stat == "indentation_level" and "indentation_type" in results:
160166
print(f"{messages.get('indentation_type', 'Indentation Type')}: {results.get('indentation_type', 'N/A')}")
161167
print(f"{messages.get('indentation_size', 'Indentation Size')}: {results.get('indentation_size', 'N/A')}")
162168
continue
169+
170+
elif stat == "duplicate_code_detection" and any(key in results for key in ["duplicate_blocks", "duplicate_lines", "duplicate_percentage"]):
171+
print(f"{messages.get('duplicate_blocks', 'Duplicate Blocks')}: {results.get('duplicate_blocks', 'N/A')}")
172+
print(f"{messages.get('duplicate_lines', 'Duplicate Lines')}: {results.get('duplicate_lines', 'N/A')}")
173+
print(f"{messages.get('duplicate_percentage', 'Duplicate Percentage')}: {results.get('duplicate_percentage', 'N/A')}%")
174+
continue
175+
176+
elif stat == "asymptotic_complexity" and any(key in results for key in ["average_complexity", "complexity_distribution", "total_analyzed_functions"]):
177+
print(f"{messages.get('average_complexity', 'Average Complexity')}: {results.get('average_complexity', 'N/A')}")
178+
print(f"{messages.get('total_analyzed_functions', 'Total Analyzed Functions')}: {results.get('total_analyzed_functions', 'N/A')}")
179+
complexity_dist = results.get('complexity_distribution', {})
180+
if complexity_dist:
181+
print(f"{messages.get('complexity_distribution', 'Complexity Distribution')}:")
182+
for complexity, count in complexity_dist.items():
183+
print(f" {complexity}: {count}")
184+
continue
163185

164186
elif stat in results:
165187
print(f"{stats_labels[stat]}: {results[stat]}")

0 commit comments

Comments
 (0)