-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build|docs): #15 add function level complexity analysis
- Add function level complexity analysis - Add tests for function level complexity analysis - Enhance the output of the analysis - Create a new file to store the types used in the project - Create a new file to store the utils used in the project - Write the csv file with the function level complexity analysis - Write the csv files using Rust instead of Python. - Enhance the table output of the analysis - Update the README file to include the new features
- Loading branch information
1 parent
a175c28
commit d26d0d5
Showing
13 changed files
with
324 additions
and
86 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from enum import Enum | ||
|
||
|
||
class DetailTypes(Enum): | ||
low = "low" # Show only files with complexity above the max_complexity | ||
normal = "normal" # Show all files with their complexity | ||
|
||
|
||
class Level(Enum): | ||
function = "function" | ||
file = "file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from .types import ( | ||
DetailTypes, | ||
) | ||
from complexipy.rust import ( | ||
FileComplexity, | ||
) | ||
from rich.table import Table | ||
|
||
|
||
def create_table_file_level( | ||
files: list[FileComplexity], max_complexity: int, details: DetailTypes | ||
) -> tuple[Table, bool, int]: | ||
has_success = True | ||
|
||
table = Table( | ||
title="Summary", show_header=True, header_style="bold magenta", show_lines=True | ||
) | ||
table.add_column("Path") | ||
table.add_column("File") | ||
table.add_column("Complexity") | ||
total_complexity = 0 | ||
for file in files: | ||
total_complexity += file.complexity | ||
if file.complexity > max_complexity and max_complexity != 0: | ||
table.add_row( | ||
f"{file.path}", | ||
f"[green]{file.file_name}[/green]", | ||
f"[red]{file.complexity}[/red]", | ||
) | ||
has_success = False | ||
elif details != DetailTypes.low or max_complexity == 0: | ||
table.add_row( | ||
f"{file.path}", | ||
f"[green]{file.file_name}[/green]", | ||
f"[blue]{file.complexity}[/blue]", | ||
) | ||
return table, has_success, total_complexity | ||
|
||
|
||
def create_table_function_level( | ||
files: list[FileComplexity], complexity: int, details: DetailTypes | ||
) -> tuple[Table, bool, int]: | ||
has_success = True | ||
|
||
table = Table( | ||
title="Summary", show_header=True, header_style="bold magenta", show_lines=True | ||
) | ||
table.add_column("Path") | ||
table.add_column("File") | ||
table.add_column("Function") | ||
table.add_column("Complexity") | ||
total_complexity = 0 | ||
for file in files: | ||
total_complexity += file.complexity | ||
for function in file.functions: | ||
total_complexity += function.complexity | ||
if function.complexity > complexity and complexity != 0: | ||
table.add_row( | ||
f"{file.path}", | ||
f"[green]{file.file_name}[/green]", | ||
f"[green]{function.name}[/green]", | ||
f"[red]{function.complexity}[/red]", | ||
) | ||
has_success = False | ||
elif details != DetailTypes.low or complexity == 0: | ||
table.add_row( | ||
f"{file.path}", | ||
f"[green]{file.file_name}[/green]", | ||
f"[green]{function.name}[/green]", | ||
f"[blue]{function.complexity}[/blue]", | ||
) | ||
return table, has_success, total_complexity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.