Skip to content

Commit 793ab83

Browse files
committed
fixes
1 parent ae05edb commit 793ab83

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

cli/commands/comment_ratio.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,43 @@ def comment_code_ratio_stats(
1818
Analyzes and reports the comment to code ratio for the given file.
1919
"""
2020
if not os.path.exists(file_path):
21-
console.print(f"[bold red]{get_translation("error_file_not_found")}: {file_path}[/bold red]")
21+
console.print(f"[bold red]{get_translation('error_file_not_found')}: {file_path}[/bold red]")
2222
raise typer.Exit(code=1)
2323
if not os.path.isfile(file_path):
24-
console.print(f"[bold red]{get_translation("error_not_a_file")}: {file_path}[/bold red]")
24+
console.print(f"[bold red]{get_translation('error_not_a_file')}: {file_path}[/bold red]")
2525
raise typer.Exit(code=1)
2626

2727
try:
2828
with open(file_path, "r", encoding="utf-8") as f:
2929
content = f.read()
3030
except Exception as e:
31-
console.print(f"[bold red]{get_translation("error_reading_file")} {file_path}: {e}[/bold red]")
31+
console.print(f"[bold red]{get_translation('error_reading_file')} {file_path}: {e}[/bold red]")
3232
raise typer.Exit(code=1)
3333

3434
results = analyze_comment_code_ratio(content)
3535

3636
if output_format == "json":
3737
console.print(json.dumps(results, indent=2))
3838
elif output_format == "console":
39-
console.print(f"\n[bold cyan]{get_translation("comment_code_ratio_analysis_for")} [green]{file_path}[/green]:[/bold cyan]")
39+
console.print(f"\n[bold cyan]{get_translation('comment_code_ratio_analysis_for')} [green]{file_path}[/green]:[/bold cyan]")
4040
summary = results.get("summary_stats", {})
4141

42-
table_summary = Table(title=get_translation("summary_statistics"))
43-
table_summary.add_column(get_translation("metric"), style="dim")
44-
table_summary.add_column(get_translation("value"), justify="right")
45-
table_summary.add_row(get_translation("total_lines"), str(summary.get("total_lines_in_file", 0)))
46-
table_summary.add_row(get_translation("code_lines"), str(summary.get("code_lines", 0)))
47-
table_summary.add_row(get_translation("comment_lines"), str(summary.get("comment_only_lines", 0)))
48-
table_summary.add_row(get_translation("empty_lines"), str(summary.get("empty_or_whitespace_lines", 0)))
49-
table_summary.add_row(get_translation("comment_code_ratio"), f"{summary.get("comment_to_code_plus_comment_ratio", 0):.2%}")
42+
table_summary = Table(title=get_translation('summary_statistics'))
43+
table_summary.add_column(get_translation('metric'), style="dim")
44+
table_summary.add_column(get_translation('value'), justify="right")
45+
table_summary.add_row(get_translation('total_lines'), str(summary.get("total_lines_in_file", 0)))
46+
table_summary.add_row(get_translation('code_lines'), str(summary.get("code_lines", 0)))
47+
table_summary.add_row(get_translation('comment_lines'), str(summary.get("comment_only_lines", 0)))
48+
table_summary.add_row(get_translation('empty_lines'), str(summary.get("empty_or_whitespace_lines", 0)))
49+
table_summary.add_row(get_translation('comment_code_ratio'), f"{summary.get('comment_to_code_plus_comment_ratio', 0):.2%}")
5050
console.print(table_summary)
5151

5252
line_details = results.get("line_by_line_analysis", [])
5353
if line_details:
54-
table_details = Table(title=get_translation("line_by_line_classification"))
55-
table_details.add_column(get_translation("line_num"), style="dim", width=6)
56-
table_details.add_column(get_translation("line_type"), style="dim")
57-
table_details.add_column(get_translation("content_col"))
54+
table_details = Table(title=get_translation('line_by_line_classification'))
55+
table_details.add_column(get_translation('line_num'), style="dim", width=6)
56+
table_details.add_column(get_translation('line_type'), style="dim")
57+
table_details.add_column(get_translation('content_col'))
5858
for line_data in line_details:
5959
table_details.add_row(
6060
str(line_data["original_line_number"]),
@@ -63,7 +63,7 @@ def comment_code_ratio_stats(
6363
)
6464
console.print(table_details)
6565
else:
66-
console.print(f"[bold red]{get_translation("error_invalid_format")}: {output_format}. {get_translation("valid_formats_are")} console, json.[/bold red]")
66+
console.print(f"[bold red]{get_translation('error_invalid_format')}: {output_format}. {get_translation('valid_formats_are')} console, json.[/bold red]")
6767
raise typer.Exit(code=1)
6868

6969
if __name__ == "__main__":

cli/commands/dependencies.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ def dependency_stats(
1818
Analyzes and reports the external dependencies for the given file.
1919
"""
2020
if not os.path.exists(file_path):
21-
console.print(f"[bold red]{get_translation("error_file_not_found")}: {file_path}[/bold red]")
21+
console.print(f"[bold red]{get_translation('error_file_not_found')}: {file_path}[/bold red]")
2222
raise typer.Exit(code=1)
2323
if not os.path.isfile(file_path):
24-
console.print(f"[bold red]{get_translation("error_not_a_file")}: {file_path}[/bold red]")
24+
console.print(f"[bold red]{get_translation('error_not_a_file')}: {file_path}[/bold red]")
2525
raise typer.Exit(code=1)
2626

2727
try:
2828
with open(file_path, "r", encoding="utf-8") as f:
2929
content = f.read()
3030
except Exception as e:
31-
console.print(f"[bold red]{get_translation("error_reading_file")} {file_path}: {e}[/bold red]")
31+
console.print(f"[bold red]{get_translation('error_reading_file')} {file_path}: {e}[/bold red]")
3232
raise typer.Exit(code=1)
3333

3434
results = analyze_dependencies(content, file_name_for_error_reporting=file_path)
@@ -37,13 +37,13 @@ def dependency_stats(
3737
# The analyzer returns a list of imports or an error dict
3838
console.print(json.dumps(results, indent=2))
3939
elif output_format == "console":
40-
console.print(f"\n[bold cyan]{get_translation("dependency_analysis_for")} [green]{file_path}[/green]:[/bold cyan]")
40+
console.print(f"\n[bold cyan]{get_translation('dependency_analysis_for')} [green]{file_path}[/green]:[/bold cyan]")
4141
if isinstance(results, dict) and "error" in results:
4242
console.print(f"[bold red]Error analyzing dependencies: {results['error']}[/bold red]")
4343
elif isinstance(results, list):
4444
if results:
45-
table = Table(title=get_translation("dependencies_found"))
46-
table.add_column(get_translation("dependency_name"), style="dim")
45+
table = Table(title=get_translation('dependencies_found'))
46+
table.add_column(get_translation('dependency_name'), style="dim")
4747
for dep in sorted(results):
4848
table.add_row(dep)
4949
console.print(table)
@@ -53,7 +53,7 @@ def dependency_stats(
5353
console.print(f"[bold red]{get_translation('error_unexpected_result')}[/bold red]")
5454

5555
else:
56-
console.print(f"[bold red]{get_translation("error_invalid_format")}: {output_format}. {get_translation("valid_formats_are")} console, json.[/bold red]")
56+
console.print(f"[bold red]{get_translation('error_invalid_format')}: {output_format}. {get_translation('valid_formats_are')} console, json.[/bold red]")
5757
raise typer.Exit(code=1)
5858

5959
if __name__ == "__main__":

cli/commands/visibility.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@ def visibility_stats(
1818
Analyzes and reports the visibility of functions and methods (public/private) in the given file.
1919
"""
2020
if not os.path.exists(file_path):
21-
console.print(f"[bold red]{get_translation("error_file_not_found")}: {file_path}[/bold red]")
21+
console.print(f"[bold red]{get_translation('error_file_not_found')}: {file_path}[/bold red]")
2222
raise typer.Exit(code=1)
2323
if not os.path.isfile(file_path):
24-
console.print(f"[bold red]{get_translation("error_not_a_file")}: {file_path}[/bold red]")
24+
console.print(f"[bold red]{get_translation('error_not_a_file')}: {file_path}[/bold red]")
2525
raise typer.Exit(code=1)
2626

2727
try:
2828
with open(file_path, "r", encoding="utf-8") as f:
2929
content = f.read()
3030
except Exception as e:
31-
console.print(f"[bold red]{get_translation("error_reading_file")} {file_path}: {e}[/bold red]")
31+
console.print(f"[bold red]{get_translation('error_reading_file')} {file_path}: {e}[/bold red]")
3232
raise typer.Exit(code=1)
3333

3434
results = analyze_visibility(content, file_name_for_error_reporting=file_path)
3535

3636
if output_format == "json":
3737
console.print(json.dumps(results, indent=2))
3838
elif output_format == "console":
39-
console.print(f"\n[bold cyan]{get_translation("visibility_analysis_for")} [green]{file_path}[/green]:[/bold cyan]")
39+
console.print(f"\n[bold cyan]{get_translation('visibility_analysis_for')} [green]{file_path}[/green]:[/bold cyan]")
4040

4141
if isinstance(results, dict) and "error" in results:
42-
console.print(f"[bold red]{get_translation("error_analyzing_visibility")}: {results["error"]}[/bold red]")
42+
console.print(f"[bold red]{get_translation('error_analyzing_visibility')}: {results['error']}[/bold red]")
4343
raise typer.Exit(code=1)
4444

45-
summary_table = Table(title=get_translation("visibility_summary"))
46-
summary_table.add_column(get_translation("category"), style="dim")
47-
summary_table.add_column(get_translation("count"), justify="right")
48-
summary_table.add_row(get_translation("public_functions"), str(results.get("public_functions", 0)))
49-
summary_table.add_row(get_translation("private_functions"), str(results.get("private_functions", 0)))
50-
summary_table.add_row(get_translation("public_methods"), str(results.get("public_methods", 0)))
51-
summary_table.add_row(get_translation("private_methods"), str(results.get("private_methods", 0)))
45+
summary_table = Table(title=get_translation('visibility_summary'))
46+
summary_table.add_column(get_translation('category'), style="dim")
47+
summary_table.add_column(get_translation('count'), justify="right")
48+
summary_table.add_row(get_translation('public_functions'), str(results.get("public_functions", 0)))
49+
summary_table.add_row(get_translation('private_functions'), str(results.get("private_functions", 0)))
50+
summary_table.add_row(get_translation('public_methods'), str(results.get("public_methods", 0)))
51+
summary_table.add_row(get_translation('private_methods'), str(results.get("private_methods", 0)))
5252
console.print(summary_table)
5353

5454
details = results.get("details", [])
5555
if details:
56-
details_table = Table(title=get_translation("details_by_element"))
57-
details_table.add_column(get_translation("name"), style="dim")
58-
details_table.add_column(get_translation("type"))
59-
details_table.add_column(get_translation("visibility"))
60-
details_table.add_column(get_translation("line_num"), justify="right")
56+
details_table = Table(title=get_translation('details_by_element'))
57+
details_table.add_column(get_translation('name'), style="dim")
58+
details_table.add_column(get_translation('type'))
59+
details_table.add_column(get_translation('visibility'))
60+
details_table.add_column(get_translation('line_num'), justify="right")
6161
for item in details:
6262
details_table.add_row(
6363
item.get("name"),
@@ -70,7 +70,7 @@ def visibility_stats(
7070
console.print(get_translation("no_elements_found_for_visibility"))
7171

7272
else:
73-
console.print(f"[bold red]{get_translation("error_invalid_format")}: {output_format}. {get_translation("valid_formats_are")} console, json.[/bold red]")
73+
console.print(f"[bold red]{get_translation('error_invalid_format')}: {output_format}. {get_translation('valid_formats_are')} console, json.[/bold red]")
7474
raise typer.Exit(code=1)
7575

7676
if __name__ == "__main__":

0 commit comments

Comments
 (0)