|
1 | 1 | import os |
2 | 2 | from typing import List, Dict, Optional, Union |
3 | 3 |
|
4 | | -from spice.analyzers.identation import detect_indentation |
| 4 | +from spice.analyzers.indentation import detect_indentation |
5 | 5 |
|
6 | 6 | def analyze_file(file_path: str, selected_stats: Optional[List[str]] = None) -> Dict[str, Union[int, str, List[int]]]: |
7 | 7 | """ |
@@ -35,7 +35,7 @@ def analyze_file(file_path: str, selected_stats: Optional[List[str]] = None) -> |
35 | 35 | raise ValueError("File has no extension") |
36 | 36 |
|
37 | 37 | # Define valid stats |
38 | | - valid_stats = ["line_count", "function_count", "comment_line_count", "inline_comment_count", "indentation_level"] |
| 38 | + valid_stats = ["line_count", "function_count", "comment_line_count", "inline_comment_count", "indentation_level", "external_dependencies_count", "method_type_count"] |
39 | 39 |
|
40 | 40 | # default to all stats if none specified |
41 | 41 | if selected_stats is None: |
@@ -82,19 +82,29 @@ def analyze_file(file_path: str, selected_stats: Optional[List[str]] = None) -> |
82 | 82 |
|
83 | 83 | # indentation analysis if requested |
84 | 84 | if "indentation_level" in selected_stats: |
85 | | - indentation_info = detect_indentation(code) |
86 | | - results["indentation_type"] = indentation_info["indent_type"] |
87 | | - results["indentation_size"] = indentation_info["indent_size"] |
88 | | - results["indentation_levels"] = indentation_info["levels"] |
89 | | - |
| 85 | + from spice.analyzers.indentation import detect_indentation |
| 86 | + indentation_info = detect_indentation(file_path) |
| 87 | + results["indentation_type"] = indentation_info["indentation_type"] |
| 88 | + results["indentation_size"] = indentation_info["indentation_size"] |
| 89 | + |
90 | 90 | # function count if requested |
91 | 91 | if "function_count" in selected_stats: |
92 | 92 | from spice.analyzers.count_functions import count_functions |
93 | | - from utils.get_lexer import get_lexer_for_file |
94 | | - LexerClass = get_lexer_for_file(file_path) |
95 | | - lexer = LexerClass(source_code=code) # Pass source_code explicitly |
96 | 93 | results["function_count"] = count_functions(file_path) |
97 | 94 |
|
| 95 | + # external dependencies count if requested |
| 96 | + if "external_dependencies_count" in selected_stats: |
| 97 | + from spice.analyzers.count_external_dependencies import count_external_dependencies |
| 98 | + results["external_dependencies_count"] = count_external_dependencies(file_path) |
| 99 | + |
| 100 | + # method type count if requested |
| 101 | + if "method_type_count" in selected_stats: |
| 102 | + from spice.analyzers.count_method_type import count_method_type |
| 103 | + private_methods, public_methods = count_method_type(file_path) |
| 104 | + results["method_type_count"] = { |
| 105 | + "private": private_methods, |
| 106 | + "public": public_methods |
| 107 | + } |
98 | 108 | return results |
99 | 109 |
|
100 | 110 | except Exception as e: |
|
0 commit comments