diff --git a/cli/commands/analyze.py b/cli/commands/analyze.py index 595afa9..76f4e01 100644 --- a/cli/commands/analyze.py +++ b/cli/commands/analyze.py @@ -17,7 +17,6 @@ def analyze_command(file, all, json_output, LANG_FILE): "line_count", "function_count", "comment_line_count", - "inline_comment_count", "indentation_level" ] @@ -26,7 +25,6 @@ def analyze_command(file, all, json_output, LANG_FILE): "line_count": messages.get("line_count_option", "Line Count"), "function_count": messages.get("function_count_option", "Function Count"), "comment_line_count": messages.get("comment_line_count_option", "Comment Line Count"), - "inline_comment_count": messages.get("inline_comment_count_option", "Inline Comment Count"), "indentation_level": messages.get("indentation_level_option", "Indentation Analysis") } diff --git a/cli/translations/en.py b/cli/translations/en.py index 7c9885a..0e3973a 100644 --- a/cli/translations/en.py +++ b/cli/translations/en.py @@ -9,13 +9,11 @@ "line_count": "The file has {count} lines", "function_count": "The file has {count} functions", "comment_line_count": "The file has {count} comment lines", - "inline_comment_count": "The file has {count} inline comments", # keys for analyze command checkbox menu "select_stats": "Select stats to display:", "line_count_option": "Line Count", "function_count_option": "Function Count", "comment_line_count_option": "Comment Line Count", - "inline_comment_count_option": "Inline Comment Count", "no_stats_selected": "No stats selected. Analysis cancelled.", "confirm_and_analyze": "Confirm and analyze", "checkbox_hint": "(Use space to select, enter to confirm)", diff --git a/cli/translations/fremen.py b/cli/translations/fremen.py index f7bb68b..546903c 100644 --- a/cli/translations/fremen.py +++ b/cli/translations/fremen.py @@ -1,7 +1,7 @@ messages = { # keys for the hello command "welcome": "🌶️ Salam, wanderer, and welcome to the sietch of [bold red]SpiceCode[/]! 🌶️", - "description": "🔥 The [yellow]Fedaykin CLI[/] that ignites your code with spice, as fierce as Arrakis' dunes 🥵", + "description": "🔥 The [yellow]Fedaykin CLI[/] that ignites your code with spice, as fierce as Arrakis’ dunes 🥵", # error messages "error": "خطأ:", # keys for the analyze command output @@ -9,13 +9,11 @@ "line_count": "The file spans {count} dunes", "function_count": "The file holds {count} sacred routines", "comment_line_count": "The file whispers {count} lines of hidden lore", - "inline_comment_count": "The file contains {count} passages of dual meaning", # keys for analyze command checkbox menu "select_stats": "Choose the omens to unveil:", "line_count_option": "Dune Count", "function_count_option": "Sacred Routines", "comment_line_count_option": "Whispered Lore", - "inline_comment_count_option": "Passages of Dual Meaning", "no_stats_selected": "No omens were heeded. The analysis fades into the sands.", "confirm_and_analyze": "Seal your fate and analyze", "checkbox_hint": "(Use space to mark, enter to proceed)" diff --git a/cli/translations/pt-br.py b/cli/translations/pt-br.py index c5afdf9..abaff61 100644 --- a/cli/translations/pt-br.py +++ b/cli/translations/pt-br.py @@ -9,13 +9,11 @@ "line_count": "O arquivo tem {count} linhas", "function_count": "O arquivo tem {count} funções", "comment_line_count": "O arquivo tem {count} linhas de comentário", - "inline_comment_count": "O arquivo tem {count} comentários inline", # chaves para o menu de seleção do comando analyze "select_stats": "Selecione as estatísticas para exibir:", "line_count_option": "Contagem de Linhas", "function_count_option": "Contagem de Funções", "comment_line_count_option": "Contagem de Linhas de Comentário", - "inline_comment_count_option": "Contagem de Comentários Inline", "no_stats_selected": "Nenhuma estatística selecionada. Análise cancelada.", "confirm_and_analyze": "Confirmar e analisar", "checkbox_hint": "(Use espaço para selecionar, enter para confirmar)" diff --git a/spice/analyze.py b/spice/analyze.py index ca40aa4..1ecb34a 100644 --- a/spice/analyze.py +++ b/spice/analyze.py @@ -10,8 +10,7 @@ def analyze_file(file_path: str, selected_stats: Optional[List[str]] = None) -> Args: file_path (str): Path to the file to analyze selected_stats (list, optional): List of stats to compute. If None, compute all stats. - Valid stats are: "line_count", "function_count", "comment_line_count", - "inline_comment_count", "indentation_level" + Valid stats are: "line_count", "function_count", "comment_line_count", "indentation_level" Returns: dict: Dictionary containing the requested stats and file information @@ -35,7 +34,7 @@ def analyze_file(file_path: str, selected_stats: Optional[List[str]] = None) -> raise ValueError("File has no extension") # Define valid stats - valid_stats = ["line_count", "function_count", "comment_line_count", "inline_comment_count", "indentation_level"] + valid_stats = ["line_count", "function_count", "comment_line_count", "indentation_level"] # default to all stats if none specified if selected_stats is None: @@ -72,14 +71,6 @@ def analyze_file(file_path: str, selected_stats: Optional[List[str]] = None) -> lexer = LexerClass(source_code=code) # Pass source_code explicitly results["comment_line_count"] = count_comment_lines(file_path) - # inline comment count if requested - if "inline_comment_count" in selected_stats: - from spice.analyzers.count_inline_comments import count_inline_comments - from utils.get_lexer import get_lexer_for_file - LexerClass = get_lexer_for_file(file_path) - lexer = LexerClass(source_code=code) # Pass source_code explicitly - results["inline_comment_count"] = count_inline_comments(file_path) - # indentation analysis if requested if "indentation_level" in selected_stats: indentation_info = detect_indentation(code) diff --git a/spice/analyzers/count_inline_comments.py b/spice/analyzers/count_inline_comments.py deleted file mode 100644 index 381912b..0000000 --- a/spice/analyzers/count_inline_comments.py +++ /dev/null @@ -1,52 +0,0 @@ -# this will count inline comments, which are lines that have both code and comments -# INLINE COMMENT LINE IS A LINE THAT HAS BOTH CODE AND A COMMENT -# so like: y = 5 #sets y to 5 IS AN INLINE COMMENT LINE!!!!!!!! -from utils.get_lexer import get_lexer_for_file -from lexers.token import TokenType -import os - -def count_inline_comments(file_path): - """Count lines that have both code and comments in a file. - - Args: - file_path (str): Path to the file to analyze - - Returns: - int: Number of lines that have both code and comments - """ - # Get the appropriate lexer for the file - Lexer = get_lexer_for_file(file_path) - - # Read the file content - with open(file_path, 'r', encoding='utf-8') as f: - code = f.read() - - # Initialize lexer with source code - lexer = Lexer(source_code=code) - - # Get all tokens - tokens = lexer.tokenize() - - # Group tokens by line number - tokens_by_line = {} - for token in tokens: - if token.line not in tokens_by_line: - tokens_by_line[token.line] = [] - tokens_by_line[token.line].append(token) - - # Count lines that have both code and comment tokens - inline_comment_count = 0 - for line_num, line_tokens in tokens_by_line.items(): - has_comment = False - has_code = False - - for token in line_tokens: - if token.type == TokenType.COMMENT: - has_comment = True - elif token.type not in [TokenType.NEWLINE, TokenType.COMMENT]: - has_code = True - - if has_comment and has_code: - inline_comment_count += 1 - - return inline_comment_count