@@ -34,7 +34,7 @@ def analyze_file(file_path: str, selected_stats=None):
3434 # comment line count if requested
3535 if "comment_line_count" in selected_stats :
3636 from spice .analyzers .count_comment_lines import count_comment_lines
37- results ["comment_line_count" ] = count_comment_lines (code )
37+ results ["comment_line_count" ] = count_comment_lines (file_path )
3838
3939 # indentation analysis if requested
4040 if "indentation_level" in selected_stats :
@@ -43,27 +43,9 @@ def analyze_file(file_path: str, selected_stats=None):
4343 results ["indentation_size" ] = indentation_info ["indent_size" ]
4444 results ["indentation_levels" ] = indentation_info ["levels" ]
4545
46- # only put the code through the lexer and proceed with tokenization if needed
47- if any (stat in selected_stats for stat in ["function_count" ]):
48- # get the lexer for the code's language
49- from utils .get_lexer import get_lexer_for_file
50- LexerClass = get_lexer_for_file (file_path )
51-
52- # tokenize the code via lexer
53- lexer = LexerClass (code )
54- tokens = lexer .tokenize ()
55-
56- # only put the code through the parser and proceed with parsing if needed
57- if "function_count" in selected_stats :
58- # import parser here to avoid circular import issues
59- from parser .parser import Parser
60-
61- # parse tokens into AST
62- parser = Parser (tokens )
63- ast = parser .parse ()
64-
65- # count functions
66- from spice .analyzers .count_functions import count_functions
67- results ["function_count" ] = count_functions (ast )
46+ # function count if requested
47+ if "function_count" in selected_stats :
48+ from spice .analyzers .count_functions import count_functions
49+ results ["function_count" ] = count_functions (file_path )
6850
6951 return results
0 commit comments