From 2072cf7b9af888989fb82aa9644fb13871c8972f Mon Sep 17 00:00:00 2001 From: Caleb Date: Mon, 23 Oct 2023 09:43:44 -0400 Subject: [PATCH 01/11] created space between checks --- chasten/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chasten/main.py b/chasten/main.py index 77f7f252..67a4df92 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -656,6 +656,10 @@ def analyze( # noqa: PLR0913, PLR0915 current_check_save.matches.append(current_match_for_current_check_save) # type: ignore # add the current source to main object that contains a list of source chasten_results_save.sources.append(current_result_source) + output.console.print( + f" = Total" + ) + output.console.print() # display all of the analysis results if verbose output is requested output.print_analysis_details(chasten_results_save, verbose=verbose) # save all of the results from this analysis From b1b062a42421085d3bc2a9610ee0576af3343854 Mon Sep 17 00:00:00 2001 From: Caleb Date: Mon, 23 Oct 2023 09:44:40 -0400 Subject: [PATCH 02/11] removed extra space --- chasten/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 67a4df92..a8172bf8 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -668,14 +668,14 @@ def analyze( # noqa: PLR0913, PLR0915 ) # output the name of the saved file if saving successfully took place if saved_file_name: - output.console.print(f"\n:sparkles: Saved the file '{saved_file_name}'") + output.console.print(f":sparkles: Saved the file '{saved_file_name}'") # confirm whether or not all of the checks passed # and then display the appropriate diagnostic message all_checks_passed = all(check_status_list) if not all_checks_passed: - output.console.print("\n:sweat: At least one check did not pass.") + output.console.print(":sweat: At least one check did not pass.") sys.exit(constants.markers.Non_Zero_Exit) - output.console.print("\n:joy: All checks passed.") + output.console.print(":joy: All checks passed.") @cli.command() From 25139056677de7ab1640b917ac769ad556af1e90 Mon Sep 17 00:00:00 2001 From: Caleb Date: Mon, 23 Oct 2023 09:48:37 -0400 Subject: [PATCH 03/11] recorrected spelling --- chasten/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chasten/main.py b/chasten/main.py index a8172bf8..42282d92 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -657,7 +657,7 @@ def analyze( # noqa: PLR0913, PLR0915 # add the current source to main object that contains a list of source chasten_results_save.sources.append(current_result_source) output.console.print( - f" = Total" + f" = {len(matches_list)} total matches" ) output.console.print() # display all of the analysis results if verbose output is requested From bade673560e50171bfdbbb20a82cf07903729558 Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 25 Oct 2023 09:50:04 -0400 Subject: [PATCH 04/11] added comments to changes --- chasten/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 42282d92..6326549c 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -656,10 +656,11 @@ def analyze( # noqa: PLR0913, PLR0915 current_check_save.matches.append(current_match_for_current_check_save) # type: ignore # add the current source to main object that contains a list of source chasten_results_save.sources.append(current_result_source) - output.console.print( - f" = {len(matches_list)} total matches" - ) + # add the amount of total matches in each check to the end of each checks output + output.console.print(f" = {len(match_generator_list)} total matches") + # add constant space between check outputs and end output output.console.print() + output.console.print({chasten_results_save.sources}) # display all of the analysis results if verbose output is requested output.print_analysis_details(chasten_results_save, verbose=verbose) # save all of the results from this analysis From e7a010dafe9fca7d789612e16e926f864d97b4f2 Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 1 Nov 2023 09:50:57 -0400 Subject: [PATCH 05/11] cleaned text --- chasten/main.py | 4 +++- chasten/process.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 6326549c..71bdded9 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -660,7 +660,9 @@ def analyze( # noqa: PLR0913, PLR0915 output.console.print(f" = {len(match_generator_list)} total matches") # add constant space between check outputs and end output output.console.print() - output.console.print({chasten_results_save.sources}) + # display the final count of matches found + output.console.print([x.check.passed for x in chasten_results_save.sources]) + output.console.print() # display all of the analysis results if verbose output is requested output.print_analysis_details(chasten_results_save, verbose=verbose) # save all of the results from this analysis diff --git a/chasten/process.py b/chasten/process.py index 5670b4e1..157a7966 100644 --- a/chasten/process.py +++ b/chasten/process.py @@ -106,4 +106,4 @@ def combine_dicts(dict_list: List[Dict[Any, Any]]) -> str: # { nested JSON for file n } # ] # which is a list of valid JSON objects - return json.dumps(dict_list, indent=2) + return json.dumps(dict_list, indent=2) \ No newline at end of file From 84efdf4025a9cba043c5c6ecb1a3cc4ddb648b25 Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 1 Nov 2023 13:01:49 -0400 Subject: [PATCH 06/11] added total checks passed --- chasten/main.py | 11 +++++------ chasten/util.py | 6 ++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 71bdded9..17842016 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -657,12 +657,11 @@ def analyze( # noqa: PLR0913, PLR0915 # add the current source to main object that contains a list of source chasten_results_save.sources.append(current_result_source) # add the amount of total matches in each check to the end of each checks output - output.console.print(f" = {len(match_generator_list)} total matches") - # add constant space between check outputs and end output - output.console.print() - # display the final count of matches found - output.console.print([x.check.passed for x in chasten_results_save.sources]) - output.console.print() + output.console.print(f" = {len(match_generator_list)} total matches\n") + # calculate the final count of matches found + total_result = util.total_amount_passed(chasten_results_save) + # display checks passed, total amount of checks, and percentage of checks passed + output.console.print(f":computer: {total_result[0]} / {total_result[1]} checks passed ({total_result[2]}%)\n") # display all of the analysis results if verbose output is requested output.print_analysis_details(chasten_results_save, verbose=verbose) # save all of the results from this analysis diff --git a/chasten/util.py b/chasten/util.py index ec03cf92..f82282ac 100644 --- a/chasten/util.py +++ b/chasten/util.py @@ -54,3 +54,9 @@ def get_chasten_version() -> str: def join_and_preserve(data, start, end): """Join and preserve lines inside of a list.""" return constants.markers.Newline.join(data[start:end]) + +def total_amount_passed(analyze_result) -> tuple[int,int,int]: + """Calculate amount of checks passed in analyze""" + list_checks = [x.check.passed for x in analyze_result.sources] + count_true,count_total = list_checks.count(True),len(list_checks)/2 + return (count_true,count_total,(count_true / count_total) * 100) \ No newline at end of file From bef26fd61e4354316c81c4f7b4d09f23683f1744 Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 1 Nov 2023 14:22:25 -0400 Subject: [PATCH 07/11] added function comments --- chasten/util.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chasten/util.py b/chasten/util.py index f82282ac..e01fd3d5 100644 --- a/chasten/util.py +++ b/chasten/util.py @@ -55,8 +55,11 @@ def join_and_preserve(data, start, end): """Join and preserve lines inside of a list.""" return constants.markers.Newline.join(data[start:end]) -def total_amount_passed(analyze_result) -> tuple[int,int,int]: +def total_amount_passed(analyze_result) -> tuple[int,int,float]: """Calculate amount of checks passed in analyze""" + # iterate through check sources to find checks passed list_checks = [x.check.passed for x in analyze_result.sources] + # set variables to count true checks and total counts count_true,count_total = list_checks.count(True),len(list_checks)/2 - return (count_true,count_total,(count_true / count_total) * 100) \ No newline at end of file + # return tuple of checks passed, total checks, percentage of checks passed + return (count_true,int(count_total),(count_true / count_total) * 100) \ No newline at end of file From 1b604cf1644aeb867b74786968b8fa56cfb902bd Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 1 Nov 2023 15:13:41 -0400 Subject: [PATCH 08/11] lint --- chasten/main.py | 4 +++- chasten/process.py | 2 +- chasten/util.py | 9 +++++---- scripts/extract_coverage.py | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 17842016..96cbdad4 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -661,7 +661,9 @@ def analyze( # noqa: PLR0913, PLR0915 # calculate the final count of matches found total_result = util.total_amount_passed(chasten_results_save) # display checks passed, total amount of checks, and percentage of checks passed - output.console.print(f":computer: {total_result[0]} / {total_result[1]} checks passed ({total_result[2]}%)\n") + output.console.print( + f":computer: {total_result[0]} / {total_result[1]} checks passed ({total_result[2]}%)\n" + ) # display all of the analysis results if verbose output is requested output.print_analysis_details(chasten_results_save, verbose=verbose) # save all of the results from this analysis diff --git a/chasten/process.py b/chasten/process.py index 157a7966..5670b4e1 100644 --- a/chasten/process.py +++ b/chasten/process.py @@ -106,4 +106,4 @@ def combine_dicts(dict_list: List[Dict[Any, Any]]) -> str: # { nested JSON for file n } # ] # which is a list of valid JSON objects - return json.dumps(dict_list, indent=2) \ No newline at end of file + return json.dumps(dict_list, indent=2) diff --git a/chasten/util.py b/chasten/util.py index e01fd3d5..4d9d39d6 100644 --- a/chasten/util.py +++ b/chasten/util.py @@ -55,11 +55,12 @@ def join_and_preserve(data, start, end): """Join and preserve lines inside of a list.""" return constants.markers.Newline.join(data[start:end]) -def total_amount_passed(analyze_result) -> tuple[int,int,float]: + +def total_amount_passed(analyze_result) -> tuple[int, int, float]: """Calculate amount of checks passed in analyze""" # iterate through check sources to find checks passed list_checks = [x.check.passed for x in analyze_result.sources] # set variables to count true checks and total counts - count_true,count_total = list_checks.count(True),len(list_checks)/2 - # return tuple of checks passed, total checks, percentage of checks passed - return (count_true,int(count_total),(count_true / count_total) * 100) \ No newline at end of file + count_true, count_total = list_checks.count(True), len(list_checks) / 2 + # return tuple of checks passed, total checks, percentage of checks passed + return (count_true, int(count_total), (count_true / count_total) * 100) diff --git a/scripts/extract_coverage.py b/scripts/extract_coverage.py index 680c65ca..53d9be36 100644 --- a/scripts/extract_coverage.py +++ b/scripts/extract_coverage.py @@ -12,5 +12,5 @@ filename = "chasten/util.py" covered_lines = set(data.lines(filename)) # type: ignore -print(f"Covered lines in {filename}:") # noqa +print(f"Covered lines in {filename}:") # noqa print(covered_lines) # noqa From 499ac4ae0d450bd05c1bac98d32fecc12ec4a8d9 Mon Sep 17 00:00:00 2001 From: Caleb Date: Fri, 3 Nov 2023 09:51:30 -0400 Subject: [PATCH 09/11] temp changes --- chasten/main.py | 1 + chasten/util.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 96cbdad4..165ac524 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -657,6 +657,7 @@ def analyze( # noqa: PLR0913, PLR0915 # add the current source to main object that contains a list of source chasten_results_save.sources.append(current_result_source) # add the amount of total matches in each check to the end of each checks output + output.console.print(len(checks_dict)) output.console.print(f" = {len(match_generator_list)} total matches\n") # calculate the final count of matches found total_result = util.total_amount_passed(chasten_results_save) diff --git a/chasten/util.py b/chasten/util.py index 4d9d39d6..d07b2c88 100644 --- a/chasten/util.py +++ b/chasten/util.py @@ -58,9 +58,13 @@ def join_and_preserve(data, start, end): def total_amount_passed(analyze_result) -> tuple[int, int, float]: """Calculate amount of checks passed in analyze""" - # iterate through check sources to find checks passed - list_checks = [x.check.passed for x in analyze_result.sources] - # set variables to count true checks and total counts - count_true, count_total = list_checks.count(True), len(list_checks) / 2 - # return tuple of checks passed, total checks, percentage of checks passed - return (count_true, int(count_total), (count_true / count_total) * 100) + try: + # iterate through check sources to find checks passed + list_checks = [x.check.passed for x in analyze_result.sources] + # set variables to count true checks and total counts + count_true, count_total = list_checks.count(True), len(list_checks) + # return tuple of checks passed, total checks, percentage of checks passed + return (count_true, int(count_total), (count_true / count_total) * 100) + # return exception for basline results when empty analyze + except ZeroDivisionError: + return (0,0,0) From f9a83fe8ab145d5872a2ad4eb29c3dc2bd515211 Mon Sep 17 00:00:00 2001 From: Caleb Date: Sun, 5 Nov 2023 11:18:28 -0500 Subject: [PATCH 10/11] change to reuse check count variables --- chasten/main.py | 3 +-- chasten/util.py | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 165ac524..89458f68 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -657,10 +657,9 @@ def analyze( # noqa: PLR0913, PLR0915 # add the current source to main object that contains a list of source chasten_results_save.sources.append(current_result_source) # add the amount of total matches in each check to the end of each checks output - output.console.print(len(checks_dict)) output.console.print(f" = {len(match_generator_list)} total matches\n") # calculate the final count of matches found - total_result = util.total_amount_passed(chasten_results_save) + total_result = util.total_amount_passed(chasten_results_save,len(check_list)) # display checks passed, total amount of checks, and percentage of checks passed output.console.print( f":computer: {total_result[0]} / {total_result[1]} checks passed ({total_result[2]}%)\n" diff --git a/chasten/util.py b/chasten/util.py index d07b2c88..f5cb26b7 100644 --- a/chasten/util.py +++ b/chasten/util.py @@ -56,15 +56,15 @@ def join_and_preserve(data, start, end): return constants.markers.Newline.join(data[start:end]) -def total_amount_passed(analyze_result) -> tuple[int, int, float]: +def total_amount_passed(analyze_result, count_total) -> tuple[int, int, float]: """Calculate amount of checks passed in analyze""" try: # iterate through check sources to find checks passed - list_checks = [x.check.passed for x in analyze_result.sources] + list_passed = [x.check.passed for x in analyze_result.sources] # set variables to count true checks and total counts - count_true, count_total = list_checks.count(True), len(list_checks) + count_true = list_passed.count(True) # return tuple of checks passed, total checks, percentage of checks passed - return (count_true, int(count_total), (count_true / count_total) * 100) - # return exception for basline results when empty analyze + return (count_true, count_total, (count_true / count_total) * 100) + # return exception when dividing by zero except ZeroDivisionError: return (0,0,0) From 763aebb935605af2adcfc9eaa0109d94cc7a2038 Mon Sep 17 00:00:00 2001 From: Caleb Date: Sun, 5 Nov 2023 11:29:53 -0500 Subject: [PATCH 11/11] lint fix --- chasten/main.py | 2 +- chasten/util.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 89458f68..5f905a37 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -659,7 +659,7 @@ def analyze( # noqa: PLR0913, PLR0915 # add the amount of total matches in each check to the end of each checks output output.console.print(f" = {len(match_generator_list)} total matches\n") # calculate the final count of matches found - total_result = util.total_amount_passed(chasten_results_save,len(check_list)) + total_result = util.total_amount_passed(chasten_results_save, len(check_list)) # display checks passed, total amount of checks, and percentage of checks passed output.console.print( f":computer: {total_result[0]} / {total_result[1]} checks passed ({total_result[2]}%)\n" diff --git a/chasten/util.py b/chasten/util.py index f5cb26b7..006a3fd0 100644 --- a/chasten/util.py +++ b/chasten/util.py @@ -67,4 +67,4 @@ def total_amount_passed(analyze_result, count_total) -> tuple[int, int, float]: return (count_true, count_total, (count_true / count_total) * 100) # return exception when dividing by zero except ZeroDivisionError: - return (0,0,0) + return (0, 0, 0.0)