From 7876df7a7a5ced8bbd2fe754763b75480867796c Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:14:36 +0000 Subject: [PATCH 001/103] conforming to pep8 standard --- bettyfixer/autoprototype.py | 149 +++++++++++++++++++++++++++--------- 1 file changed, 111 insertions(+), 38 deletions(-) diff --git a/bettyfixer/autoprototype.py b/bettyfixer/autoprototype.py index 1888417..a9a67c8 100644 --- a/bettyfixer/autoprototype.py +++ b/bettyfixer/autoprototype.py @@ -1,15 +1,22 @@ -import argparse +""" +This module contains the functions to generate a header file with +the prototypes of the functions in a directory. +""" import subprocess import os -import re -from colorama import Fore import glob +from colorama import Fore + -# betty cj def betty_check(): + """Check if betty is installed and if there are any errors in the files. + Returns: + bool: True if betty is installed and there are no errors, False otherwise. + """ try: c_files = glob.glob("*.c") - result1 = subprocess.run(["betty"] + c_files, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + result1 = subprocess.run(["betty"] + c_files, check=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) except subprocess.CalledProcessError as e: print(e) @@ -23,78 +30,144 @@ def betty_check(): return result1.returncode == 0 -## auto checks errors def print_check_betty_first(): - print(Fore.RED + "You should fix betty Errors first before copy prototype functions into The header file" + Fore.RESET) + """Prints a message to the user to fix betty errors first.""" + print( + Fore.RED + "You should fix betty Errors first before \ + copy prototype functions into The header file" + Fore.RESET + ) + + def print_header_name_missing(): + """Prints a message to the user to provide a header file name.""" print(Fore.RED + "Usage : bettyfixer -H .h" + Fore.RESET) -def print_Ctags_header_error(msg): + + +def print_ctags_header_error(msg): + """Prints a message to the user in red color.""" print(Fore.RED + msg + Fore.RESET) + def check_ctags(): + """Check if ctags is installed. + Returns: + bool: True if ctags is installed, False otherwise. + str: Error message if ctags is not installed. + """ try: - subprocess.run(['ctags', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) + subprocess.run(['ctags', '--version'], stdout=subprocess.PIPE, + stderr=subprocess.PIPE, check=True) return True, None except subprocess.CalledProcessError: msg = "ctags is not installed. Please install ctags before running this script." return False, msg + def generate_tags(directory): + """Generate tags for the files in the directory. + Args: + directory (str): Directory path. + Returns: + bool: True if ctags is generated successfully, False otherwise. + """ try: - subprocess.run(['ctags', '-R', '--c-kinds=+p', '--fields=+S', '--extra=+q', '--languages=c', f'--langmap=c:.c', directory], check=True) + subprocess.run(['ctags', '-R', '--c-kinds=+p', '--fields=+S', '--extra=+q', + '--languages=c', '--langmap=c:.c', directory], check=True) return True except subprocess.CalledProcessError as e: - print_Ctags_header_error(f"Error generating ctags: {e}") + print_ctags_header_error(f"Error generating ctags: {e}") return False -def filter_tags(directory,tags_file): - temp_tags_path = os.path.join(directory,'temp_tags') - tags_path = os.path.join(directory,tags_file) - sed_command = r"cat {0} | sed -n 's/^.*\/^\(.*\)/\1/p' | sed 's/\(.*\)\$.*/\1/' | sed 's/;$//' | uniq | sed '/int main(/d' | sed '/.*:/d' | sed 's/$/;/g' > {1}".format(tags_path, temp_tags_path) - + +def filter_tags(directory, tags_file): + """ + Filter the tags file to get only the function prototypes. + Args: + directory (str): Directory path. + tags_file (str): Tags file name. + Returns: + str: Filtered tags. + """ + temp_tags_path = os.path.join(directory, 'temp_tags') + tags_path = os.path.join(directory, tags_file) + + sed_command = r"cat {0} | sed -n 's/^.*\/^\(.*\)/\1/p' | sed 's/\(.*\)\$.*/\1/' | sed 's/;$//' | uniq | sed '/int main(/d' | sed '/.*:/d' | sed 's/$/;/g' > {1}".format( + tags_path, temp_tags_path) + # Run the sed_command using subprocess subprocess.run(sed_command, shell=True, check=True) # Check if the file exists before trying to open it if os.path.exists(temp_tags_path): - with open(temp_tags_path, 'r') as temp_tags_file: + with open(temp_tags_path, 'r', encoding='utf-8') as temp_tags_file: filtered_tags = temp_tags_file.read() return filtered_tags - else: - # Handle the case where the file doesn't exist - msg =f"Error: File {temp_tags_path} does not exist." - print_Ctags_header_error(msg) - return None + + # Handle the case where the file doesn't exist + msg = f"Error: File {temp_tags_path} does not exist." + print_ctags_header_error(msg) + return None + def create_header(header_file, filtered_tags): + """ + Create a header file with the filtered tags. + Args: + header_file (str): Header file name. + filtered_tags (str): Filtered tags. + """ header_name = header_file.split('/')[-1] - header_name =header_name.split('.') - header_name= '_'.join(header_name) - with open(header_file, 'w') as header: + header_name = header_name.split('.') + header_name = '_'.join(header_name) + with open(header_file, 'w', encoding='utf-8') as header: header.write(f'#ifndef {header_name.upper()}\n') header.write(f'#define {header_name.upper()}\n\n') header.write(filtered_tags) header.write('\n#endif\n') + + def delete_files(tags, temp_tags): + """ + Delete the tags and temp_tags files. + Args: + tags (str): Tags file name. + temp_tags (str): Temp tags file name. + """ command = "rm {0} {1}".format(tags, temp_tags) subprocess.run(command, shell=True, check=True) def check_header_file(header_file): + """ + Check if the header file is valid. + Args: + header_file (str): Header file name. + Returns: + bool: True if the header file is valid, False otherwise. + str: Error message if the header file is invalid. + """ if not header_file.endswith('.h'): - + msg = "Error: Invalid header file. It should have a '.h' extension." - return False , msg + return False, msg return True, None + + def autoproto(directory, header): - check1, msg1=check_header_file(header) - check2, msg2=check_ctags() - if (not check1): - print_Ctags_header_error(msg1) - elif (not check2): - print_Ctags_header_error(msg2) - if generate_tags(directory) != False: - filtered_tags = filter_tags(directory, 'tags') - if filtered_tags != None: - create_header(header, filtered_tags) - delete_files('tags', 'temp_tags') + """ + Generate a header file with the prototypes of the functions in the directory. + Args: + directory (str): Directory path. + header (str): Header file name. + """ + check1, msg1 = check_header_file(header) + check2, msg2 = check_ctags() + if (not check1): + print_ctags_header_error(msg1) + elif (not check2): + print_ctags_header_error(msg2) + if generate_tags(directory) is not False: + filtered_tags = filter_tags(directory, 'tags') + if filtered_tags is not None: + create_header(header, filtered_tags) + delete_files('tags', 'temp_tags') From d4e525bd1b2ca56b2d06c2811e4db89a833ae16e Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:20:10 +0000 Subject: [PATCH 002/103] conforming to pep8 and adding docstring for better readability --- bettyfixer/backup.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bettyfixer/backup.py b/bettyfixer/backup.py index 03219c7..0b2761b 100644 --- a/bettyfixer/backup.py +++ b/bettyfixer/backup.py @@ -1,15 +1,18 @@ -import shutil # Add the import statement for shutil +""" +This module provides a function to create a backup copy of a file. +""" +import shutil def create_backup(file_path): + """ + Create a backup copy of the original file. + Args: + file_path (str): The path of the file to create a backup of. + """ try: - # Create a backup copy of the original file backup_path = file_path + '.bak' shutil.copy2(file_path, backup_path) except FileNotFoundError: print(f"Error creating backup for {file_path}: File not found.") except Exception as e: print(f"Unexpected error in create_backup for {file_path}: {e}") - - - - \ No newline at end of file From 0677f69e36b50900baae6c7ba35a65beab412666 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:26:43 +0000 Subject: [PATCH 003/103] Add Betty Fixer main module docstring and pep8 standard --- bettyfixer/betty_fixer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index d8be43a..92bddc2 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -1,3 +1,4 @@ +"""Betty Fixer main module.""" import re import sys import os From 169a9243b9d585c12dacf782ed4720ddee219a6e Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:26:56 +0000 Subject: [PATCH 004/103] Refactor bettyfixer module --- bettyfixer/betty_fixer.py | 46 +++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 92bddc2..7f7c437 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -9,15 +9,18 @@ HIDDEN_FILE_NAME = ".processed_files" + def read_file(file_path): with open(file_path, 'r') as file: content = file.read() return content + def write_file(file_path, content): with open(file_path, 'w') as file: file.write(content) + def add_line_without_newline(file_path, line): # Add a line without a newline at the end of the file if not found with open(file_path, 'r') as file: @@ -27,11 +30,13 @@ def add_line_without_newline(file_path, line): if not last_line.strip() == line.strip(): with open(file_path, 'a') as file: file.write(line) - + + def remove_consecutive_blank_lines(content): # Remove multiple consecutive blank lines return re.sub('\n{3,}', '\n\n', content) + def add_parentheses_around_return(content): # Add parentheses around return values if not already present content = re.sub(r'return[ ]+([^(][^;]+);', r'return (\1);', content) @@ -46,10 +51,12 @@ def add_parentheses_around_return(content): return content + def fix_comments(content): # Remove single-line comments (//) found alone in a line or after a code line return re.sub(r'([^;])\s*//.*|^\s*//.*', r'\1', content, flags=re.MULTILINE) + def remove_trailing_whitespaces(content): # Remove trailing whitespaces at the end of lines return re.sub(r'[ \t]+$', '', content, flags=re.MULTILINE) @@ -60,6 +67,7 @@ def process_errors(file_path): errors_file_path = 'errors.txt' process_error_file(errors_file_path) + def fix_betty_warnings(content, file_path): # Run Betty and append errors to the common errors.txt file content = remove_consecutive_blank_lines(content) @@ -71,6 +79,7 @@ def fix_betty_warnings(content, file_path): # Return the file path for further processing return file_path + def remove_blank_lines_inside_comments(file_path): clean_errors_file('errors.txt') # Read the content of the file @@ -92,6 +101,8 @@ def remove_blank_lines_inside_comments(file_path): with open(file_path, 'w') as file: file.writelines(lines) return + + def fix_betty_style(file_paths): for file_path in file_paths: create_backup(file_path) @@ -110,12 +121,13 @@ def fix_betty_style(file_paths): # Extract functions with no description from 'errors.txt' errors_file_path = 'errors.txt' - functions_with_no_description = extract_functions_with_no_description(errors_file_path) + functions_with_no_description = extract_functions_with_no_description( + errors_file_path) # Iterate through each line in path_file and remove extra spaces with open(file_path, 'r') as file: lines = file.readlines() - + cleaned_lines = [remove_extra_spaces(line) for line in lines] # Write the cleaned lines back to the file @@ -138,7 +150,6 @@ def fix_betty_style(file_paths): betty_handler(errors_file_path) - def More_than_5_functions_in_the_file(errors_file_path): # Set to True initially to enter the loop errors_fixed = True @@ -176,7 +187,8 @@ def More_than_5_functions_in_the_file(errors_file_path): if counter == 6: # Create a new file with the content from the specified line to the end of the file - copy_remaining_lines(lines, block_start_line, new_file_path) + copy_remaining_lines( + lines, block_start_line, new_file_path) # Remove the content from the main file del lines[block_start_line:] # Write the modified content back to the main file @@ -185,12 +197,14 @@ def More_than_5_functions_in_the_file(errors_file_path): # Clean 'errors.txt' before extracting new errors open(errors_file_path, 'w').close() # Update Betty errors in errors.txt - exctract_errors(new_file_path, errors_file_path) + exctract_errors( + new_file_path, errors_file_path) errors_fixed = True # Set the flag if a line is fixed break line_number += 1 + def find_available_file_name(original_file_path): base_name, extension = os.path.splitext(original_file_path) counter = 1 @@ -202,11 +216,12 @@ def find_available_file_name(original_file_path): return new_file_path counter += 1 + def copy_remaining_lines(lines, start_line, new_file_path): # Create a new file with the content from the specified line to the end of the file with open(new_file_path, 'w') as new_file: new_file.write(''.join(lines[start_line:])) - + def betty_handler(errors_file_path): with open(errors_file_path, 'r') as errors_file: @@ -226,6 +241,7 @@ def betty_handler(errors_file_path): file_path = variables[0] other_handlers(file_path) + def other_handlers(file_path): errors_file_path = 'errors.txt' # Your logic code @@ -241,11 +257,13 @@ def other_handlers(file_path): # Update Betty errors in errors.txt exctract_errors(file_path, errors_file_path) + def create_tasks_directory(): # Create tasks directory if not found if not os.path.exists("tasks"): os.makedirs("tasks") + def copy_files_to_tasks(files): # Copy files to tasks directory for file_path in files: @@ -256,7 +274,8 @@ def copy_files_to_tasks(files): content = source_file.readlines() # Exclude lines starting with #include and ending with '.h"' - filtered_content = [line for line in content if not line.strip().startswith("#include") or not line.strip().endswith('.h"')] + filtered_content = [line for line in content if not line.strip( + ).startswith("#include") or not line.strip().endswith('.h"')] # Write the modified content to the destination file with open(destination_path, 'w') as destination_file: @@ -271,17 +290,20 @@ def modify_main_files(files): content = main_file.readlines() # Keep only lines with #include that end with '.h"' - include_lines = [line.strip() for line in content if line.strip().startswith("#include") and line.strip().endswith('.h"')] + include_lines = [line.strip() for line in content if line.strip( + ).startswith("#include") and line.strip().endswith('.h"')] # Write the modified content to the main file, adding an empty line at the end with open(file_path, 'w') as main_file: - main_file.write('\n'.join(include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) + main_file.write('\n'.join( + include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) def record_processed_file(filename): with open(HIDDEN_FILE_NAME, 'a') as hidden_file: hidden_file.write(filename + '\n') + def is_file_processed(filename): if not os.path.exists(HIDDEN_FILE_NAME): return False @@ -290,6 +312,7 @@ def is_file_processed(filename): processed_files = hidden_file.read().splitlines() return filename in processed_files + def main(): if is_file_processed(".processed_files"): print("The files have already been processed. Skipping.") @@ -327,5 +350,6 @@ def main(): # Delete errors.txt file os.remove('errors.txt') + if __name__ == "__main__": - main() \ No newline at end of file + main() From 663a3ac4800eaf8ac3a28e89efe3464ae82ad234 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:27:05 +0000 Subject: [PATCH 005/103] Add dependency_links.txt file --- bettyfixer.egg-info/dependency_links.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 bettyfixer.egg-info/dependency_links.txt diff --git a/bettyfixer.egg-info/dependency_links.txt b/bettyfixer.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/bettyfixer.egg-info/dependency_links.txt @@ -0,0 +1 @@ + From 0b5193f4abbf4f737df788db340375a0f1b71aa0 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:27:13 +0000 Subject: [PATCH 006/103] Add new files and modify existing files --- bettyfixer.egg-info/PKG-INFO | 75 ++ bettyfixer.egg-info/SOURCES.txt | 17 + bettyfixer.egg-info/entry_points.txt | 3 + bettyfixer.egg-info/requires.txt | 2 + bettyfixer.egg-info/top_level.txt | 1 + build/lib/bettyfixer/__init__.py | 1 + build/lib/bettyfixer/autoprototype.py | 119 +++ build/lib/bettyfixer/backup.py | 15 + build/lib/bettyfixer/betty_fixer.py | 330 ++++++++ build/lib/bettyfixer/betty_handler.py | 59 ++ build/lib/bettyfixer/errors_extractor.py | 37 + build/lib/bettyfixer/extract_line.py | 970 +++++++++++++++++++++++ dist/bettyfixer-1.4.6-py3.10.egg | Bin 0 -> 29870 bytes 13 files changed, 1629 insertions(+) create mode 100644 bettyfixer.egg-info/PKG-INFO create mode 100644 bettyfixer.egg-info/SOURCES.txt create mode 100644 bettyfixer.egg-info/entry_points.txt create mode 100644 bettyfixer.egg-info/requires.txt create mode 100644 bettyfixer.egg-info/top_level.txt create mode 100644 build/lib/bettyfixer/__init__.py create mode 100644 build/lib/bettyfixer/autoprototype.py create mode 100644 build/lib/bettyfixer/backup.py create mode 100644 build/lib/bettyfixer/betty_fixer.py create mode 100644 build/lib/bettyfixer/betty_handler.py create mode 100644 build/lib/bettyfixer/errors_extractor.py create mode 100644 build/lib/bettyfixer/extract_line.py create mode 100644 dist/bettyfixer-1.4.6-py3.10.egg diff --git a/bettyfixer.egg-info/PKG-INFO b/bettyfixer.egg-info/PKG-INFO new file mode 100644 index 0000000..d63eb91 --- /dev/null +++ b/bettyfixer.egg-info/PKG-INFO @@ -0,0 +1,75 @@ +Metadata-Version: 2.1 +Name: bettyfixer +Version: 1.4.6 +Summary: Betty Fixer is a tool designed to automatically fix coding style issues in C files based on the Betty coding style guidelines. It performs corrections to ensure that the code complies with the Betty style, making it more readable and consistent. +Home-page: https://github.com/Moealsir/betty_fixer +Author: Moealsir +Author-email: mohamedwdalsir@gmail.com +License: MIT +Description-Content-Type: text/markdown +License-File: AUTHORS +Requires-Dist: colorama +Requires-Dist: black + +# Betty Fixer + +Betty Fixer is a tool designed to automatically fix coding style issues in C files based on the Betty coding style guidelines. It performs corrections to ensure that the code complies with the Betty style, making it more readable and consistent. + +## Features + +- **Betty Style Fixes**: Automatically corrects coding style issues following the Betty style guidelines. +- **Vi Script Execution**: Runs a Vi script for each fixed file, making it convenient for developers to review and further modify the code. +- **Create header.h**: You can now create header file by specifing header file name after flag -H . + +## Prerequisites + +Before using Betty Fixer, ensure you have the following installed: + +- [Betty](https://github.com/holbertonschool/Betty) - The Betty linter for C code. +- [Vi Editor](https://www.vim.org/) - The Vi editor for script execution. +- Ctags :- + + sudo apt-get install exuberant-ctags +## Getting Started + +1. Clone the repository: + + ```bash + pip install bettyfixer + ``` + +2. Run Betty Fixer on your C files: + + ```bash + bettyfixer file1.c file2.c ... + ``` + +3. To create header file run: + + ```bash + bettyfixer -H .h ... + ``` +## Compatibility: + +The current release of `bettyfixer` is optimized for Ubuntu 20.04 LTS (Focal Fossa). We are actively working to expand compatibility to include other Ubuntu releases in future updates. Stay tuned for upcoming releases that will offer support for a broader range of Ubuntu versions. + + +## Contributing + +If you'd like to contribute to Betty Fixer, please follow these steps: + +1. Go to the [Github repository](https://github.com/Moealsir/betty_fixer) +2. Fork the repository. +3. Create a new branch for your feature or bug fix. +4. Make your changes and ensure the code style follows the project conventions. +5. Test your changes thoroughly. +6. Create a pull request with a clear description of your changes. + + + + + +### Creaters: - +[@Moealsir](https://github.com/Moealsir)
+[@Malazmuzamil98](https://github.com/malazmuzamil98)
+[@AhedEisa](https://github.com/be-great) diff --git a/bettyfixer.egg-info/SOURCES.txt b/bettyfixer.egg-info/SOURCES.txt new file mode 100644 index 0000000..7f70f85 --- /dev/null +++ b/bettyfixer.egg-info/SOURCES.txt @@ -0,0 +1,17 @@ +AUTHORS +MANIFEST.in +README.md +setup.py +bettyfixer/__init__.py +bettyfixer/autoprototype.py +bettyfixer/backup.py +bettyfixer/betty_fixer.py +bettyfixer/betty_handler.py +bettyfixer/errors_extractor.py +bettyfixer/extract_line.py +bettyfixer.egg-info/PKG-INFO +bettyfixer.egg-info/SOURCES.txt +bettyfixer.egg-info/dependency_links.txt +bettyfixer.egg-info/entry_points.txt +bettyfixer.egg-info/requires.txt +bettyfixer.egg-info/top_level.txt \ No newline at end of file diff --git a/bettyfixer.egg-info/entry_points.txt b/bettyfixer.egg-info/entry_points.txt new file mode 100644 index 0000000..f5962ae --- /dev/null +++ b/bettyfixer.egg-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +bettyfixer = bettyfixer.betty_fixer:main +show-changelog = show_changelog:main diff --git a/bettyfixer.egg-info/requires.txt b/bettyfixer.egg-info/requires.txt new file mode 100644 index 0000000..a9f6d74 --- /dev/null +++ b/bettyfixer.egg-info/requires.txt @@ -0,0 +1,2 @@ +colorama +black diff --git a/bettyfixer.egg-info/top_level.txt b/bettyfixer.egg-info/top_level.txt new file mode 100644 index 0000000..9ea24b9 --- /dev/null +++ b/bettyfixer.egg-info/top_level.txt @@ -0,0 +1 @@ +bettyfixer diff --git a/build/lib/bettyfixer/__init__.py b/build/lib/bettyfixer/__init__.py new file mode 100644 index 0000000..5ade3d7 --- /dev/null +++ b/build/lib/bettyfixer/__init__.py @@ -0,0 +1 @@ +from .betty_fixer import * \ No newline at end of file diff --git a/build/lib/bettyfixer/autoprototype.py b/build/lib/bettyfixer/autoprototype.py new file mode 100644 index 0000000..13f7690 --- /dev/null +++ b/build/lib/bettyfixer/autoprototype.py @@ -0,0 +1,119 @@ +import argparse +import subprocess +import os +import re +from colorama import Fore +import glob + +# betty cj + + +def betty_check(): + try: + c_files = glob.glob("*.c") + result1 = subprocess.run(["betty"] + c_files, check=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + except subprocess.CalledProcessError as e: + print(e) + return False + + if "ERROR:" in result1.stdout or "ERROR:" in result1.stderr: + return False + if "WARNING:" in result1.stdout or "WARNING:" in result1.stderr: + return False + + return result1.returncode == 0 + + +# auto checks errors +def print_check_betty_first(): + print(Fore.RED + "You should fix betty Errors first before copy prototype functions into The header file" + Fore.RESET) + + +def print_header_name_missing(): + print(Fore.RED + "Usage : bettyfixer -H .h" + Fore.RESET) + + +def print_ctags_header_error(msg): + print(Fore.RED + msg + Fore.RESET) + + +def check_ctags(): + try: + subprocess.run(['ctags', '--version'], stdout=subprocess.PIPE, + stderr=subprocess.PIPE, check=True) + return True, None + except subprocess.CalledProcessError: + msg = "ctags is not installed. Please install ctags before running this script." + return False, msg + + +def generate_tags(directory): + try: + subprocess.run(['ctags', '-R', '--c-kinds=+p', '--fields=+S', '--extra=+q', + '--languages=c', f'--langmap=c:.c', directory], check=True) + return True + except subprocess.CalledProcessError as e: + print_ctags_header_error(f"Error generating ctags: {e}") + return False + + +def filter_tags(directory, tags_file): + temp_tags_path = os.path.join(directory, 'temp_tags') + tags_path = os.path.join(directory, tags_file) + + sed_command = r"cat {0} | sed -n 's/^.*\/^\(.*\)/\1/p' | sed 's/\(.*\)\$.*/\1/' | sed 's/;$//' | uniq | sed '/int main(/d' | sed '/.*:/d' | sed 's/$/;/g' > {1}".format( + tags_path, temp_tags_path) + + # Run the sed_command using subprocess + subprocess.run(sed_command, shell=True, check=True) + + # Check if the file exists before trying to open it + if os.path.exists(temp_tags_path): + with open(temp_tags_path, 'r') as temp_tags_file: + filtered_tags = temp_tags_file.read() + return filtered_tags + else: + # Handle the case where the file doesn't exist + msg = f"Error: File {temp_tags_path} does not exist." + print_ctags_header_error(msg) + return None + + +def create_header(header_file, filtered_tags): + header_name = header_file.split('/')[-1] + header_name = header_name.split('.') + header_name = '_'.join(header_name) + with open(header_file, 'w') as header: + header.write(f'#ifndef {header_name.upper()}\n') + header.write(f'#define {header_name.upper()}\n\n') + header.write(filtered_tags) + header.write('\n#endif\n') + + +def delete_files(tags, temp_tags): + command = "rm {0} {1}".format(tags, temp_tags) + subprocess.run(command, shell=True, check=True) + + +def check_header_file(header_file): + if not header_file.endswith('.h'): + + msg = "Error: Invalid header file. It should have a '.h' extension." + return False, msg + return True, None + + +def autoproto(directory, header): + check1, msg1 = check_header_file(header) + check2, msg2 = check_ctags() + if (not check1): + print_ctags_header_error(msg1) + elif (not check2): + print_ctags_header_error(msg2) + if generate_tags(directory) != False: + filtered_tags = filter_tags(directory, 'tags') + if filtered_tags != None: + create_header(header, filtered_tags) + delete_files('tags', 'temp_tags') diff --git a/build/lib/bettyfixer/backup.py b/build/lib/bettyfixer/backup.py new file mode 100644 index 0000000..03219c7 --- /dev/null +++ b/build/lib/bettyfixer/backup.py @@ -0,0 +1,15 @@ +import shutil # Add the import statement for shutil + +def create_backup(file_path): + try: + # Create a backup copy of the original file + backup_path = file_path + '.bak' + shutil.copy2(file_path, backup_path) + except FileNotFoundError: + print(f"Error creating backup for {file_path}: File not found.") + except Exception as e: + print(f"Unexpected error in create_backup for {file_path}: {e}") + + + + \ No newline at end of file diff --git a/build/lib/bettyfixer/betty_fixer.py b/build/lib/bettyfixer/betty_fixer.py new file mode 100644 index 0000000..d8be43a --- /dev/null +++ b/build/lib/bettyfixer/betty_fixer.py @@ -0,0 +1,330 @@ +import re +import sys +import os +from bettyfixer.backup import * +from bettyfixer.errors_extractor import * +from bettyfixer.extract_line import * +from bettyfixer.autoprototype import * + +HIDDEN_FILE_NAME = ".processed_files" + +def read_file(file_path): + with open(file_path, 'r') as file: + content = file.read() + return content + +def write_file(file_path, content): + with open(file_path, 'w') as file: + file.write(content) + +def add_line_without_newline(file_path, line): + # Add a line without a newline at the end of the file if not found + with open(file_path, 'r') as file: + lines = file.readlines() + last_line = lines[-1] if lines else '' + + if not last_line.strip() == line.strip(): + with open(file_path, 'a') as file: + file.write(line) + +def remove_consecutive_blank_lines(content): + # Remove multiple consecutive blank lines + return re.sub('\n{3,}', '\n\n', content) + +def add_parentheses_around_return(content): + # Add parentheses around return values if not already present + content = re.sub(r'return[ ]+([^(][^;]+);', r'return (\1);', content) + + # Add parentheses around return values if no value is present and not already in parentheses + content = re.sub(r'return[ ]+([^;()]+);', r'return (\1);', content) + + # Check if space after semicolon before closing brace '}' is needed + if not re.search(r';\s*}', content): + # Add space after semicolon before closing brace '}' + content = re.sub(r';}', r';\n}', content) + + return content + +def fix_comments(content): + # Remove single-line comments (//) found alone in a line or after a code line + return re.sub(r'([^;])\s*//.*|^\s*//.*', r'\1', content, flags=re.MULTILINE) + +def remove_trailing_whitespaces(content): + # Remove trailing whitespaces at the end of lines + return re.sub(r'[ \t]+$', '', content, flags=re.MULTILINE) + + +def process_errors(file_path): + # Process the errors for the specified file + errors_file_path = 'errors.txt' + process_error_file(errors_file_path) + +def fix_betty_warnings(content, file_path): + # Run Betty and append errors to the common errors.txt file + content = remove_consecutive_blank_lines(content) + clean_errors_file('errors.txt') + + content = fix_comments(content) + content = remove_trailing_whitespaces(content) + + # Return the file path for further processing + return file_path + +def remove_blank_lines_inside_comments(file_path): + clean_errors_file('errors.txt') + # Read the content of the file + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find lines starting with '/**' (declaration beginning) + for i, line in enumerate(lines): + if line.strip().startswith('/**'): + # Find the next line starting with ' */' (declaration ending) + for j in range(i + 1, len(lines)): + if lines[j].strip().startswith('*/'): + # Remove any blank lines between declaration beginning and ending + for k in range(i + 1, j): + if lines[k].strip() == '': + del lines[k] + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + return +def fix_betty_style(file_paths): + for file_path in file_paths: + create_backup(file_path) + run_vi_script(file_path) + content = read_file(file_path) + content = fix_comments(content) + content = add_parentheses_around_return(content) + content = remove_trailing_whitespaces(content) + content = remove_consecutive_blank_lines(content) + file_path_with_errors = fix_betty_warnings(content, file_path) + write_file(file_path, content) + add_line_without_newline(file_path, '\n') + + for _ in range(2): + process_errors(file_path_with_errors) + + # Extract functions with no description from 'errors.txt' + errors_file_path = 'errors.txt' + functions_with_no_description = extract_functions_with_no_description(errors_file_path) + + # Iterate through each line in path_file and remove extra spaces + with open(file_path, 'r') as file: + lines = file.readlines() + + cleaned_lines = [remove_extra_spaces(line) for line in lines] + + # Write the cleaned lines back to the file + with open(file_path, 'w') as file: + file.writelines(cleaned_lines) + + # Generate documentation for each function with no description + for function_name in functions_with_no_description: + remove_unused_attribute(file_path, function_name) + run_vi_script(file_path) + fix_missing_blank_line_after_declarations(errors_file_path) + remove_blank_lines_inside_comments(file_path) + fix_should_be_void(errors_file_path) + More_than_5_functions_in_the_file(errors_file_path) + fix_brace_should_be_on_the_next_line(errors_file_path) + fix_brace_should_be_on_the_previous_line(errors_file_path) + content = read_file(file_path) + content = remove_trailing_whitespaces(content) + write_file(file_path, content) + betty_handler(errors_file_path) + + + +def More_than_5_functions_in_the_file(errors_file_path): + # Set to True initially to enter the loop + errors_fixed = True + + while errors_fixed: + errors_fixed = False # Reset the flag at the beginning of each iteration + + with open(errors_file_path, 'r') as errors_file: + # Read all lines at once to allow modification of the list while iterating + error_lines = errors_file.readlines() + + for error_line in error_lines: + if 'More than 5 functions in the file' in error_line: + variables = extract_and_print_variables(error_line) + if len(variables) >= 2: + file_path, _ = variables[:2] + line_number = 1 # Assuming you want to start from the first line + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the next available file name (file1.c, file2.c, etc.) + new_file_path = find_available_file_name(file_path) + + # Count the /** ... */ blocks + counter = 0 + inside_block = False + block_start_line = 0 + for idx, line in enumerate(lines): + if line.strip().startswith('/**'): + inside_block = True + block_start_line = idx + elif inside_block and line.strip().startswith('*/'): + inside_block = False + counter += 1 + + if counter == 6: + # Create a new file with the content from the specified line to the end of the file + copy_remaining_lines(lines, block_start_line, new_file_path) + # Remove the content from the main file + del lines[block_start_line:] + # Write the modified content back to the main file + with open(file_path, 'w') as main_file: + main_file.write(''.join(lines)) + # Clean 'errors.txt' before extracting new errors + open(errors_file_path, 'w').close() + # Update Betty errors in errors.txt + exctract_errors(new_file_path, errors_file_path) + errors_fixed = True # Set the flag if a line is fixed + break + + line_number += 1 + +def find_available_file_name(original_file_path): + base_name, extension = os.path.splitext(original_file_path) + counter = 1 + + while True: + # Remove :01d from the format to allow for sequential numbering without leading zeros + new_file_path = f'{base_name}{counter}{extension}' + if not os.path.exists(new_file_path): + return new_file_path + counter += 1 + +def copy_remaining_lines(lines, start_line, new_file_path): + # Create a new file with the content from the specified line to the end of the file + with open(new_file_path, 'w') as new_file: + new_file.write(''.join(lines[start_line:])) + + +def betty_handler(errors_file_path): + with open(errors_file_path, 'r') as errors_file: + # Read all lines at once to allow modification of the list while iterating + error_lines = errors_file.readlines() + + messages = ["More than 40 lines in a function", + "line over 80 characters" + ] + + for error_line in error_lines: + for message in messages: + if message in error_line: + variables = extract_and_print_variables(error_line) + if len(variables) >= 1: + # Extract the first element from the tuple + file_path = variables[0] + other_handlers(file_path) + +def other_handlers(file_path): + errors_file_path = 'errors.txt' + # Your logic code + + create_tasks_directory() + # Pass file_path as a list to copy_files_to_tasks + copy_files_to_tasks([file_path]) + modify_main_files([file_path]) + + # Clean 'errors.txt' before extracting new errors + clean_errors_file(errors_file_path) + + # Update Betty errors in errors.txt + exctract_errors(file_path, errors_file_path) + +def create_tasks_directory(): + # Create tasks directory if not found + if not os.path.exists("tasks"): + os.makedirs("tasks") + +def copy_files_to_tasks(files): + # Copy files to tasks directory + for file_path in files: + destination_path = os.path.join("tasks", os.path.basename(file_path)) + if not os.path.exists(destination_path): + # Read the content of the file + with open(file_path, 'r') as source_file: + content = source_file.readlines() + + # Exclude lines starting with #include and ending with '.h"' + filtered_content = [line for line in content if not line.strip().startswith("#include") or not line.strip().endswith('.h"')] + + # Write the modified content to the destination file + with open(destination_path, 'w') as destination_file: + destination_file.write(''.join(filtered_content)) + + +def modify_main_files(files): + # Modify main files + for file_path in files: + # Read the content of the main file + with open(file_path, 'r') as main_file: + content = main_file.readlines() + + # Keep only lines with #include that end with '.h"' + include_lines = [line.strip() for line in content if line.strip().startswith("#include") and line.strip().endswith('.h"')] + + # Write the modified content to the main file, adding an empty line at the end + with open(file_path, 'w') as main_file: + main_file.write('\n'.join(include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) + + +def record_processed_file(filename): + with open(HIDDEN_FILE_NAME, 'a') as hidden_file: + hidden_file.write(filename + '\n') + +def is_file_processed(filename): + if not os.path.exists(HIDDEN_FILE_NAME): + return False + + with open(HIDDEN_FILE_NAME, 'r') as hidden_file: + processed_files = hidden_file.read().splitlines() + return filename in processed_files + +def main(): + if is_file_processed(".processed_files"): + print("The files have already been processed. Skipping.") + sys.exit(1) + + if len(sys.argv) < 2: + print("Usage: python -m betty_fixer_package.betty_fixer file1.c file2.c ...") + sys.exit(1) + + if "-H" in sys.argv and len(sys.argv) > 2: + v = betty_check() + if (v == False): + print_check_betty_first() + else: + header = sys.argv[sys.argv.index("-H") + 1] + autoproto(".", header) + elif "-H" in sys.argv and len(sys.argv) <= 2: + print_header_name_missing() + else: + file_paths = sys.argv[1:] + + # Check if any file has been processed before + if any(is_file_processed(file) for file in file_paths): + print("One or more files have already been processed. Skipping.") + sys.exit(1) + + open('errors.txt', 'w').close() + # Fix Betty style + fix_betty_style(file_paths) + for file in file_paths: + run_vi_script(file) + # Record processed file after completion + record_processed_file(file) + + # Delete errors.txt file + os.remove('errors.txt') + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/build/lib/bettyfixer/betty_handler.py b/build/lib/bettyfixer/betty_handler.py new file mode 100644 index 0000000..7fb7854 --- /dev/null +++ b/build/lib/bettyfixer/betty_handler.py @@ -0,0 +1,59 @@ +import os +import sys + +def other_handler(file_path): + create_tasks_directory() + copy_files_to_tasks(file_path) + modify_main_files(file_path) + +def create_tasks_directory(): + # Create tasks directory if not found + if not os.path.exists("tasks"): + os.makedirs("tasks") + +def copy_files_to_tasks(files): + # Copy files to tasks directory + for file_path in files: + destination_path = os.path.join("tasks", os.path.basename(file_path)) + if not os.path.exists(destination_path): + # Read the content of the file + with open(file_path, 'r') as source_file: + content = source_file.readlines() + + # Exclude lines starting with #include and ending with '.h"' + filtered_content = [line for line in content if not line.strip().startswith("#include") or not line.strip().endswith('.h"')] + + # Write the modified content to the destination file + with open(destination_path, 'w') as destination_file: + destination_file.write(''.join(filtered_content)) + +def modify_main_files(files): + # Modify main files + for file_path in files: + # Read the content of the main file + with open(file_path, 'r') as main_file: + content = main_file.readlines() + + # Keep only lines with #include that end with '.h"' + include_lines = [line.strip() for line in content if line.strip().startswith("#include") and line.strip().endswith('.h"')] + + # Write the modified content to the main file, adding an empty line at the end + with open(file_path, 'w') as main_file: + main_file.write('\n'.join(include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) + +if __name__ == "__main__": + # Check if the correct number of arguments is provided + if len(sys.argv) < 2: + print("Usage: python betty_handler.py file1.c file2.c ...") + sys.exit(1) + + # Create tasks directory if not found + create_tasks_directory() + + # Copy files to tasks directory if not found + copy_files_to_tasks(sys.argv[1:]) + + # Modify main files + modify_main_files(sys.argv[1:]) + + print("Tasks directory and main files modified successfully.") diff --git a/build/lib/bettyfixer/errors_extractor.py b/build/lib/bettyfixer/errors_extractor.py new file mode 100644 index 0000000..8a2cfab --- /dev/null +++ b/build/lib/bettyfixer/errors_extractor.py @@ -0,0 +1,37 @@ +import subprocess +import sys + +def exctract_errors(file_path, output_file): + try: + # Run Betty on the specified file + result = subprocess.run(['betty', file_path], capture_output=True, text=True, check=True) + + # Extract the output, including errors and warnings + output = result.stdout + + # Append the output to the common errors.txt file + with open(output_file, 'a') as errors_file_path: + errors_file_path.write(output) + except subprocess.CalledProcessError as e: + # Handle the case when Betty returns a non-zero exit code + pass + # Append the error output to the common errors.txt file + with open(output_file, 'a') as errors_file_path: + errors_file_path.write(e.stdout) + errors_file_path.write(e.stderr) + +if __name__ == "__main__": + # Check if at least one file path is provided as a command-line argument + if len(sys.argv) < 2: + print("Usage: python error_extractor.py ...") + sys.exit(1) + + # Specify the common errors.txt file in the current directory + errors_file_path = 'errors.txt' + + # Clear the content of the errors.txt file before appending new errors + open(errors_file_path, 'w').close() + + # Iterate over each file provided as a command-line argument + for file_path in sys.argv[1:]: + exctract_errors(file_path, errors_file_path) diff --git a/build/lib/bettyfixer/extract_line.py b/build/lib/bettyfixer/extract_line.py new file mode 100644 index 0000000..8e212e2 --- /dev/null +++ b/build/lib/bettyfixer/extract_line.py @@ -0,0 +1,970 @@ +import re +import sys +from bettyfixer.errors_extractor import exctract_errors +import os +import subprocess + +def run_vi_script(filename): + # Specify the file you want to edit + filename = os.path.abspath(filename) + # Run the vi command with gg=G using the -c option + subprocess.run(['vi', '-c', 'normal! gg=G', '-c', 'wq', filename]) + +def remove_extra_spaces(input_text): + lines = input_text.split('\n') + cleaned_lines = [] + + for line in lines: + cleaned_line = ' '.join(line.split()) + cleaned_lines.append(cleaned_line) + + cleaned_text = '\n'.join(cleaned_lines) + return cleaned_text +# Process the errors from the errors.txt file +def process_error_file(errors_file_path): + with open(errors_file_path, 'r') as errors_file: + for error_line in errors_file: + variables = extract_and_print_variables(error_line) + if variables: + file_path, line_number, error_description = variables + fix_errors_from_file(file_path, line_number, error_description) + +def extract_and_print_variables(error_line): + # Split the error line to extract variables + parts = error_line.split(":") + if len(parts) >= 3: + # Extracting file path and line number + file_path, line_number, *error_parts = parts + # Join all parts except the file path and line number to get the error description + error_description = ":".join(error_parts[1:]).strip() + + # Further processing if needed + return file_path.strip(), line_number.strip(), error_description + return None +def clean_up_line(line): + # Remove extra spaces and ensure a single space before and after each word + cleaned_line = ' '.join(part.strip() for part in line.split(' ')) + + # Add newline character if the original line had it + if line.endswith('\n'): + cleaned_line += '\n' + + return cleaned_line +def fix_errors_from_file(file_path, line_number, error_description): + # List of error messages + error_messages = [ + "space prohibited between function name and open parenthesis", + "space prohibited after that open parenthesis", + "space prohibited before that close parenthesis", + "space required before the open parenthesis", + "space prohibited before semicolon", + "should be \"foo *bar\"", + "spaces prohibited around that '", + "space prohibited after that '", + "space prohibited before that '", + "spaces preferred around that '", + "space required after that '", + "spaces required around that ", + "space required before the open brace", + "space required after that close brac", + "should be \"foo **bar\"", + "Statements should start on a tabstop", + ] + + # Check each error message + for i, message in enumerate(error_messages): + if message in error_description: + if i == 0: + fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, line_number, error_description) + elif i == 1: + fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, error_description) + elif i == 2: + fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, error_description) + elif i == 3: + fix_space_required_before_the_open_parenthesis(file_path, line_number, error_description) + elif i == 4: + fix_space_prohibited_before_semicolon(file_path, line_number, ';') + elif i == 5: + fix_should_be_foo_star_bar(file_path, line_number, error_description) + elif i == 6: + fix_spaces_prohibited_around_that(file_path, line_number, error_description) + elif i == 7: + fix_space_prohibited_after_that(file_path, line_number, error_description) + elif i == 8: + fix_space_prohibited_before_that(file_path, line_number, error_description) + elif i == 9: + fix_spaces_preferred_around_that(file_path, line_number, error_description) + elif i == 10: + fix_space_required_after_that(file_path, line_number, error_description) + elif i == 11: + fix_space_required_around_that(file_path, line_number, error_description) + elif i == 12: + fix_space_required_before_the_open_brace(file_path, line_number, error_description) + elif i == 13: + fix_space_required_after_the_close_brace(file_path, line_number, error_description) + elif i == 14: + fix_should_be_foo_star_star_bar(file_path, line_number, error_description) + elif i == 15: + run_vi_script(file_path) + +def fix_should_be_void(errors_file_path): + errors_fixed = True # Set to True initially to enter the loop + + while errors_fixed: + errors_fixed = False # Reset the flag at the beginning of each iteration + + with open(errors_file_path, 'r') as errors_file: + # Read all lines at once to allow modification of the list while iterating + error_lines = errors_file.readlines() + + for error_line in error_lines: + if 'should probably be' in error_line and '(void)' in error_line: + # Extract (file_path, line_number) from the error line + variables = extract_and_print_variables(error_line) + if len(variables) >= 2: + file_path, line_number = variables[:2] # Take the first two values + + # Fix missing blank line after declaration + if should_be_void(file_path, line_number, 'errors.txt'): + errors_fixed = True # Set the flag if a line is fixed + + +def should_be_void(file_path, line_number, errors_file_path): + # Convert line_number to integer + line_number = int(line_number) + specifier = '()' + replacement = '(void)' + + # Read the content of the file + with open(file_path, 'r') as file: + lines = file.readlines() + + # Replace '()' with '(void)' in the specified line + lines[line_number - 1] = lines[line_number - 1].replace(specifier, replacement) + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + + # Clean 'errors.txt' before extracting new errors + clean_errors_file(errors_file_path) + + # Update Betty errors in errors.txt + exctract_errors(file_path, errors_file_path) + + return True # Line is fixed, return True + + + +def clean_errors_file(errors_file_path): + errors_file_path = 'errors.txt' + + # Clear the content of the errors.txt file before appending new errors + open(errors_file_path, 'w').close() + + # Iterate over each file provided as a command-line argument + for file_path in sys.argv[1:]: + exctract_errors(file_path, errors_file_path) + +def fix_missing_blank_line_after_declarations(errors_file_path): + errors_fixed = True # Set to True initially to enter the loop + + while errors_fixed: + errors_fixed = False # Reset the flag at the beginning of each iteration + + with open(errors_file_path, 'r') as errors_file: + # Read all lines at once to allow modification of the list while iterating + error_lines = errors_file.readlines() + + for error_line in error_lines: + if 'Missing a blank line after declarations' in error_line: + # Extract (file_path, line_number) from the error line + variables = extract_and_print_variables(error_line) + if len(variables) >= 2: + file_path, line_number = variables[:2] # Take the first two values + + # Fix missing blank line after declaration + if fix_missing_blank_line_after_declaration(file_path, line_number, 'errors.txt'): + errors_fixed = True # Set the flag if a line is fixed + +def fix_missing_blank_line_after_declaration(file_path, line_number, errors_file_path): + # Convert line_number to integer + line_number = int(line_number) + + # Read the content of the file + with open(file_path, 'r') as file: + lines = file.readlines() + + line_number -= 1 + # Check if a blank line is already present + if lines[line_number].strip() == '': + return False # No fix needed, return False + + # Add a blank line after the specified line number + lines.insert(int(line_number), '\n') + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + + # Clean 'errors.txt' before extracting new errors + clean_errors_file(errors_file_path) + + return True # Line is fixed, return True + +def fix_should_be_foo_star_star_bar(file_path, line_number, error_description): #done + # Specify the specifier + specifier = '**' + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Check conditions and fix the line accordingly + if f'foo** bar' in error_description: + fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') + elif f'foo ** bar' in error_description: + fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') + elif f'foo**bar' in error_description: + fixed_line = error_line.replace(f'{specifier}', f' {specifier}') + elif f'foo* *bar' in error_description: + fixed_line = error_line.replace('* *', f' {specifier}') + else: + # If none of the conditions match, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + +def remove_unused_attribute(file_name, function_name): + try: + with open(file_name, 'r') as file: + lines = file.readlines() + + # Search for the function + pattern = r'\b' + re.escape(function_name) + r'\b[^(]*\([^)]*\)' + + function_declarations = {} # Dictionary to store function_name and its original line + + for i, line in enumerate(lines): + if re.search(pattern, line): + function_start_line = i + function_declarations[function_name] = lines[function_start_line] # Save the original line + break + else: + pass + # took a copy from the original function declaration + original_declaration = lines[function_start_line] + + # Extract and remove __attribute__((unused)) + match = re.search(r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[function_start_line]) + unused_attribute = match.group(1) if match else None + lines[function_start_line] = re.sub(r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[function_start_line]) + + # Call the existing function to generate documentation + generate_documentation(lines, function_start_line, function_name) + + # Restore __attribute__((unused)) + if unused_attribute: + lines[function_start_line] = lines[function_start_line].replace(lines[function_start_line].strip(), lines[function_start_line].strip() + ' ' + unused_attribute).strip() + + # Write back to the file + with open(file_name, 'w') as file: + file.writelines(lines) + + fix_lines_in_file(file_name, function_declarations) + except Exception as e: + print(f"Error: {e}") + +def fix_lines_in_file(file_name, function_declarations): + try: + with open(file_name, 'r') as file: + lines = file.readlines() + + # Iterate through each line in file + for i, line in enumerate(lines): + if '*/' in line and 'unused' in line: + # Check if any function_name is found in this line + for func_name, original_line in function_declarations.items(): + if func_name in line: + # Replace the line with the desired format + lines[i] = f' */\n{original_line}' + + # Check if the next line is a blank line; if so, delete it + if i + 1 < len(lines) and lines[i + 1] == '\n': + del lines[i + 1] + break + + # Write back to the file + with open(file_name, 'w') as file: + file.writelines(lines) + except Exception as e: + print(f"Error: {e}") + +def generate_documentation(lines, function_start_line, function_name): + # Extract function arguments + args_match = re.search(r'\(([^)]*)\)', lines[function_start_line]) + if args_match: + # Extract arguments from the updated text + args_text = args_match.group(1).strip() + + # Ignore if arguments are "void" + if args_text.lower() == 'void': + arguments = [] + else: + while ')' not in args_text and '\n' not in lines[function_start_line]: + # Iterate through the remaining lines until a closing parenthesis or a new line is encountered + function_start_line += 1 + args_text += lines[function_start_line].strip() + + # Continue searching for closing parenthesis in the line and take the word before it as the second argument + closing_parenthesis_pos = args_text.find(')') + if closing_parenthesis_pos != -1: + args_text = args_text[:closing_parenthesis_pos].strip() + + arguments = args_text.split(',') + arguments = [arg.strip().split(' ')[-1].lstrip('*') if '*' in arg else arg.strip().split(' ')[-1] for arg in arguments if arg.strip()] + + # Create documentation + documentation = [] + documentation.append('/**') + documentation.append(f' * {function_name} - a Function that ...') + if arguments: + for arg in arguments: + # Correctly identify the second argument as the word before the last closing parenthesis + if arg == arguments[-1]: + documentation.append(f' * @{arg}: Description of {arg}.') + else: + documentation.append(f' * @{arg}: Description of {arg}.') + documentation.append(' * Return: Description of the return value.') + documentation.append(' */\n') # Add a new line after closing '/' + + # Insert documentation into the file + lines.insert(function_start_line, '\n'.join(documentation)) + +def extract_functions_with_no_description(file_path): + functions = [] + file_path = 'errors.txt' + with open(file_path, 'r') as errors_file: + for line in errors_file: + # Check if the error description contains 'no description found for function' + if 'no description found for function' in line: + # Split the line by spaces and get the word after 'no description found for function' + words = line.split() + index = words.index('no') + 5 # Adjust index based on the specific position of the function name + function_name = words[index] + + # Append the function name to the list + functions.append(function_name) + + return functions +def fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, line_number, error_description): + # Extract specifier from error_description + specifier_index = error_description.find("'") + 1 + specifier = error_description[specifier_index:-1] + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Find the specifier in the line and fix it + fixed_line = error_line.replace(f' {specifier}', specifier) + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, error_description): + # Extract specifier from error_description + specifier_index = error_description.find("'") + 1 + specifier = error_description[specifier_index:-1] + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Find the specifier in the line and fix it + fixed_line = error_line.replace(f'{specifier} ', specifier) + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, error_description): + # Extract specifier from error_description + specifier_index = error_description.find("'") + 1 + specifier = error_description[specifier_index:-1] + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + error_line = clean_up_line(error_line) + # Find the specifier in the line and fix it + fixed_line = error_line.replace(f' {specifier}', specifier) + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_required_before_the_open_parenthesis(file_path, line_number, error_description): + # Extract specifier from error_description + specifier_index = error_description.find("'") + 1 + specifier = error_description[specifier_index:-1] + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + error_line = clean_up_line(error_line) + # Find the specifier in the line and fix it + fixed_line = error_line.replace(specifier, f' {specifier}') + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + +def fix_brace_should_be_on_the_next_line(errors_file_path): + errors_fixed = True # Set to True initially to enter the loop + + while errors_fixed: + errors_fixed = False # Reset the flag at the beginning of each iteration + + with open(errors_file_path, 'r') as errors_file: + # Read all lines at once to allow modification of the list while iterating + error_lines = errors_file.readlines() + + for i, error_line in enumerate(error_lines): + if 'that open brace { should be on the next line' in error_line: + # Extract (file_path, line_number) from the error line + variables = extract_and_print_variables(error_line) + if len(variables) >= 2: + file_path, line_number = variables[:2] # Take the first two values + + # Fix missing blank line after declaration + if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): + errors_fixed = True # Set the flag if a line is fixed + + # Add a message in the error line + error_lines[i] += " (brace moved to the next line)" + + elif 'following function declarations go on the next line' in error_line: + # Extract (file_path, line_number) from the error line + variables = extract_and_print_variables(error_line) + if len(variables) >= 2: + file_path, line_number = variables[:2] # Take the first two values + + # Fix missing blank line after declaration + if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): + errors_fixed = True # Set the flag if a line is fixed + + # Add a message in the error line + error_lines[i] += " (brace moved to the next line)" + + + +def fix_brace_on_the_next_line(file_path, line_number, errors_file_path): + # Convert line_number to integer + line_number = int(line_number) + + # Read the content of the file + with open(file_path, 'r') as file: + lines = file.readlines() + + # Check if the specified line is within the file's range + if 1 <= line_number <= len(lines): + # Find the brace '{' in the line + line = lines[line_number - 1] + + # Replace '{' with '\n{' to move it to the next line + lines[line_number - 1] = line.replace('{', '\n{') + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + + # Clean 'errors.txt' before extracting new errors + clean_errors_file(errors_file_path) + + return True # Line is fixed, return True + + return False + + +def brace_go_next_line(file_path, line_number, error_description): + specifier = '{' + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Check if the specifier is present in the error description + if specifier in error_description: + # Replace the specifier with a newline before the specifier + fixed_line = error_line.replace(f'{specifier}', f'\n{specifier}') + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + +def fix_brace_should_be_on_the_previous_line(errors_file_path): + errors_fixed = True # Set to True initially to enter the loop + + while errors_fixed: + errors_fixed = False # Reset the flag at the beginning of each iteration + + with open(errors_file_path, 'r') as errors_file: + # Read all lines at once to allow modification of the list while iterating + error_lines = errors_file.readlines() + + for error_line in error_lines: + if 'that open brace { should be on the previous line' in error_line: + # Extract (file_path, line_number) from the error line + variables = extract_and_print_variables(error_line) + if len(variables) >= 2: + file_path, line_number = variables[:2] # Take the first two values + + # Fix missing blank line after declaration + if fix_brace_on_the_previous_line(file_path, line_number, 'errors.txt'): + errors_fixed = True # Set the flag if a line is fixed + +def fix_brace_on_the_previous_line(file_path, line_number, errors_file_path): + # Convert line_number to integer + line_number = int(line_number) + + # Read the content of the file + with open(file_path, 'r') as file: + lines = file.readlines() + + line_number -= 1 + + # Find the position of the '{' in the previous line + brace_position = lines[line_number].rfind('{') + + if brace_position == -1: + return False # No '{' found in the previous line, no fix needed + + # Remove spaces and newline before the '{' + lines[line_number] = lines[line_number][:brace_position].rstrip() + '{' + lines[line_number][brace_position + 1:] + + # Delete the previous '\n' character to move the brace to the previous line + if lines[line_number - 1].endswith('\n'): + lines[line_number - 1] = lines[line_number - 1].rstrip() + ' ' if not lines[line_number - 1].endswith(' ') else lines[line_number - 1].rstrip() + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + + # Clean 'errors.txt' before extracting new errors + clean_errors_file(errors_file_path) + + return True # Line is fixed, return True + + +def fix_space_prohibited_before_semicolon(file_path, line_number, specifier): + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + + # Replace any space before the semicolon specifier + fixed_line = error_line.replace(f' {specifier}', specifier) + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_should_be_foo_star_bar(file_path, line_number, error_description): #done + # Specify the specifier + specifier = '*' + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Check conditions and fix the line accordingly + if f'foo** bar' in error_description: + fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') + elif f'foo* bar' in error_description: + fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') + elif f'foo * bar' in error_description: + fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') + elif f'foo*bar' in error_description: + fixed_line = error_line.replace(f'{specifier}', f' {specifier}') + else: + # If none of the conditions match, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_spaces_prohibited_around_that(file_path, line_number, error_description): + # Find the specifier between two single quotes in the error_description + specifier_start = error_description.find("'") + 1 + specifier_end = error_description.rfind("'") + + if specifier_start < 0 or specifier_end < 0: + # Unable to find valid specifier, return without making changes + return + + specifier = error_description[specifier_start:specifier_end] + + # Extract context from the end of error_description (ctx:context) between : and ) + context_start = error_description.rfind(':') + 1 + context_end = error_description.rfind(')') + + if context_start < 0 or context_end < 0: + # Unable to find valid context, return without making changes + return + + context = error_description[context_start:context_end].strip() + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Check if the provided line number is within the valid range + if not (1 <= int(line_number) <= len(lines)): + # Invalid line number, return without making changes + return + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Fix line according to the context conditions + if context == 'WxW': + fixed_line = error_line.replace(f' {specifier} ', f'{specifier}') + elif context == 'WxV': + fixed_line = error_line.replace(f' {specifier}', f'{specifier}') + elif context == 'VxW': + fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') + else: + # If the context doesn't match known conditions, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + +def fix_space_prohibited_after_that(file_path, line_number, error_description): #done + # Find the specifier between two single quotes in the error_description + specifier_start = error_description.find("'") + 1 + specifier_end = error_description.rfind("'") + + if specifier_start < 0 or specifier_end < 0: + # Unable to find valid specifier, return without making changes + return + + specifier = error_description[specifier_start:specifier_end] + + # Extract context from the end of error_description (ctx:context) between : and ) + context_start = error_description.rfind(':') + 1 + context_end = error_description.rfind(')') + + if context_start < 0 or context_end < 0: + # Unable to find valid context, return without making changes + return + + context = error_description[context_start:context_end].strip() + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Fix line according to the context conditions + if context == 'WxW': + fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') + elif context == 'ExW': + fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') + else: + # If the context doesn't match known conditions, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_prohibited_before_that(file_path, line_number, error_description): + # Find the specifier between two single quotes in the error_description + specifier_start = error_description.find("'") + 1 + specifier_end = error_description.rfind("'") + + if specifier_start < 0 or specifier_end < 0: + # Unable to find valid specifier, return without making changes + return + + specifier = error_description[specifier_start:specifier_end] + + # Extract context from the end of error_description (ctx:context) between : and ) + context_start = error_description.rfind(':') + 1 + context_end = error_description.rfind(')') + + if context_start < 0 or context_end < 0: + # Unable to find valid context, return without making changes + return + + context = error_description[context_start:context_end].strip() + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Fix line according to the context conditions + if context == 'WxV' or context == 'WxO' or context == 'WxE' or context == 'WxW': + fixed_line = error_line.replace(f' {specifier}', f'{specifier}') + else: + # If the context doesn't match known conditions, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_spaces_preferred_around_that(file_path, line_number, error_description): #done + # Find the specifier between two single quotes in the error_description + specifier_start = error_description.find("'") + 1 + specifier_end = error_description.rfind("'") + + if specifier_start < 0 or specifier_end < 0: + # Unable to find valid specifier, return without making changes + return + + specifier = error_description[specifier_start:specifier_end] + + # Extract context from the end of error_description (ctx:context) between : and ) + context_start = error_description.rfind(':') + 1 + context_end = error_description.rfind(')') + + if context_start < 0 or context_end < 0: + # Unable to find valid context, return without making changes + return + + context = error_description[context_start:context_end].strip() + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Check if the line already satisfies the condition + if f' {specifier} ' in error_line: + # If the required space is already present, skip the fix + return + + # Fix line according to the context conditions + if context == 'VxV': + fixed_line = error_line.replace(f'{specifier}', f' {specifier} ') + elif context == 'WxV': + fixed_line = error_line.replace(f' {specifier}', f' {specifier} ') + elif context == 'VxW': + fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') + else: + # If the context doesn't match known conditions, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_required_around_that(file_path, line_number, error_description): #done + # Find the specifier between two single quotes in the error_description + specifier_start = error_description.find("'") + 1 + specifier_end = error_description.rfind("'") + + if specifier_start < 0 or specifier_end < 0: + # Unable to find valid specifier, return without making changes + return + + specifier = error_description[specifier_start:specifier_end] + + # Extract context from the end of error_description (ctx:context) between : and ) + context_start = error_description.rfind(':') + 1 + context_end = error_description.rfind(')') + + if context_start < 0 or context_end < 0: + # Unable to find valid context, return without making changes + return + + context = error_description[context_start:context_end].strip() + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Check if the line already satisfies the condition + if f' {specifier} ' in error_line: + # If the required space is already present, skip the fix + return + + # Fix line according to the context conditions + if context == 'VxV': + fixed_line = error_line.replace(f'{specifier}', f' {specifier} ') + elif context == 'WxV': + fixed_line = error_line.replace(f' {specifier}', f' {specifier} ') + elif context == 'VxW': + fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') + else: + # If the context doesn't match known conditions, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_required_after_that(file_path, line_number, error_description): + # Find the specifier between two single quotes in the error_description + specifier_start = error_description.find("'") + 1 + specifier_end = error_description.rfind("'") + + if specifier_start < 0 or specifier_end < 0: + # Unable to find valid specifier, return without making changes + return + + specifier = error_description[specifier_start:specifier_end] + + # Extract context from the end of error_description (ctx:context) between : and ) + context_start = error_description.rfind(':') + 1 + context_end = error_description.rfind(')') + + if context_start < 0 or context_end < 0: + # Unable to find valid context, return without making changes + return + + context = error_description[context_start:context_end].strip() + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + + # Fix line according to the context conditions + if context == 'WxV' or context == 'VxV': + fixed_line = error_line.replace(f'{specifier}', f'{specifier} ') + else: + # If the context doesn't match known conditions, return without making changes + return + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_required_before_the_open_brace(file_path, line_number, error_description): + # Extract specifier from error_description + specifier_index = error_description.find("'") + 1 + specifier = error_description[specifier_index:-1] + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + error_line = clean_up_line(error_line) + # Find the specifier in the line and fix it + fixed_line = error_line.replace(specifier, f' {specifier}') + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) +def fix_space_required_after_the_close_brace(file_path, line_number, error_description): + # Extract specifier from error_description + specifier_index = error_description.find("'") + 1 + specifier = error_description[specifier_index:-1] + + # Read the file content + with open(file_path, 'r') as file: + lines = file.readlines() + + # Find the line with the error + error_line = lines[int(line_number) - 1] + error_line = clean_up_line(error_line) + # Find the specifier in the line and fix it + fixed_line = error_line.replace(specifier, f'{specifier} ') + + # Replace the line in the file + lines[int(line_number) - 1] = fixed_line + + # Write the modified content back to the file + with open(file_path, 'w') as file: + file.writelines(lines) + + +# Example usage +if __name__ == "__main__": +# Assuming you have an errors.txt file with test data + errors_file_path = 'errors.txt' + process_error_file(errors_file_path) + \ No newline at end of file diff --git a/dist/bettyfixer-1.4.6-py3.10.egg b/dist/bettyfixer-1.4.6-py3.10.egg new file mode 100644 index 0000000000000000000000000000000000000000..61c6814b613bf1838888a1b14a3233da7394b998 GIT binary patch literal 29870 zcmaI7bC74vvM$`1#CG6>JwYr=4^fvWNotfQ+9F?SAC?OEH1 zi8Uip()NTm+r#S#*>c?5!qj6wDGMnd6UVom^ZW2ZQ+xk4kEY`Yc{yHDu)4k>k$(5I zn&u{WP4l`M;d@prvYM7d^qkTUnaDpo8~B8aY|OeX8`sdi`iYUhwf<|OsXG1s5?!)7 z1)JDg)gHGKmONJdM@_1c4%qb5;yD9!kU6l)Jj3x2xl^YmLGq)YrXuHj!w`futOI6y z<6E9R+GI^YaTE=rQiWxYvE!JD6bv9J#9b(pEo*d_On{KpoH@|&nZp!_GkMu4pGwZ? zSzs|Mu!@JjwISpP2R!Gy$sB-`{UGxqUe(6h&)7Hd)UCndCHIr%0obTwwu$PRrx|!M z3fmQ%_Z!e{Ad9_tV$SQ*X>OiEKJSQ))TY4}(t-F$vQr|>W*h#Vs01*|H85+`c+cxt zTJvb|BVdj)o%gjyqthIh2(2LpF?#j&L|tXvOt{^>zQ+CYeqnxLat%jr?f63jM5yo0 zA-~Ax(p#xeFG;%3zapLl5{#QE-%JIR+3~vgSskiAbD)XULx0N94yTlT7W}NUlY3)~ z?CVywS46iROpKZEMJZ>H^|_R{BxY^c)eguTJc6v#0@3&Nj9qro?9PpHD@~T!B=C!o zW_n?N?=E`uio#|kE&xHrLu4(eCY^hd-i}H%N|Q!0!u`S4IH!4AzOnw?@QoFRZ;(K zGTnwihsgn44Dd)$fw`K$D5Q{lDl0S*YcftCo-!1#pkq|A{L)~00eD6Qkqr9#&YIv4 zlA{$7T?@kt^?Qs5gSJ!2fFXg@7qw&mQ;D$12(3TLlAaE+SuXV)G4fW@8}Qn2p5vh6 z@FW$y@Zi(?=?3sQgPV&mxMa)$6DfdSs`Y{zZ(!$4hsw z(@X_+T2eq=f-!!XB8~4A;w{ZjF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sP-v@|o-Cl!UyMO!!CH(Tf z_#>Hrdx5+ry!OfXP5AQ5I_gitA44hsOysrR>~BojFAc#^zk|3c|K}io7Ue$z0DnEJ{&I%H1X%xi KM{WJr-Twhu;?i~i literal 0 HcmV?d00001 From 4aa325a69b78229c016ac170ce9346a9a19e4c98 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:14:38 +0000 Subject: [PATCH 007/103] ***Add validation for user input*** ***Refactor code for better readability*** ***Update error handling in API calls*** --- bettyfixer/betty_fixer.py | 174 +++++++++++++++++++++++++++++++++----- 1 file changed, 151 insertions(+), 23 deletions(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 7f7c437..b161d25 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -11,33 +11,66 @@ def read_file(file_path): - with open(file_path, 'r') as file: + """ + Read the content of the specified file. + Args: + file_path (str): The path of the file to read. + Returns: + str: The content of the file. + """ + with open(file_path, 'r', encoding='utf-8') as file: content = file.read() return content def write_file(file_path, content): - with open(file_path, 'w') as file: + """ + Write the specified content to the specified file. + Args: + file_path (str): The path of the file to write to. + content (str): The content to write to the file. + """ + with open(file_path, 'w', encoding='utf-8') as file: file.write(content) def add_line_without_newline(file_path, line): + """ + Add a line without a newline at the end of the file if not found. + Args: + file_path (str): The path of the file to add the line to. + line (str): The line to add to the file. + """ # Add a line without a newline at the end of the file if not found - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() last_line = lines[-1] if lines else '' if not last_line.strip() == line.strip(): - with open(file_path, 'a') as file: + with open(file_path, 'a', encoding='utf-8') as file: file.write(line) def remove_consecutive_blank_lines(content): + """ + Remove multiple consecutive blank lines from the specified content. + Args: + content (str): The content to remove multiple consecutive blank lines from. + Returns: + str: The content with multiple consecutive blank lines removed. + """ # Remove multiple consecutive blank lines return re.sub('\n{3,}', '\n\n', content) def add_parentheses_around_return(content): + """ + Add parentheses around return values if not already present. + Args: + content (str): The content to add parentheses around return values to. + Returns: + str: The content with parentheses around return values added. + """ # Add parentheses around return values if not already present content = re.sub(r'return[ ]+([^(][^;]+);', r'return (\1);', content) @@ -53,22 +86,49 @@ def add_parentheses_around_return(content): def fix_comments(content): + """ + Fix comments in the specified content. + Args: + content (str): The content to fix comments in. + Returns: + str: The content with comments fixed. + """ # Remove single-line comments (//) found alone in a line or after a code line return re.sub(r'([^;])\s*//.*|^\s*//.*', r'\1', content, flags=re.MULTILINE) def remove_trailing_whitespaces(content): + """ + Remove trailing whitespaces at the end of lines in the specified content. + Args: + content (str): The content to remove trailing whitespaces from. + Returns: + str: The content with trailing whitespaces removed. + """ # Remove trailing whitespaces at the end of lines return re.sub(r'[ \t]+$', '', content, flags=re.MULTILINE) def process_errors(file_path): + """ + Process the errors for the specified file. + Args: + file_path (str): The path of the file to process the errors for. + """ # Process the errors for the specified file errors_file_path = 'errors.txt' process_error_file(errors_file_path) def fix_betty_warnings(content, file_path): + """ + Fix Betty warnings in the specified content. + Args: + content (str): The content to fix Betty warnings in. + file_path (str): The path of the file to fix Betty warnings in. + Returns: + str: The file path for further processing. + """ # Run Betty and append errors to the common errors.txt file content = remove_consecutive_blank_lines(content) clean_errors_file('errors.txt') @@ -81,9 +141,14 @@ def fix_betty_warnings(content, file_path): def remove_blank_lines_inside_comments(file_path): + """ + Remove blank lines inside comments in the specified file. + Args: + file_path (str): The path of the file to remove blank lines inside comments from. + """ clean_errors_file('errors.txt') # Read the content of the file - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find lines starting with '/**' (declaration beginning) @@ -98,12 +163,17 @@ def remove_blank_lines_inside_comments(file_path): del lines[k] # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) return def fix_betty_style(file_paths): + """ + Fix Betty style for the specified file paths. + Args: + file_paths (list): The list of file paths to fix Betty style for. + """ for file_path in file_paths: create_backup(file_path) run_vi_script(file_path) @@ -125,13 +195,13 @@ def fix_betty_style(file_paths): errors_file_path) # Iterate through each line in path_file and remove extra spaces - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() cleaned_lines = [remove_extra_spaces(line) for line in lines] # Write the cleaned lines back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(cleaned_lines) # Generate documentation for each function with no description @@ -151,13 +221,18 @@ def fix_betty_style(file_paths): def More_than_5_functions_in_the_file(errors_file_path): + """ + Fix the error 'More than 5 functions in the file' in the specified file. + Args: + errors_file_path (str): The path of the errors file to fix the error in. + """ # Set to True initially to enter the loop errors_fixed = True while errors_fixed: errors_fixed = False # Reset the flag at the beginning of each iteration - with open(errors_file_path, 'r') as errors_file: + with open(errors_file_path, 'r', encoding='utf-8') as errors_file: # Read all lines at once to allow modification of the list while iterating error_lines = errors_file.readlines() @@ -167,7 +242,7 @@ def More_than_5_functions_in_the_file(errors_file_path): if len(variables) >= 2: file_path, _ = variables[:2] line_number = 1 # Assuming you want to start from the first line - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the next available file name (file1.c, file2.c, etc.) @@ -192,10 +267,11 @@ def More_than_5_functions_in_the_file(errors_file_path): # Remove the content from the main file del lines[block_start_line:] # Write the modified content back to the main file - with open(file_path, 'w') as main_file: + with open(file_path, 'w', encoding='utf-8') as main_file: main_file.write(''.join(lines)) # Clean 'errors.txt' before extracting new errors - open(errors_file_path, 'w').close() + open(errors_file_path, 'w', + encoding='utf-8').close() # Update Betty errors in errors.txt exctract_errors( new_file_path, errors_file_path) @@ -206,6 +282,13 @@ def More_than_5_functions_in_the_file(errors_file_path): def find_available_file_name(original_file_path): + """ + Find the next available file name based on the specified file path. + Args: + original_file_path (str): The path of the original file to find the next available file name for. + Returns: + str: The next available file name based on the original file path. + """ base_name, extension = os.path.splitext(original_file_path) counter = 1 @@ -218,13 +301,25 @@ def find_available_file_name(original_file_path): def copy_remaining_lines(lines, start_line, new_file_path): + """ + Copy the remaining lines from the specified start line to the new file. + Args: + lines (list): The list of lines to copy from. + start_line (int): The line number to start copying from. + new_file_path (str): The path of the new file to copy the lines to. + """ # Create a new file with the content from the specified line to the end of the file - with open(new_file_path, 'w') as new_file: + with open(new_file_path, 'w', encoding='utf-8') as new_file: new_file.write(''.join(lines[start_line:])) def betty_handler(errors_file_path): - with open(errors_file_path, 'r') as errors_file: + """ + Handle Betty errors in the specified file. + Args: + errors_file_path (str): The path of the errors file to handle Betty errors in. + """ + with open(errors_file_path, 'r', encoding='utf-8') as errors_file: # Read all lines at once to allow modification of the list while iterating error_lines = errors_file.readlines() @@ -243,6 +338,11 @@ def betty_handler(errors_file_path): def other_handlers(file_path): + """ + Handle other errors in the specified file. + Args: + file_path (str): The path of the file to handle other errors in. + """ errors_file_path = 'errors.txt' # Your logic code @@ -259,18 +359,26 @@ def other_handlers(file_path): def create_tasks_directory(): + """ + Create the tasks directory if not found. + """ # Create tasks directory if not found if not os.path.exists("tasks"): os.makedirs("tasks") def copy_files_to_tasks(files): + """ + Copy the specified files to the tasks directory. + Args: + files (list): The list of files to copy to the tasks directory. + """ # Copy files to tasks directory for file_path in files: destination_path = os.path.join("tasks", os.path.basename(file_path)) if not os.path.exists(destination_path): # Read the content of the file - with open(file_path, 'r') as source_file: + with open(file_path, 'r', encoding='utf-8') as source_file: content = source_file.readlines() # Exclude lines starting with #include and ending with '.h"' @@ -278,15 +386,20 @@ def copy_files_to_tasks(files): ).startswith("#include") or not line.strip().endswith('.h"')] # Write the modified content to the destination file - with open(destination_path, 'w') as destination_file: + with open(destination_path, 'w', encoding='utf-8') as destination_file: destination_file.write(''.join(filtered_content)) def modify_main_files(files): + """ + Modify the main files to include the specified files. + Args: + files (list): The list of files to include in the main files. + """ # Modify main files for file_path in files: # Read the content of the main file - with open(file_path, 'r') as main_file: + with open(file_path, 'r', encoding='utf-8') as main_file: content = main_file.readlines() # Keep only lines with #include that end with '.h"' @@ -294,26 +407,41 @@ def modify_main_files(files): ).startswith("#include") and line.strip().endswith('.h"')] # Write the modified content to the main file, adding an empty line at the end - with open(file_path, 'w') as main_file: + with open(file_path, 'w', encoding='utf-8') as main_file: main_file.write('\n'.join( include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) def record_processed_file(filename): - with open(HIDDEN_FILE_NAME, 'a') as hidden_file: + """ + Record the specified file as processed. + Args: + filename (str): The name of the file to record as processed. + """ + with open(HIDDEN_FILE_NAME, 'a', encoding='utf-8') as hidden_file: hidden_file.write(filename + '\n') def is_file_processed(filename): + """ + Check if the specified file has been processed before. + Args: + filename (str): The name of the file to check if processed. + Returns: + bool: True if the file has been processed before, False otherwise. + """ if not os.path.exists(HIDDEN_FILE_NAME): return False - with open(HIDDEN_FILE_NAME, 'r') as hidden_file: + with open(HIDDEN_FILE_NAME, 'r', encoding='utf-8') as hidden_file: processed_files = hidden_file.read().splitlines() return filename in processed_files def main(): + """ + Main function for the Betty Fixer module. + """ if is_file_processed(".processed_files"): print("The files have already been processed. Skipping.") sys.exit(1) @@ -323,8 +451,8 @@ def main(): sys.exit(1) if "-H" in sys.argv and len(sys.argv) > 2: - v = betty_check() - if (v == False): + + if not betty_check(): print_check_betty_first() else: header = sys.argv[sys.argv.index("-H") + 1] @@ -339,7 +467,7 @@ def main(): print("One or more files have already been processed. Skipping.") sys.exit(1) - open('errors.txt', 'w').close() + open('errors.txt', 'w', encoding='utf-8').close() # Fix Betty style fix_betty_style(file_paths) for file in file_paths: From 7e7007e83456483bf3997cfa87e0c49f9816ce94 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:50:26 +0000 Subject: [PATCH 008/103] Add functions for handling Betty style tasks --- bettyfixer/betty_handler.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/bettyfixer/betty_handler.py b/bettyfixer/betty_handler.py index 7fb7854..7c17868 100644 --- a/bettyfixer/betty_handler.py +++ b/bettyfixer/betty_handler.py @@ -1,44 +1,68 @@ +""" +This module contains functions for handling Betty style tasks. + +The module can be run as a script, taking a list of file paths as command-line arguments. +When run as a script, it creates a tasks directory if one doesn't exist, +copies the specified files to the tasks directory, and modifies the main files. +""" import os import sys def other_handler(file_path): + """ + This function creates a tasks directory if one doesn't exist, + copies the specified files to the tasks directory, and modifies the main files. + """ create_tasks_directory() copy_files_to_tasks(file_path) modify_main_files(file_path) def create_tasks_directory(): + """ + Create a tasks directory if one doesn't exist. + """ # Create tasks directory if not found if not os.path.exists("tasks"): os.makedirs("tasks") def copy_files_to_tasks(files): - # Copy files to tasks directory + """ + Copy the specified files to the tasks directory. + Args: + files (list): A list of file paths to copy to the tasks directory. + """ for file_path in files: destination_path = os.path.join("tasks", os.path.basename(file_path)) if not os.path.exists(destination_path): # Read the content of the file - with open(file_path, 'r') as source_file: + with open(file_path, 'r', encoding='utf-8') as source_file: content = source_file.readlines() # Exclude lines starting with #include and ending with '.h"' filtered_content = [line for line in content if not line.strip().startswith("#include") or not line.strip().endswith('.h"')] # Write the modified content to the destination file - with open(destination_path, 'w') as destination_file: + with open(destination_path, 'w', encoding='utf-8') as destination_file: destination_file.write(''.join(filtered_content)) def modify_main_files(files): + """ + Modify the main files to include the tasks. + Args: + files (list): A list of file paths to modify. + + """ # Modify main files for file_path in files: # Read the content of the main file - with open(file_path, 'r') as main_file: + with open(file_path, 'r', encoding='utf-8') as main_file: content = main_file.readlines() # Keep only lines with #include that end with '.h"' include_lines = [line.strip() for line in content if line.strip().startswith("#include") and line.strip().endswith('.h"')] # Write the modified content to the main file, adding an empty line at the end - with open(file_path, 'w') as main_file: + with open(file_path, 'w', encoding='utf-8') as main_file: main_file.write('\n'.join(include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) if __name__ == "__main__": From 47a0737810d428f52c43c2f9cbed72d95d1e4b71 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:53:30 +0000 Subject: [PATCH 009/103] Add error extraction functionality to BettyFixer*** --- bettyfixer/errors_extractor.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bettyfixer/errors_extractor.py b/bettyfixer/errors_extractor.py index 8a2cfab..4e0c189 100644 --- a/bettyfixer/errors_extractor.py +++ b/bettyfixer/errors_extractor.py @@ -1,7 +1,16 @@ +""" +Error Extractor module to extract errors from files using Betty style checker. +""" import subprocess import sys def exctract_errors(file_path, output_file): + """ + Extract errors from a file using Betty style checker and append them to common errors.txt file. + Args: + file_path (str): The path of the file to extract errors from. + output_file (str): The path of the common errors.txt file to append the errors to. + """ try: # Run Betty on the specified file result = subprocess.run(['betty', file_path], capture_output=True, text=True, check=True) @@ -10,13 +19,13 @@ def exctract_errors(file_path, output_file): output = result.stdout # Append the output to the common errors.txt file - with open(output_file, 'a') as errors_file_path: + with open(output_file, 'a', encoding='utf-8') as errors_file_path: errors_file_path.write(output) except subprocess.CalledProcessError as e: # Handle the case when Betty returns a non-zero exit code pass # Append the error output to the common errors.txt file - with open(output_file, 'a') as errors_file_path: + with open(output_file, 'a', encoding='utf-8') as errors_file_path: errors_file_path.write(e.stdout) errors_file_path.write(e.stderr) @@ -30,7 +39,7 @@ def exctract_errors(file_path, output_file): errors_file_path = 'errors.txt' # Clear the content of the errors.txt file before appending new errors - open(errors_file_path, 'w').close() + open(errors_file_path, 'w', encoding='utf-8').close() # Iterate over each file provided as a command-line argument for file_path in sys.argv[1:]: From a6470a41cf79a59bbccac3d2e9af05616d4dd46a Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:21:13 +0000 Subject: [PATCH 010/103] Fix docstring --- bettyfixer/extract_line.py | 528 +++++++++++++++++++++++++++++-------- 1 file changed, 423 insertions(+), 105 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 8e212e2..4e57981 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -1,16 +1,38 @@ +""" +Extracts errors from the errors.txt file and fixes them in the specified file +""" import re import sys -from bettyfixer.errors_extractor import exctract_errors import os import subprocess +from bettyfixer.errors_extractor import exctract_errors + def run_vi_script(filename): + """ + Run the vi command with gg=G using the -c option. + Args: + filename (str): The path of the file to edit. + """ # Specify the file you want to edit filename = os.path.abspath(filename) # Run the vi command with gg=G using the -c option - subprocess.run(['vi', '-c', 'normal! gg=G', '-c', 'wq', filename]) + try: + # if it fails, check=True raise an exception + subprocess.run(['vi', '-c', 'normal! gg=G', + '-c', 'wq', filename], check=True) + except subprocess.CalledProcessError as e: + print(f"Error running vi: {e}") + def remove_extra_spaces(input_text): + """ + Remove extra spaces from the input text. + Args: + input_text (str): The input text to remove extra spaces from. + Returns: + str: The input text with extra spaces removed. + """ lines = input_text.split('\n') cleaned_lines = [] @@ -20,16 +42,31 @@ def remove_extra_spaces(input_text): cleaned_text = '\n'.join(cleaned_lines) return cleaned_text -# Process the errors from the errors.txt file + + def process_error_file(errors_file_path): - with open(errors_file_path, 'r') as errors_file: + """ + Process the errors from the errors.txt file. + Args: + errors_file_path (str): The path of the errors.txt file. + """ + with open(errors_file_path, 'r', encoding='utf-8') as errors_file: for error_line in errors_file: variables = extract_and_print_variables(error_line) if variables: file_path, line_number, error_description = variables fix_errors_from_file(file_path, line_number, error_description) - + + def extract_and_print_variables(error_line): + """ + Extract and print variables from the error line. + Args: + error_line (str): The error line to extract variables from. + Returns: + tuple: A tuple containing the file path, line number, and error description. + """ + # Split the error line to extract variables parts = error_line.split(":") if len(parts) >= 3: @@ -41,7 +78,16 @@ def extract_and_print_variables(error_line): # Further processing if needed return file_path.strip(), line_number.strip(), error_description return None + + def clean_up_line(line): + """ + Remove extra spaces and ensure a single space before and after each word. + Args: + line (str): The line to clean up. + Returns: + str: The cleaned up line. + """ # Remove extra spaces and ensure a single space before and after each word cleaned_line = ' '.join(part.strip() for part in line.split(' ')) @@ -50,7 +96,16 @@ def clean_up_line(line): cleaned_line += '\n' return cleaned_line + + def fix_errors_from_file(file_path, line_number, error_description): + """ + Fix errors in the specified file. + Args: + file_path (str): The path of the file to fix errors in. + line_number (str): The line number of the error. + error_description (str): The description of the error. + """ # List of error messages error_messages = [ "space prohibited between function name and open parenthesis", @@ -75,45 +130,66 @@ def fix_errors_from_file(file_path, line_number, error_description): for i, message in enumerate(error_messages): if message in error_description: if i == 0: - fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, line_number, error_description) + fix_space_prohibited_between_function_name_and_open_parenthesis( + file_path, line_number, error_description) elif i == 1: - fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, error_description) + fix_space_prohibited_after_that_open_parenthesis( + file_path, line_number, error_description) elif i == 2: - fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, error_description) + fix_space_prohibited_before_that_close_parenthesis( + file_path, line_number, error_description) elif i == 3: - fix_space_required_before_the_open_parenthesis(file_path, line_number, error_description) + fix_space_required_before_the_open_parenthesis( + file_path, line_number, error_description) elif i == 4: - fix_space_prohibited_before_semicolon(file_path, line_number, ';') + fix_space_prohibited_before_semicolon( + file_path, line_number, ';') elif i == 5: - fix_should_be_foo_star_bar(file_path, line_number, error_description) + fix_should_be_foo_star_bar( + file_path, line_number, error_description) elif i == 6: - fix_spaces_prohibited_around_that(file_path, line_number, error_description) + fix_spaces_prohibited_around_that( + file_path, line_number, error_description) elif i == 7: - fix_space_prohibited_after_that(file_path, line_number, error_description) + fix_space_prohibited_after_that( + file_path, line_number, error_description) elif i == 8: - fix_space_prohibited_before_that(file_path, line_number, error_description) + fix_space_prohibited_before_that( + file_path, line_number, error_description) elif i == 9: - fix_spaces_preferred_around_that(file_path, line_number, error_description) + fix_spaces_preferred_around_that( + file_path, line_number, error_description) elif i == 10: - fix_space_required_after_that(file_path, line_number, error_description) + fix_space_required_after_that( + file_path, line_number, error_description) elif i == 11: - fix_space_required_around_that(file_path, line_number, error_description) + fix_space_required_around_that( + file_path, line_number, error_description) elif i == 12: - fix_space_required_before_the_open_brace(file_path, line_number, error_description) + fix_space_required_before_the_open_brace( + file_path, line_number, error_description) elif i == 13: - fix_space_required_after_the_close_brace(file_path, line_number, error_description) + fix_space_required_after_the_close_brace( + file_path, line_number, error_description) elif i == 14: - fix_should_be_foo_star_star_bar(file_path, line_number, error_description) + fix_should_be_foo_star_star_bar( + file_path, line_number, error_description) elif i == 15: run_vi_script(file_path) + def fix_should_be_void(errors_file_path): + """ + Fix errors in the specified file. + Args: + errors_file_path (str): The path of the file to fix errors in. + """ errors_fixed = True # Set to True initially to enter the loop while errors_fixed: errors_fixed = False # Reset the flag at the beginning of each iteration - with open(errors_file_path, 'r') as errors_file: + with open(errors_file_path, 'r', encoding='utf-8') as errors_file: # Read all lines at once to allow modification of the list while iterating error_lines = errors_file.readlines() @@ -122,7 +198,8 @@ def fix_should_be_void(errors_file_path): # Extract (file_path, line_number) from the error line variables = extract_and_print_variables(error_line) if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values + # Take the first two values + file_path, line_number = variables[:2] # Fix missing blank line after declaration if should_be_void(file_path, line_number, 'errors.txt'): @@ -130,22 +207,32 @@ def fix_should_be_void(errors_file_path): def should_be_void(file_path, line_number, errors_file_path): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + errors_file_path (str): The path of the errors.txt file. + Returns: + bool: True if the line is fixed, False otherwise. + """ # Convert line_number to integer line_number = int(line_number) specifier = '()' replacement = '(void)' # Read the content of the file - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Replace '()' with '(void)' in the specified line - lines[line_number - 1] = lines[line_number - 1].replace(specifier, replacement) + lines[line_number - 1] = lines[line_number - + 1].replace(specifier, replacement) # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) - + # Clean 'errors.txt' before extracting new errors clean_errors_file(errors_file_path) @@ -155,24 +242,34 @@ def should_be_void(file_path, line_number, errors_file_path): return True # Line is fixed, return True - def clean_errors_file(errors_file_path): + """ + Clean the errors.txt file by removing its content. + Args: + errors_file_path (str): The path of the errors.txt file to clean. + """ errors_file_path = 'errors.txt' # Clear the content of the errors.txt file before appending new errors - open(errors_file_path, 'w').close() + open(errors_file_path, 'w', encoding='utf-8').close() # Iterate over each file provided as a command-line argument for file_path in sys.argv[1:]: exctract_errors(file_path, errors_file_path) + def fix_missing_blank_line_after_declarations(errors_file_path): + """ + Fix errors in the specified file. + Args: + errors_file_path (str): The path of the file to fix errors in. + """ errors_fixed = True # Set to True initially to enter the loop while errors_fixed: errors_fixed = False # Reset the flag at the beginning of each iteration - with open(errors_file_path, 'r') as errors_file: + with open(errors_file_path, 'r', encoding='utf-8') as errors_file: # Read all lines at once to allow modification of the list while iterating error_lines = errors_file.readlines() @@ -181,18 +278,29 @@ def fix_missing_blank_line_after_declarations(errors_file_path): # Extract (file_path, line_number) from the error line variables = extract_and_print_variables(error_line) if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values + # Take the first two values + file_path, line_number = variables[:2] # Fix missing blank line after declaration if fix_missing_blank_line_after_declaration(file_path, line_number, 'errors.txt'): errors_fixed = True # Set the flag if a line is fixed + def fix_missing_blank_line_after_declaration(file_path, line_number, errors_file_path): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + errors_file_path (str): The path of the errors.txt file. + Returns: + bool: True if the line is fixed, False otherwise. + """ # Convert line_number to integer line_number = int(line_number) # Read the content of the file - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() line_number -= 1 @@ -204,20 +312,28 @@ def fix_missing_blank_line_after_declaration(file_path, line_number, errors_file lines.insert(int(line_number), '\n') # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) - + # Clean 'errors.txt' before extracting new errors clean_errors_file(errors_file_path) return True # Line is fixed, return True -def fix_should_be_foo_star_star_bar(file_path, line_number, error_description): #done + +def fix_should_be_foo_star_star_bar(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Specify the specifier specifier = '**' # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -240,12 +356,19 @@ def fix_should_be_foo_star_star_bar(file_path, line_number, error_description): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) + def remove_unused_attribute(file_name, function_name): + """ + Remove __attribute__((unused)) from the specified function in the file. + Args: + file_name (str): The path of the file to remove __attribute__((unused)) from. + function_name (str): The name of the function to remove __attribute__((unused)) from. + """ try: - with open(file_name, 'r') as file: + with open(file_name, 'r', encoding='utf-8') as file: lines = file.readlines() # Search for the function @@ -256,36 +379,48 @@ def remove_unused_attribute(file_name, function_name): for i, line in enumerate(lines): if re.search(pattern, line): function_start_line = i - function_declarations[function_name] = lines[function_start_line] # Save the original line + # Save the original line + function_declarations[function_name] = lines[function_start_line] break else: - pass + pass # took a copy from the original function declaration original_declaration = lines[function_start_line] # Extract and remove __attribute__((unused)) - match = re.search(r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[function_start_line]) + match = re.search( + r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[function_start_line]) unused_attribute = match.group(1) if match else None - lines[function_start_line] = re.sub(r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[function_start_line]) + lines[function_start_line] = re.sub( + r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[function_start_line]) # Call the existing function to generate documentation generate_documentation(lines, function_start_line, function_name) # Restore __attribute__((unused)) if unused_attribute: - lines[function_start_line] = lines[function_start_line].replace(lines[function_start_line].strip(), lines[function_start_line].strip() + ' ' + unused_attribute).strip() + lines[function_start_line] = lines[function_start_line].replace(lines[function_start_line].strip( + ), lines[function_start_line].strip() + ' ' + unused_attribute).strip() # Write back to the file - with open(file_name, 'w') as file: + with open(file_name, 'w', encoding='utf-8') as file: file.writelines(lines) fix_lines_in_file(file_name, function_declarations) except Exception as e: print(f"Error: {e}") + def fix_lines_in_file(file_name, function_declarations): + """ + Fix the lines in the file. + Args: + file_name (str): The path of the file to fix the lines in. + function_declarations (dict): A dictionary containing + the function_name and its original line. + """ try: - with open(file_name, 'r') as file: + with open(file_name, 'r', encoding='utf-8') as file: lines = file.readlines() # Iterate through each line in file @@ -296,19 +431,27 @@ def fix_lines_in_file(file_name, function_declarations): if func_name in line: # Replace the line with the desired format lines[i] = f' */\n{original_line}' - + # Check if the next line is a blank line; if so, delete it if i + 1 < len(lines) and lines[i + 1] == '\n': del lines[i + 1] break # Write back to the file - with open(file_name, 'w') as file: + with open(file_name, 'w', encoding='utf-8') as file: file.writelines(lines) except Exception as e: print(f"Error: {e}") - + + def generate_documentation(lines, function_start_line, function_name): + """ + Generate documentation for the specified function in the file. + Args: + lines (list): A list of lines in the file. + function_start_line (int): The line number where the function starts. + function_name (str): The name of the function to generate documentation for. + """ # Extract function arguments args_match = re.search(r'\(([^)]*)\)', lines[function_start_line]) if args_match: @@ -320,7 +463,7 @@ def generate_documentation(lines, function_start_line, function_name): arguments = [] else: while ')' not in args_text and '\n' not in lines[function_start_line]: - # Iterate through the remaining lines until a closing parenthesis or a new line is encountered + # Iterate through the remaining lines until a closing parenthesis or a new line is encountered function_start_line += 1 args_text += lines[function_start_line].strip() @@ -330,7 +473,8 @@ def generate_documentation(lines, function_start_line, function_name): args_text = args_text[:closing_parenthesis_pos].strip() arguments = args_text.split(',') - arguments = [arg.strip().split(' ')[-1].lstrip('*') if '*' in arg else arg.strip().split(' ')[-1] for arg in arguments if arg.strip()] + arguments = [arg.strip().split(' ')[-1].lstrip('*') if '*' in arg else arg.strip( + ).split(' ')[-1] for arg in arguments if arg.strip()] # Create documentation documentation = [] @@ -349,23 +493,41 @@ def generate_documentation(lines, function_start_line, function_name): # Insert documentation into the file lines.insert(function_start_line, '\n'.join(documentation)) + def extract_functions_with_no_description(file_path): + """ + Extract functions with no description from the specified file. + Args: + file_path (str): The path of the file to extract functions from. + Returns: + list: A list of functions with no description. + """ functions = [] file_path = 'errors.txt' - with open(file_path, 'r') as errors_file: + with open(file_path, 'r', encoding='utf-8') as errors_file: for line in errors_file: # Check if the error description contains 'no description found for function' if 'no description found for function' in line: # Split the line by spaces and get the word after 'no description found for function' words = line.split() - index = words.index('no') + 5 # Adjust index based on the specific position of the function name + # Adjust index based on the specific position of the function name + index = words.index('no') + 5 function_name = words[index] # Append the function name to the list functions.append(function_name) return functions + + def fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Extract specifier from error_description specifier_index = error_description.find("'") + 1 specifier = error_description[specifier_index:-1] @@ -379,20 +541,30 @@ def fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, l # Find the specifier in the line and fix it fixed_line = error_line.replace(f' {specifier}', specifier) - + # Replace the line in the file lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file with open(file_path, 'w') as file: - file.writelines(lines) + file.writelines(lines) + + def fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, error_description): - # Extract specifier from error_description + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + + """ + # Extract specifier from error_description specifier_index = error_description.find("'") + 1 specifier = error_description[specifier_index:-1] # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -405,15 +577,24 @@ def fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, err lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) + + def fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Extract specifier from error_description specifier_index = error_description.find("'") + 1 specifier = error_description[specifier_index:-1] # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -426,15 +607,24 @@ def fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, e lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) + + def fix_space_required_before_the_open_parenthesis(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Extract specifier from error_description specifier_index = error_description.find("'") + 1 specifier = error_description[specifier_index:-1] # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -447,16 +637,22 @@ def fix_space_required_before_the_open_parenthesis(file_path, line_number, error lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) - + + def fix_brace_should_be_on_the_next_line(errors_file_path): + """ + Fix errors in the specified file. + Args: + errors_file_path (str): The path of the file to fix errors in. + """ errors_fixed = True # Set to True initially to enter the loop while errors_fixed: errors_fixed = False # Reset the flag at the beginning of each iteration - with open(errors_file_path, 'r') as errors_file: + with open(errors_file_path, 'r', encoding='utf-8') as errors_file: # Read all lines at once to allow modification of the list while iterating error_lines = errors_file.readlines() @@ -465,7 +661,8 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): # Extract (file_path, line_number) from the error line variables = extract_and_print_variables(error_line) if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values + # Take the first two values + file_path, line_number = variables[:2] # Fix missing blank line after declaration if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): @@ -478,7 +675,8 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): # Extract (file_path, line_number) from the error line variables = extract_and_print_variables(error_line) if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values + # Take the first two values + file_path, line_number = variables[:2] # Fix missing blank line after declaration if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): @@ -488,25 +686,33 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): error_lines[i] += " (brace moved to the next line)" - def fix_brace_on_the_next_line(file_path, line_number, errors_file_path): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + errors_file_path (str): The path of the errors.txt file. + Returns: + bool: True if the line is fixed, False otherwise. + """ # Convert line_number to integer line_number = int(line_number) # Read the content of the file - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Check if the specified line is within the file's range if 1 <= line_number <= len(lines): # Find the brace '{' in the line line = lines[line_number - 1] - + # Replace '{' with '\n{' to move it to the next line lines[line_number - 1] = line.replace('{', '\n{') - + # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) # Clean 'errors.txt' before extracting new errors @@ -514,14 +720,22 @@ def fix_brace_on_the_next_line(file_path, line_number, errors_file_path): return True # Line is fixed, return True - return False + return False + - def brace_go_next_line(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + + """ specifier = '{' # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -536,16 +750,22 @@ def brace_go_next_line(file_path, line_number, error_description): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) + def fix_brace_should_be_on_the_previous_line(errors_file_path): + """ + Fix errors in the specified file. + Args: + errors_file_path (str): The path of the file to fix errors in. + """ errors_fixed = True # Set to True initially to enter the loop while errors_fixed: errors_fixed = False # Reset the flag at the beginning of each iteration - with open(errors_file_path, 'r') as errors_file: + with open(errors_file_path, 'r', encoding='utf-8') as errors_file: # Read all lines at once to allow modification of the list while iterating error_lines = errors_file.readlines() @@ -554,20 +774,31 @@ def fix_brace_should_be_on_the_previous_line(errors_file_path): # Extract (file_path, line_number) from the error line variables = extract_and_print_variables(error_line) if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values + # Take the first two values + file_path, line_number = variables[:2] # Fix missing blank line after declaration if fix_brace_on_the_previous_line(file_path, line_number, 'errors.txt'): errors_fixed = True # Set the flag if a line is fixed + def fix_brace_on_the_previous_line(file_path, line_number, errors_file_path): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + errors_file_path (str): The path of the errors.txt file. + Returns: + bool: True if the line is fixed, False otherwise. + """ # Convert line_number to integer line_number = int(line_number) # Read the content of the file - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() - + line_number -= 1 # Find the position of the '{' in the previous line @@ -577,16 +808,18 @@ def fix_brace_on_the_previous_line(file_path, line_number, errors_file_path): return False # No '{' found in the previous line, no fix needed # Remove spaces and newline before the '{' - lines[line_number] = lines[line_number][:brace_position].rstrip() + '{' + lines[line_number][brace_position + 1:] + lines[line_number] = lines[line_number][:brace_position].rstrip( + ) + '{' + lines[line_number][brace_position + 1:] # Delete the previous '\n' character to move the brace to the previous line if lines[line_number - 1].endswith('\n'): - lines[line_number - 1] = lines[line_number - 1].rstrip() + ' ' if not lines[line_number - 1].endswith(' ') else lines[line_number - 1].rstrip() + lines[line_number - 1] = lines[line_number - 1].rstrip() + ' ' if not lines[line_number - + 1].endswith(' ') else lines[line_number - 1].rstrip() # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) - + # Clean 'errors.txt' before extracting new errors clean_errors_file(errors_file_path) @@ -594,15 +827,21 @@ def fix_brace_on_the_previous_line(file_path, line_number, errors_file_path): def fix_space_prohibited_before_semicolon(file_path, line_number, specifier): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + specifier (str): The specifier to fix. + """ # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error error_line = lines[int(line_number) - 1] - # Replace any space before the semicolon specifier fixed_line = error_line.replace(f' {specifier}', specifier) @@ -610,14 +849,23 @@ def fix_space_prohibited_before_semicolon(file_path, line_number, specifier): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) -def fix_should_be_foo_star_bar(file_path, line_number, error_description): #done + + +def fix_should_be_foo_star_bar(file_path, line_number, error_description): # done + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Specify the specifier specifier = '*' # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -642,11 +890,20 @@ def fix_should_be_foo_star_bar(file_path, line_number, error_description): #done # Write the modified content back to the file with open(file_path, 'w') as file: file.writelines(lines) + + def fix_spaces_prohibited_around_that(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Find the specifier between two single quotes in the error_description specifier_start = error_description.find("'") + 1 specifier_end = error_description.rfind("'") - + if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return @@ -664,7 +921,7 @@ def fix_spaces_prohibited_around_that(file_path, line_number, error_description) context = error_description[context_start:context_end].strip() # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Check if the provided line number is within the valid range @@ -690,14 +947,22 @@ def fix_spaces_prohibited_around_that(file_path, line_number, error_description) lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) -def fix_space_prohibited_after_that(file_path, line_number, error_description): #done + +def fix_space_prohibited_after_that(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Find the specifier between two single quotes in the error_description specifier_start = error_description.find("'") + 1 specifier_end = error_description.rfind("'") - + if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return @@ -715,7 +980,7 @@ def fix_space_prohibited_after_that(file_path, line_number, error_description): context = error_description[context_start:context_end].strip() # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -734,13 +999,22 @@ def fix_space_prohibited_after_that(file_path, line_number, error_description): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) + + def fix_space_prohibited_before_that(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Find the specifier between two single quotes in the error_description specifier_start = error_description.find("'") + 1 specifier_end = error_description.rfind("'") - + if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return @@ -777,11 +1051,20 @@ def fix_space_prohibited_before_that(file_path, line_number, error_description): # Write the modified content back to the file with open(file_path, 'w') as file: file.writelines(lines) -def fix_spaces_preferred_around_that(file_path, line_number, error_description): #done + + +def fix_spaces_preferred_around_that(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Find the specifier between two single quotes in the error_description specifier_start = error_description.find("'") + 1 specifier_end = error_description.rfind("'") - + if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return @@ -804,7 +1087,7 @@ def fix_spaces_preferred_around_that(file_path, line_number, error_description): # Find the line with the error error_line = lines[int(line_number) - 1] - + # Check if the line already satisfies the condition if f' {specifier} ' in error_line: # If the required space is already present, skip the fix @@ -819,7 +1102,7 @@ def fix_spaces_preferred_around_that(file_path, line_number, error_description): fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') else: # If the context doesn't match known conditions, return without making changes - return + return # Replace the line in the file lines[int(line_number) - 1] = fixed_line @@ -827,11 +1110,20 @@ def fix_spaces_preferred_around_that(file_path, line_number, error_description): # Write the modified content back to the file with open(file_path, 'w') as file: file.writelines(lines) -def fix_space_required_around_that(file_path, line_number, error_description): #done + + +def fix_space_required_around_that(file_path, line_number, error_description): # done + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Find the specifier between two single quotes in the error_description specifier_start = error_description.find("'") + 1 specifier_end = error_description.rfind("'") - + if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return @@ -854,7 +1146,7 @@ def fix_space_required_around_that(file_path, line_number, error_description): # # Find the line with the error error_line = lines[int(line_number) - 1] - + # Check if the line already satisfies the condition if f' {specifier} ' in error_line: # If the required space is already present, skip the fix @@ -869,7 +1161,7 @@ def fix_space_required_around_that(file_path, line_number, error_description): # fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') else: # If the context doesn't match known conditions, return without making changes - return + return # Replace the line in the file lines[int(line_number) - 1] = fixed_line @@ -877,11 +1169,20 @@ def fix_space_required_around_that(file_path, line_number, error_description): # # Write the modified content back to the file with open(file_path, 'w') as file: file.writelines(lines) + + def fix_space_required_after_that(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Find the specifier between two single quotes in the error_description specifier_start = error_description.find("'") + 1 specifier_end = error_description.rfind("'") - + if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return @@ -918,7 +1219,16 @@ def fix_space_required_after_that(file_path, line_number, error_description): # Write the modified content back to the file with open(file_path, 'w') as file: file.writelines(lines) + + def fix_space_required_before_the_open_brace(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Extract specifier from error_description specifier_index = error_description.find("'") + 1 specifier = error_description[specifier_index:-1] @@ -939,7 +1249,16 @@ def fix_space_required_before_the_open_brace(file_path, line_number, error_descr # Write the modified content back to the file with open(file_path, 'w') as file: file.writelines(lines) + + def fix_space_required_after_the_close_brace(file_path, line_number, error_description): + """ + Fix the specified line in the file. + Args: + file_path (str): The path of the file to fix the specified line in. + line_number (str): The line number to fix. + error_description (str): The description of the error. + """ # Extract specifier from error_description specifier_index = error_description.find("'") + 1 specifier = error_description[specifier_index:-1] @@ -964,7 +1283,6 @@ def fix_space_required_after_the_close_brace(file_path, line_number, error_descr # Example usage if __name__ == "__main__": -# Assuming you have an errors.txt file with test data + # Assuming you have an errors.txt file with test data errors_file_path = 'errors.txt' process_error_file(errors_file_path) - \ No newline at end of file From 4e469e9b05456b3cb47b6791c24329788c80b06a Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:25:02 +0000 Subject: [PATCH 011/103] Refactor file handling functions and add comments --- bettyfixer/betty_handler.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bettyfixer/betty_handler.py b/bettyfixer/betty_handler.py index 7c17868..e493538 100644 --- a/bettyfixer/betty_handler.py +++ b/bettyfixer/betty_handler.py @@ -8,6 +8,7 @@ import os import sys + def other_handler(file_path): """ This function creates a tasks directory if one doesn't exist, @@ -17,6 +18,7 @@ def other_handler(file_path): copy_files_to_tasks(file_path) modify_main_files(file_path) + def create_tasks_directory(): """ Create a tasks directory if one doesn't exist. @@ -25,6 +27,7 @@ def create_tasks_directory(): if not os.path.exists("tasks"): os.makedirs("tasks") + def copy_files_to_tasks(files): """ Copy the specified files to the tasks directory. @@ -39,12 +42,14 @@ def copy_files_to_tasks(files): content = source_file.readlines() # Exclude lines starting with #include and ending with '.h"' - filtered_content = [line for line in content if not line.strip().startswith("#include") or not line.strip().endswith('.h"')] + filtered_content = [line for line in content if not line.strip( + ).startswith("#include") or not line.strip().endswith('.h"')] # Write the modified content to the destination file with open(destination_path, 'w', encoding='utf-8') as destination_file: destination_file.write(''.join(filtered_content)) + def modify_main_files(files): """ Modify the main files to include the tasks. @@ -59,11 +64,14 @@ def modify_main_files(files): content = main_file.readlines() # Keep only lines with #include that end with '.h"' - include_lines = [line.strip() for line in content if line.strip().startswith("#include") and line.strip().endswith('.h"')] + include_lines = [line.strip() for line in content if line.strip( + ).startswith("#include") and line.strip().endswith('.h"')] # Write the modified content to the main file, adding an empty line at the end with open(file_path, 'w', encoding='utf-8') as main_file: - main_file.write('\n'.join(include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) + main_file.write('\n'.join( + include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) + if __name__ == "__main__": # Check if the correct number of arguments is provided From 7793bdfa05f54bc13938d5c06c6617f8b1819eb5 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:27:09 +0000 Subject: [PATCH 012/103] Fix import statement in __init__.py --- bettyfixer/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bettyfixer/__init__.py b/bettyfixer/__init__.py index 5ade3d7..51c9398 100644 --- a/bettyfixer/__init__.py +++ b/bettyfixer/__init__.py @@ -1 +1,2 @@ -from .betty_fixer import * \ No newline at end of file +from .betty_fixer import * +# modify_main_files(sys.argv[1:]) From b563fe718482f4f2fa45c167934d52f9de182f57 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:27:16 +0000 Subject: [PATCH 013/103] Add blank line to backup.py --- bettyfixer/backup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bettyfixer/backup.py b/bettyfixer/backup.py index 0b2761b..76f627f 100644 --- a/bettyfixer/backup.py +++ b/bettyfixer/backup.py @@ -3,6 +3,7 @@ """ import shutil + def create_backup(file_path): """ Create a backup copy of the original file. From 4b4263a047d59b98ff5bf6201103d0683f1ec06b Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:27:23 +0000 Subject: [PATCH 014/103] Refactor errors_extractor.py for better readability and maintainability --- bettyfixer/errors_extractor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bettyfixer/errors_extractor.py b/bettyfixer/errors_extractor.py index 4e0c189..4b33e15 100644 --- a/bettyfixer/errors_extractor.py +++ b/bettyfixer/errors_extractor.py @@ -4,6 +4,7 @@ import subprocess import sys + def exctract_errors(file_path, output_file): """ Extract errors from a file using Betty style checker and append them to common errors.txt file. @@ -13,7 +14,8 @@ def exctract_errors(file_path, output_file): """ try: # Run Betty on the specified file - result = subprocess.run(['betty', file_path], capture_output=True, text=True, check=True) + result = subprocess.run(['betty', file_path], + capture_output=True, text=True, check=True) # Extract the output, including errors and warnings output = result.stdout @@ -29,6 +31,7 @@ def exctract_errors(file_path, output_file): errors_file_path.write(e.stdout) errors_file_path.write(e.stderr) + if __name__ == "__main__": # Check if at least one file path is provided as a command-line argument if len(sys.argv) < 2: From 4a58dacbbf83005251812e9804e7020337b2f34b Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:27:28 +0000 Subject: [PATCH 015/103] Fix indentation in extract_line.py --- bettyfixer/extract_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 4e57981..69a09ba 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -463,7 +463,7 @@ def generate_documentation(lines, function_start_line, function_name): arguments = [] else: while ')' not in args_text and '\n' not in lines[function_start_line]: - # Iterate through the remaining lines until a closing parenthesis or a new line is encountered + # Iterate through the remaining lines until a closing parenthesis or a new line is encountered function_start_line += 1 args_text += lines[function_start_line].strip() From 36451ab069325ee80c0d1a88b3b4344552aef54e Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:34:38 +0300 Subject: [PATCH 016/103] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2cef76e..2a26fec 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ If you'd like to contribute to Betty Fixer, please follow these steps: -### Creaters: - +### Creators: - [@Moealsir](https://github.com/Moealsir)
[@Malazmuzamil98](https://github.com/malazmuzamil98)
-[@AhedEisa](https://github.com/be-great) \ No newline at end of file +[@AhedEisa](https://github.com/be-great) From e0ee9bf3a023ee3380327a18dd2699197b1c3035 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:49:39 +0300 Subject: [PATCH 017/103] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2a26fec..6eb03f6 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,6 @@ If you'd like to contribute to Betty Fixer, please follow these steps: [@Moealsir](https://github.com/Moealsir)
[@Malazmuzamil98](https://github.com/malazmuzamil98)
[@AhedEisa](https://github.com/be-great) + +### Contributors: +[@Younis-ahmed](https://github.com/Younis-ahmed)
From ef86fc58c33ed69b74661f8dce091d4e8ce7ec65 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:55:47 +0000 Subject: [PATCH 018/103] Remove dependency_links.txt file --- bettyfixer.egg-info/dependency_links.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 bettyfixer.egg-info/dependency_links.txt diff --git a/bettyfixer.egg-info/dependency_links.txt b/bettyfixer.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/bettyfixer.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - From 303db888f4b7684450c49694ca05153fdb2afb5a Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:55:53 +0000 Subject: [PATCH 019/103] Remove bettyfixer entry points --- bettyfixer.egg-info/entry_points.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 bettyfixer.egg-info/entry_points.txt diff --git a/bettyfixer.egg-info/entry_points.txt b/bettyfixer.egg-info/entry_points.txt deleted file mode 100644 index f5962ae..0000000 --- a/bettyfixer.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -bettyfixer = bettyfixer.betty_fixer:main -show-changelog = show_changelog:main From b7b0a5841a89e23a48bc4f6eb750aea67e9611b8 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:55:58 +0000 Subject: [PATCH 020/103] Delete bettyfixer.egg-info/PKG-INFO file --- bettyfixer.egg-info/PKG-INFO | 75 ------------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 bettyfixer.egg-info/PKG-INFO diff --git a/bettyfixer.egg-info/PKG-INFO b/bettyfixer.egg-info/PKG-INFO deleted file mode 100644 index d63eb91..0000000 --- a/bettyfixer.egg-info/PKG-INFO +++ /dev/null @@ -1,75 +0,0 @@ -Metadata-Version: 2.1 -Name: bettyfixer -Version: 1.4.6 -Summary: Betty Fixer is a tool designed to automatically fix coding style issues in C files based on the Betty coding style guidelines. It performs corrections to ensure that the code complies with the Betty style, making it more readable and consistent. -Home-page: https://github.com/Moealsir/betty_fixer -Author: Moealsir -Author-email: mohamedwdalsir@gmail.com -License: MIT -Description-Content-Type: text/markdown -License-File: AUTHORS -Requires-Dist: colorama -Requires-Dist: black - -# Betty Fixer - -Betty Fixer is a tool designed to automatically fix coding style issues in C files based on the Betty coding style guidelines. It performs corrections to ensure that the code complies with the Betty style, making it more readable and consistent. - -## Features - -- **Betty Style Fixes**: Automatically corrects coding style issues following the Betty style guidelines. -- **Vi Script Execution**: Runs a Vi script for each fixed file, making it convenient for developers to review and further modify the code. -- **Create header.h**: You can now create header file by specifing header file name after flag -H . - -## Prerequisites - -Before using Betty Fixer, ensure you have the following installed: - -- [Betty](https://github.com/holbertonschool/Betty) - The Betty linter for C code. -- [Vi Editor](https://www.vim.org/) - The Vi editor for script execution. -- Ctags :- - - sudo apt-get install exuberant-ctags -## Getting Started - -1. Clone the repository: - - ```bash - pip install bettyfixer - ``` - -2. Run Betty Fixer on your C files: - - ```bash - bettyfixer file1.c file2.c ... - ``` - -3. To create header file run: - - ```bash - bettyfixer -H .h ... - ``` -## Compatibility: - -The current release of `bettyfixer` is optimized for Ubuntu 20.04 LTS (Focal Fossa). We are actively working to expand compatibility to include other Ubuntu releases in future updates. Stay tuned for upcoming releases that will offer support for a broader range of Ubuntu versions. - - -## Contributing - -If you'd like to contribute to Betty Fixer, please follow these steps: - -1. Go to the [Github repository](https://github.com/Moealsir/betty_fixer) -2. Fork the repository. -3. Create a new branch for your feature or bug fix. -4. Make your changes and ensure the code style follows the project conventions. -5. Test your changes thoroughly. -6. Create a pull request with a clear description of your changes. - - - - - -### Creaters: - -[@Moealsir](https://github.com/Moealsir)
-[@Malazmuzamil98](https://github.com/malazmuzamil98)
-[@AhedEisa](https://github.com/be-great) From d330ec617e1733df901277ccd615465cf0cad4ae Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 31 Jan 2024 13:59:44 +0000 Subject: [PATCH 021/103] Remove colorama and black from requires.txt --- bettyfixer.egg-info/requires.txt | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 bettyfixer.egg-info/requires.txt diff --git a/bettyfixer.egg-info/requires.txt b/bettyfixer.egg-info/requires.txt deleted file mode 100644 index a9f6d74..0000000 --- a/bettyfixer.egg-info/requires.txt +++ /dev/null @@ -1,2 +0,0 @@ -colorama -black From d5b882811ad30fcfbfe2a1300812d2d6b498baf1 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:01:06 +0000 Subject: [PATCH 022/103] delete unnecessary files --- bettyfixer.egg-info/SOURCES.txt | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 bettyfixer.egg-info/SOURCES.txt diff --git a/bettyfixer.egg-info/SOURCES.txt b/bettyfixer.egg-info/SOURCES.txt deleted file mode 100644 index 7f70f85..0000000 --- a/bettyfixer.egg-info/SOURCES.txt +++ /dev/null @@ -1,17 +0,0 @@ -AUTHORS -MANIFEST.in -README.md -setup.py -bettyfixer/__init__.py -bettyfixer/autoprototype.py -bettyfixer/backup.py -bettyfixer/betty_fixer.py -bettyfixer/betty_handler.py -bettyfixer/errors_extractor.py -bettyfixer/extract_line.py -bettyfixer.egg-info/PKG-INFO -bettyfixer.egg-info/SOURCES.txt -bettyfixer.egg-info/dependency_links.txt -bettyfixer.egg-info/entry_points.txt -bettyfixer.egg-info/requires.txt -bettyfixer.egg-info/top_level.txt \ No newline at end of file From eecb3c5403d21cdca012f63363257728a37cfb04 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:01:44 +0000 Subject: [PATCH 023/103] Remove bettyfixer from top_level.txt --- bettyfixer.egg-info/top_level.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 bettyfixer.egg-info/top_level.txt diff --git a/bettyfixer.egg-info/top_level.txt b/bettyfixer.egg-info/top_level.txt deleted file mode 100644 index 9ea24b9..0000000 --- a/bettyfixer.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -bettyfixer From 65b4ea11c6fd0a246da3a916dc7800568bdb4c78 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:02:50 +0000 Subject: [PATCH 024/103] delete unnecessary files --- build/lib/bettyfixer/__init__.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 build/lib/bettyfixer/__init__.py diff --git a/build/lib/bettyfixer/__init__.py b/build/lib/bettyfixer/__init__.py deleted file mode 100644 index 5ade3d7..0000000 --- a/build/lib/bettyfixer/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .betty_fixer import * \ No newline at end of file From a992d88cac2f3d87431bf8ecf6faabfbdbc229e7 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:03:01 +0000 Subject: [PATCH 025/103] delete unnecessary files --- build/lib/bettyfixer/autoprototype.py | 119 -------------------------- 1 file changed, 119 deletions(-) delete mode 100644 build/lib/bettyfixer/autoprototype.py diff --git a/build/lib/bettyfixer/autoprototype.py b/build/lib/bettyfixer/autoprototype.py deleted file mode 100644 index 13f7690..0000000 --- a/build/lib/bettyfixer/autoprototype.py +++ /dev/null @@ -1,119 +0,0 @@ -import argparse -import subprocess -import os -import re -from colorama import Fore -import glob - -# betty cj - - -def betty_check(): - try: - c_files = glob.glob("*.c") - result1 = subprocess.run(["betty"] + c_files, check=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - except subprocess.CalledProcessError as e: - print(e) - return False - - if "ERROR:" in result1.stdout or "ERROR:" in result1.stderr: - return False - if "WARNING:" in result1.stdout or "WARNING:" in result1.stderr: - return False - - return result1.returncode == 0 - - -# auto checks errors -def print_check_betty_first(): - print(Fore.RED + "You should fix betty Errors first before copy prototype functions into The header file" + Fore.RESET) - - -def print_header_name_missing(): - print(Fore.RED + "Usage : bettyfixer -H .h" + Fore.RESET) - - -def print_ctags_header_error(msg): - print(Fore.RED + msg + Fore.RESET) - - -def check_ctags(): - try: - subprocess.run(['ctags', '--version'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE, check=True) - return True, None - except subprocess.CalledProcessError: - msg = "ctags is not installed. Please install ctags before running this script." - return False, msg - - -def generate_tags(directory): - try: - subprocess.run(['ctags', '-R', '--c-kinds=+p', '--fields=+S', '--extra=+q', - '--languages=c', f'--langmap=c:.c', directory], check=True) - return True - except subprocess.CalledProcessError as e: - print_ctags_header_error(f"Error generating ctags: {e}") - return False - - -def filter_tags(directory, tags_file): - temp_tags_path = os.path.join(directory, 'temp_tags') - tags_path = os.path.join(directory, tags_file) - - sed_command = r"cat {0} | sed -n 's/^.*\/^\(.*\)/\1/p' | sed 's/\(.*\)\$.*/\1/' | sed 's/;$//' | uniq | sed '/int main(/d' | sed '/.*:/d' | sed 's/$/;/g' > {1}".format( - tags_path, temp_tags_path) - - # Run the sed_command using subprocess - subprocess.run(sed_command, shell=True, check=True) - - # Check if the file exists before trying to open it - if os.path.exists(temp_tags_path): - with open(temp_tags_path, 'r') as temp_tags_file: - filtered_tags = temp_tags_file.read() - return filtered_tags - else: - # Handle the case where the file doesn't exist - msg = f"Error: File {temp_tags_path} does not exist." - print_ctags_header_error(msg) - return None - - -def create_header(header_file, filtered_tags): - header_name = header_file.split('/')[-1] - header_name = header_name.split('.') - header_name = '_'.join(header_name) - with open(header_file, 'w') as header: - header.write(f'#ifndef {header_name.upper()}\n') - header.write(f'#define {header_name.upper()}\n\n') - header.write(filtered_tags) - header.write('\n#endif\n') - - -def delete_files(tags, temp_tags): - command = "rm {0} {1}".format(tags, temp_tags) - subprocess.run(command, shell=True, check=True) - - -def check_header_file(header_file): - if not header_file.endswith('.h'): - - msg = "Error: Invalid header file. It should have a '.h' extension." - return False, msg - return True, None - - -def autoproto(directory, header): - check1, msg1 = check_header_file(header) - check2, msg2 = check_ctags() - if (not check1): - print_ctags_header_error(msg1) - elif (not check2): - print_ctags_header_error(msg2) - if generate_tags(directory) != False: - filtered_tags = filter_tags(directory, 'tags') - if filtered_tags != None: - create_header(header, filtered_tags) - delete_files('tags', 'temp_tags') From d7624b999d00dc6f47b2eda2a8294f6fbf3cc745 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:03:06 +0000 Subject: [PATCH 026/103] delete unnecessary files --- build/lib/bettyfixer/backup.py | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 build/lib/bettyfixer/backup.py diff --git a/build/lib/bettyfixer/backup.py b/build/lib/bettyfixer/backup.py deleted file mode 100644 index 03219c7..0000000 --- a/build/lib/bettyfixer/backup.py +++ /dev/null @@ -1,15 +0,0 @@ -import shutil # Add the import statement for shutil - -def create_backup(file_path): - try: - # Create a backup copy of the original file - backup_path = file_path + '.bak' - shutil.copy2(file_path, backup_path) - except FileNotFoundError: - print(f"Error creating backup for {file_path}: File not found.") - except Exception as e: - print(f"Unexpected error in create_backup for {file_path}: {e}") - - - - \ No newline at end of file From 87ab62fe85e6f5ce66ec98dd34ca306a6c64c8e6 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:03:24 +0000 Subject: [PATCH 027/103] delete unnecessary files --- build/lib/bettyfixer/betty_fixer.py | 330 ---------------------------- 1 file changed, 330 deletions(-) delete mode 100644 build/lib/bettyfixer/betty_fixer.py diff --git a/build/lib/bettyfixer/betty_fixer.py b/build/lib/bettyfixer/betty_fixer.py deleted file mode 100644 index d8be43a..0000000 --- a/build/lib/bettyfixer/betty_fixer.py +++ /dev/null @@ -1,330 +0,0 @@ -import re -import sys -import os -from bettyfixer.backup import * -from bettyfixer.errors_extractor import * -from bettyfixer.extract_line import * -from bettyfixer.autoprototype import * - -HIDDEN_FILE_NAME = ".processed_files" - -def read_file(file_path): - with open(file_path, 'r') as file: - content = file.read() - return content - -def write_file(file_path, content): - with open(file_path, 'w') as file: - file.write(content) - -def add_line_without_newline(file_path, line): - # Add a line without a newline at the end of the file if not found - with open(file_path, 'r') as file: - lines = file.readlines() - last_line = lines[-1] if lines else '' - - if not last_line.strip() == line.strip(): - with open(file_path, 'a') as file: - file.write(line) - -def remove_consecutive_blank_lines(content): - # Remove multiple consecutive blank lines - return re.sub('\n{3,}', '\n\n', content) - -def add_parentheses_around_return(content): - # Add parentheses around return values if not already present - content = re.sub(r'return[ ]+([^(][^;]+);', r'return (\1);', content) - - # Add parentheses around return values if no value is present and not already in parentheses - content = re.sub(r'return[ ]+([^;()]+);', r'return (\1);', content) - - # Check if space after semicolon before closing brace '}' is needed - if not re.search(r';\s*}', content): - # Add space after semicolon before closing brace '}' - content = re.sub(r';}', r';\n}', content) - - return content - -def fix_comments(content): - # Remove single-line comments (//) found alone in a line or after a code line - return re.sub(r'([^;])\s*//.*|^\s*//.*', r'\1', content, flags=re.MULTILINE) - -def remove_trailing_whitespaces(content): - # Remove trailing whitespaces at the end of lines - return re.sub(r'[ \t]+$', '', content, flags=re.MULTILINE) - - -def process_errors(file_path): - # Process the errors for the specified file - errors_file_path = 'errors.txt' - process_error_file(errors_file_path) - -def fix_betty_warnings(content, file_path): - # Run Betty and append errors to the common errors.txt file - content = remove_consecutive_blank_lines(content) - clean_errors_file('errors.txt') - - content = fix_comments(content) - content = remove_trailing_whitespaces(content) - - # Return the file path for further processing - return file_path - -def remove_blank_lines_inside_comments(file_path): - clean_errors_file('errors.txt') - # Read the content of the file - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find lines starting with '/**' (declaration beginning) - for i, line in enumerate(lines): - if line.strip().startswith('/**'): - # Find the next line starting with ' */' (declaration ending) - for j in range(i + 1, len(lines)): - if lines[j].strip().startswith('*/'): - # Remove any blank lines between declaration beginning and ending - for k in range(i + 1, j): - if lines[k].strip() == '': - del lines[k] - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - return -def fix_betty_style(file_paths): - for file_path in file_paths: - create_backup(file_path) - run_vi_script(file_path) - content = read_file(file_path) - content = fix_comments(content) - content = add_parentheses_around_return(content) - content = remove_trailing_whitespaces(content) - content = remove_consecutive_blank_lines(content) - file_path_with_errors = fix_betty_warnings(content, file_path) - write_file(file_path, content) - add_line_without_newline(file_path, '\n') - - for _ in range(2): - process_errors(file_path_with_errors) - - # Extract functions with no description from 'errors.txt' - errors_file_path = 'errors.txt' - functions_with_no_description = extract_functions_with_no_description(errors_file_path) - - # Iterate through each line in path_file and remove extra spaces - with open(file_path, 'r') as file: - lines = file.readlines() - - cleaned_lines = [remove_extra_spaces(line) for line in lines] - - # Write the cleaned lines back to the file - with open(file_path, 'w') as file: - file.writelines(cleaned_lines) - - # Generate documentation for each function with no description - for function_name in functions_with_no_description: - remove_unused_attribute(file_path, function_name) - run_vi_script(file_path) - fix_missing_blank_line_after_declarations(errors_file_path) - remove_blank_lines_inside_comments(file_path) - fix_should_be_void(errors_file_path) - More_than_5_functions_in_the_file(errors_file_path) - fix_brace_should_be_on_the_next_line(errors_file_path) - fix_brace_should_be_on_the_previous_line(errors_file_path) - content = read_file(file_path) - content = remove_trailing_whitespaces(content) - write_file(file_path, content) - betty_handler(errors_file_path) - - - -def More_than_5_functions_in_the_file(errors_file_path): - # Set to True initially to enter the loop - errors_fixed = True - - while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration - - with open(errors_file_path, 'r') as errors_file: - # Read all lines at once to allow modification of the list while iterating - error_lines = errors_file.readlines() - - for error_line in error_lines: - if 'More than 5 functions in the file' in error_line: - variables = extract_and_print_variables(error_line) - if len(variables) >= 2: - file_path, _ = variables[:2] - line_number = 1 # Assuming you want to start from the first line - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the next available file name (file1.c, file2.c, etc.) - new_file_path = find_available_file_name(file_path) - - # Count the /** ... */ blocks - counter = 0 - inside_block = False - block_start_line = 0 - for idx, line in enumerate(lines): - if line.strip().startswith('/**'): - inside_block = True - block_start_line = idx - elif inside_block and line.strip().startswith('*/'): - inside_block = False - counter += 1 - - if counter == 6: - # Create a new file with the content from the specified line to the end of the file - copy_remaining_lines(lines, block_start_line, new_file_path) - # Remove the content from the main file - del lines[block_start_line:] - # Write the modified content back to the main file - with open(file_path, 'w') as main_file: - main_file.write(''.join(lines)) - # Clean 'errors.txt' before extracting new errors - open(errors_file_path, 'w').close() - # Update Betty errors in errors.txt - exctract_errors(new_file_path, errors_file_path) - errors_fixed = True # Set the flag if a line is fixed - break - - line_number += 1 - -def find_available_file_name(original_file_path): - base_name, extension = os.path.splitext(original_file_path) - counter = 1 - - while True: - # Remove :01d from the format to allow for sequential numbering without leading zeros - new_file_path = f'{base_name}{counter}{extension}' - if not os.path.exists(new_file_path): - return new_file_path - counter += 1 - -def copy_remaining_lines(lines, start_line, new_file_path): - # Create a new file with the content from the specified line to the end of the file - with open(new_file_path, 'w') as new_file: - new_file.write(''.join(lines[start_line:])) - - -def betty_handler(errors_file_path): - with open(errors_file_path, 'r') as errors_file: - # Read all lines at once to allow modification of the list while iterating - error_lines = errors_file.readlines() - - messages = ["More than 40 lines in a function", - "line over 80 characters" - ] - - for error_line in error_lines: - for message in messages: - if message in error_line: - variables = extract_and_print_variables(error_line) - if len(variables) >= 1: - # Extract the first element from the tuple - file_path = variables[0] - other_handlers(file_path) - -def other_handlers(file_path): - errors_file_path = 'errors.txt' - # Your logic code - - create_tasks_directory() - # Pass file_path as a list to copy_files_to_tasks - copy_files_to_tasks([file_path]) - modify_main_files([file_path]) - - # Clean 'errors.txt' before extracting new errors - clean_errors_file(errors_file_path) - - # Update Betty errors in errors.txt - exctract_errors(file_path, errors_file_path) - -def create_tasks_directory(): - # Create tasks directory if not found - if not os.path.exists("tasks"): - os.makedirs("tasks") - -def copy_files_to_tasks(files): - # Copy files to tasks directory - for file_path in files: - destination_path = os.path.join("tasks", os.path.basename(file_path)) - if not os.path.exists(destination_path): - # Read the content of the file - with open(file_path, 'r') as source_file: - content = source_file.readlines() - - # Exclude lines starting with #include and ending with '.h"' - filtered_content = [line for line in content if not line.strip().startswith("#include") or not line.strip().endswith('.h"')] - - # Write the modified content to the destination file - with open(destination_path, 'w') as destination_file: - destination_file.write(''.join(filtered_content)) - - -def modify_main_files(files): - # Modify main files - for file_path in files: - # Read the content of the main file - with open(file_path, 'r') as main_file: - content = main_file.readlines() - - # Keep only lines with #include that end with '.h"' - include_lines = [line.strip() for line in content if line.strip().startswith("#include") and line.strip().endswith('.h"')] - - # Write the modified content to the main file, adding an empty line at the end - with open(file_path, 'w') as main_file: - main_file.write('\n'.join(include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) - - -def record_processed_file(filename): - with open(HIDDEN_FILE_NAME, 'a') as hidden_file: - hidden_file.write(filename + '\n') - -def is_file_processed(filename): - if not os.path.exists(HIDDEN_FILE_NAME): - return False - - with open(HIDDEN_FILE_NAME, 'r') as hidden_file: - processed_files = hidden_file.read().splitlines() - return filename in processed_files - -def main(): - if is_file_processed(".processed_files"): - print("The files have already been processed. Skipping.") - sys.exit(1) - - if len(sys.argv) < 2: - print("Usage: python -m betty_fixer_package.betty_fixer file1.c file2.c ...") - sys.exit(1) - - if "-H" in sys.argv and len(sys.argv) > 2: - v = betty_check() - if (v == False): - print_check_betty_first() - else: - header = sys.argv[sys.argv.index("-H") + 1] - autoproto(".", header) - elif "-H" in sys.argv and len(sys.argv) <= 2: - print_header_name_missing() - else: - file_paths = sys.argv[1:] - - # Check if any file has been processed before - if any(is_file_processed(file) for file in file_paths): - print("One or more files have already been processed. Skipping.") - sys.exit(1) - - open('errors.txt', 'w').close() - # Fix Betty style - fix_betty_style(file_paths) - for file in file_paths: - run_vi_script(file) - # Record processed file after completion - record_processed_file(file) - - # Delete errors.txt file - os.remove('errors.txt') - -if __name__ == "__main__": - main() \ No newline at end of file From 89a59d64a8173fc90324c3abe8bb3113fdd8bae5 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:03:30 +0000 Subject: [PATCH 028/103] delete unnecessary files --- build/lib/bettyfixer/betty_handler.py | 59 --------------------------- 1 file changed, 59 deletions(-) delete mode 100644 build/lib/bettyfixer/betty_handler.py diff --git a/build/lib/bettyfixer/betty_handler.py b/build/lib/bettyfixer/betty_handler.py deleted file mode 100644 index 7fb7854..0000000 --- a/build/lib/bettyfixer/betty_handler.py +++ /dev/null @@ -1,59 +0,0 @@ -import os -import sys - -def other_handler(file_path): - create_tasks_directory() - copy_files_to_tasks(file_path) - modify_main_files(file_path) - -def create_tasks_directory(): - # Create tasks directory if not found - if not os.path.exists("tasks"): - os.makedirs("tasks") - -def copy_files_to_tasks(files): - # Copy files to tasks directory - for file_path in files: - destination_path = os.path.join("tasks", os.path.basename(file_path)) - if not os.path.exists(destination_path): - # Read the content of the file - with open(file_path, 'r') as source_file: - content = source_file.readlines() - - # Exclude lines starting with #include and ending with '.h"' - filtered_content = [line for line in content if not line.strip().startswith("#include") or not line.strip().endswith('.h"')] - - # Write the modified content to the destination file - with open(destination_path, 'w') as destination_file: - destination_file.write(''.join(filtered_content)) - -def modify_main_files(files): - # Modify main files - for file_path in files: - # Read the content of the main file - with open(file_path, 'r') as main_file: - content = main_file.readlines() - - # Keep only lines with #include that end with '.h"' - include_lines = [line.strip() for line in content if line.strip().startswith("#include") and line.strip().endswith('.h"')] - - # Write the modified content to the main file, adding an empty line at the end - with open(file_path, 'w') as main_file: - main_file.write('\n'.join(include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) - -if __name__ == "__main__": - # Check if the correct number of arguments is provided - if len(sys.argv) < 2: - print("Usage: python betty_handler.py file1.c file2.c ...") - sys.exit(1) - - # Create tasks directory if not found - create_tasks_directory() - - # Copy files to tasks directory if not found - copy_files_to_tasks(sys.argv[1:]) - - # Modify main files - modify_main_files(sys.argv[1:]) - - print("Tasks directory and main files modified successfully.") From 71b91ec7f01acfd61ad12cf286f40469b7aa726c Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:03:34 +0000 Subject: [PATCH 029/103] delete unnecessary files --- build/lib/bettyfixer/errors_extractor.py | 37 ------------------------ 1 file changed, 37 deletions(-) delete mode 100644 build/lib/bettyfixer/errors_extractor.py diff --git a/build/lib/bettyfixer/errors_extractor.py b/build/lib/bettyfixer/errors_extractor.py deleted file mode 100644 index 8a2cfab..0000000 --- a/build/lib/bettyfixer/errors_extractor.py +++ /dev/null @@ -1,37 +0,0 @@ -import subprocess -import sys - -def exctract_errors(file_path, output_file): - try: - # Run Betty on the specified file - result = subprocess.run(['betty', file_path], capture_output=True, text=True, check=True) - - # Extract the output, including errors and warnings - output = result.stdout - - # Append the output to the common errors.txt file - with open(output_file, 'a') as errors_file_path: - errors_file_path.write(output) - except subprocess.CalledProcessError as e: - # Handle the case when Betty returns a non-zero exit code - pass - # Append the error output to the common errors.txt file - with open(output_file, 'a') as errors_file_path: - errors_file_path.write(e.stdout) - errors_file_path.write(e.stderr) - -if __name__ == "__main__": - # Check if at least one file path is provided as a command-line argument - if len(sys.argv) < 2: - print("Usage: python error_extractor.py ...") - sys.exit(1) - - # Specify the common errors.txt file in the current directory - errors_file_path = 'errors.txt' - - # Clear the content of the errors.txt file before appending new errors - open(errors_file_path, 'w').close() - - # Iterate over each file provided as a command-line argument - for file_path in sys.argv[1:]: - exctract_errors(file_path, errors_file_path) From 93cef65ab8cf93be01c8d371ab6174a5d1e2eaf2 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:03:42 +0000 Subject: [PATCH 030/103] delete unnecessary files --- build/lib/bettyfixer/extract_line.py | 970 --------------------------- 1 file changed, 970 deletions(-) delete mode 100644 build/lib/bettyfixer/extract_line.py diff --git a/build/lib/bettyfixer/extract_line.py b/build/lib/bettyfixer/extract_line.py deleted file mode 100644 index 8e212e2..0000000 --- a/build/lib/bettyfixer/extract_line.py +++ /dev/null @@ -1,970 +0,0 @@ -import re -import sys -from bettyfixer.errors_extractor import exctract_errors -import os -import subprocess - -def run_vi_script(filename): - # Specify the file you want to edit - filename = os.path.abspath(filename) - # Run the vi command with gg=G using the -c option - subprocess.run(['vi', '-c', 'normal! gg=G', '-c', 'wq', filename]) - -def remove_extra_spaces(input_text): - lines = input_text.split('\n') - cleaned_lines = [] - - for line in lines: - cleaned_line = ' '.join(line.split()) - cleaned_lines.append(cleaned_line) - - cleaned_text = '\n'.join(cleaned_lines) - return cleaned_text -# Process the errors from the errors.txt file -def process_error_file(errors_file_path): - with open(errors_file_path, 'r') as errors_file: - for error_line in errors_file: - variables = extract_and_print_variables(error_line) - if variables: - file_path, line_number, error_description = variables - fix_errors_from_file(file_path, line_number, error_description) - -def extract_and_print_variables(error_line): - # Split the error line to extract variables - parts = error_line.split(":") - if len(parts) >= 3: - # Extracting file path and line number - file_path, line_number, *error_parts = parts - # Join all parts except the file path and line number to get the error description - error_description = ":".join(error_parts[1:]).strip() - - # Further processing if needed - return file_path.strip(), line_number.strip(), error_description - return None -def clean_up_line(line): - # Remove extra spaces and ensure a single space before and after each word - cleaned_line = ' '.join(part.strip() for part in line.split(' ')) - - # Add newline character if the original line had it - if line.endswith('\n'): - cleaned_line += '\n' - - return cleaned_line -def fix_errors_from_file(file_path, line_number, error_description): - # List of error messages - error_messages = [ - "space prohibited between function name and open parenthesis", - "space prohibited after that open parenthesis", - "space prohibited before that close parenthesis", - "space required before the open parenthesis", - "space prohibited before semicolon", - "should be \"foo *bar\"", - "spaces prohibited around that '", - "space prohibited after that '", - "space prohibited before that '", - "spaces preferred around that '", - "space required after that '", - "spaces required around that ", - "space required before the open brace", - "space required after that close brac", - "should be \"foo **bar\"", - "Statements should start on a tabstop", - ] - - # Check each error message - for i, message in enumerate(error_messages): - if message in error_description: - if i == 0: - fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, line_number, error_description) - elif i == 1: - fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, error_description) - elif i == 2: - fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, error_description) - elif i == 3: - fix_space_required_before_the_open_parenthesis(file_path, line_number, error_description) - elif i == 4: - fix_space_prohibited_before_semicolon(file_path, line_number, ';') - elif i == 5: - fix_should_be_foo_star_bar(file_path, line_number, error_description) - elif i == 6: - fix_spaces_prohibited_around_that(file_path, line_number, error_description) - elif i == 7: - fix_space_prohibited_after_that(file_path, line_number, error_description) - elif i == 8: - fix_space_prohibited_before_that(file_path, line_number, error_description) - elif i == 9: - fix_spaces_preferred_around_that(file_path, line_number, error_description) - elif i == 10: - fix_space_required_after_that(file_path, line_number, error_description) - elif i == 11: - fix_space_required_around_that(file_path, line_number, error_description) - elif i == 12: - fix_space_required_before_the_open_brace(file_path, line_number, error_description) - elif i == 13: - fix_space_required_after_the_close_brace(file_path, line_number, error_description) - elif i == 14: - fix_should_be_foo_star_star_bar(file_path, line_number, error_description) - elif i == 15: - run_vi_script(file_path) - -def fix_should_be_void(errors_file_path): - errors_fixed = True # Set to True initially to enter the loop - - while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration - - with open(errors_file_path, 'r') as errors_file: - # Read all lines at once to allow modification of the list while iterating - error_lines = errors_file.readlines() - - for error_line in error_lines: - if 'should probably be' in error_line and '(void)' in error_line: - # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) - if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values - - # Fix missing blank line after declaration - if should_be_void(file_path, line_number, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed - - -def should_be_void(file_path, line_number, errors_file_path): - # Convert line_number to integer - line_number = int(line_number) - specifier = '()' - replacement = '(void)' - - # Read the content of the file - with open(file_path, 'r') as file: - lines = file.readlines() - - # Replace '()' with '(void)' in the specified line - lines[line_number - 1] = lines[line_number - 1].replace(specifier, replacement) - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - - # Clean 'errors.txt' before extracting new errors - clean_errors_file(errors_file_path) - - # Update Betty errors in errors.txt - exctract_errors(file_path, errors_file_path) - - return True # Line is fixed, return True - - - -def clean_errors_file(errors_file_path): - errors_file_path = 'errors.txt' - - # Clear the content of the errors.txt file before appending new errors - open(errors_file_path, 'w').close() - - # Iterate over each file provided as a command-line argument - for file_path in sys.argv[1:]: - exctract_errors(file_path, errors_file_path) - -def fix_missing_blank_line_after_declarations(errors_file_path): - errors_fixed = True # Set to True initially to enter the loop - - while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration - - with open(errors_file_path, 'r') as errors_file: - # Read all lines at once to allow modification of the list while iterating - error_lines = errors_file.readlines() - - for error_line in error_lines: - if 'Missing a blank line after declarations' in error_line: - # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) - if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values - - # Fix missing blank line after declaration - if fix_missing_blank_line_after_declaration(file_path, line_number, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed - -def fix_missing_blank_line_after_declaration(file_path, line_number, errors_file_path): - # Convert line_number to integer - line_number = int(line_number) - - # Read the content of the file - with open(file_path, 'r') as file: - lines = file.readlines() - - line_number -= 1 - # Check if a blank line is already present - if lines[line_number].strip() == '': - return False # No fix needed, return False - - # Add a blank line after the specified line number - lines.insert(int(line_number), '\n') - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - - # Clean 'errors.txt' before extracting new errors - clean_errors_file(errors_file_path) - - return True # Line is fixed, return True - -def fix_should_be_foo_star_star_bar(file_path, line_number, error_description): #done - # Specify the specifier - specifier = '**' - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Check conditions and fix the line accordingly - if f'foo** bar' in error_description: - fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') - elif f'foo ** bar' in error_description: - fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') - elif f'foo**bar' in error_description: - fixed_line = error_line.replace(f'{specifier}', f' {specifier}') - elif f'foo* *bar' in error_description: - fixed_line = error_line.replace('* *', f' {specifier}') - else: - # If none of the conditions match, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - -def remove_unused_attribute(file_name, function_name): - try: - with open(file_name, 'r') as file: - lines = file.readlines() - - # Search for the function - pattern = r'\b' + re.escape(function_name) + r'\b[^(]*\([^)]*\)' - - function_declarations = {} # Dictionary to store function_name and its original line - - for i, line in enumerate(lines): - if re.search(pattern, line): - function_start_line = i - function_declarations[function_name] = lines[function_start_line] # Save the original line - break - else: - pass - # took a copy from the original function declaration - original_declaration = lines[function_start_line] - - # Extract and remove __attribute__((unused)) - match = re.search(r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[function_start_line]) - unused_attribute = match.group(1) if match else None - lines[function_start_line] = re.sub(r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[function_start_line]) - - # Call the existing function to generate documentation - generate_documentation(lines, function_start_line, function_name) - - # Restore __attribute__((unused)) - if unused_attribute: - lines[function_start_line] = lines[function_start_line].replace(lines[function_start_line].strip(), lines[function_start_line].strip() + ' ' + unused_attribute).strip() - - # Write back to the file - with open(file_name, 'w') as file: - file.writelines(lines) - - fix_lines_in_file(file_name, function_declarations) - except Exception as e: - print(f"Error: {e}") - -def fix_lines_in_file(file_name, function_declarations): - try: - with open(file_name, 'r') as file: - lines = file.readlines() - - # Iterate through each line in file - for i, line in enumerate(lines): - if '*/' in line and 'unused' in line: - # Check if any function_name is found in this line - for func_name, original_line in function_declarations.items(): - if func_name in line: - # Replace the line with the desired format - lines[i] = f' */\n{original_line}' - - # Check if the next line is a blank line; if so, delete it - if i + 1 < len(lines) and lines[i + 1] == '\n': - del lines[i + 1] - break - - # Write back to the file - with open(file_name, 'w') as file: - file.writelines(lines) - except Exception as e: - print(f"Error: {e}") - -def generate_documentation(lines, function_start_line, function_name): - # Extract function arguments - args_match = re.search(r'\(([^)]*)\)', lines[function_start_line]) - if args_match: - # Extract arguments from the updated text - args_text = args_match.group(1).strip() - - # Ignore if arguments are "void" - if args_text.lower() == 'void': - arguments = [] - else: - while ')' not in args_text and '\n' not in lines[function_start_line]: - # Iterate through the remaining lines until a closing parenthesis or a new line is encountered - function_start_line += 1 - args_text += lines[function_start_line].strip() - - # Continue searching for closing parenthesis in the line and take the word before it as the second argument - closing_parenthesis_pos = args_text.find(')') - if closing_parenthesis_pos != -1: - args_text = args_text[:closing_parenthesis_pos].strip() - - arguments = args_text.split(',') - arguments = [arg.strip().split(' ')[-1].lstrip('*') if '*' in arg else arg.strip().split(' ')[-1] for arg in arguments if arg.strip()] - - # Create documentation - documentation = [] - documentation.append('/**') - documentation.append(f' * {function_name} - a Function that ...') - if arguments: - for arg in arguments: - # Correctly identify the second argument as the word before the last closing parenthesis - if arg == arguments[-1]: - documentation.append(f' * @{arg}: Description of {arg}.') - else: - documentation.append(f' * @{arg}: Description of {arg}.') - documentation.append(' * Return: Description of the return value.') - documentation.append(' */\n') # Add a new line after closing '/' - - # Insert documentation into the file - lines.insert(function_start_line, '\n'.join(documentation)) - -def extract_functions_with_no_description(file_path): - functions = [] - file_path = 'errors.txt' - with open(file_path, 'r') as errors_file: - for line in errors_file: - # Check if the error description contains 'no description found for function' - if 'no description found for function' in line: - # Split the line by spaces and get the word after 'no description found for function' - words = line.split() - index = words.index('no') + 5 # Adjust index based on the specific position of the function name - function_name = words[index] - - # Append the function name to the list - functions.append(function_name) - - return functions -def fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, line_number, error_description): - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Find the specifier in the line and fix it - fixed_line = error_line.replace(f' {specifier}', specifier) - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, error_description): - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Find the specifier in the line and fix it - fixed_line = error_line.replace(f'{specifier} ', specifier) - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, error_description): - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - error_line = clean_up_line(error_line) - # Find the specifier in the line and fix it - fixed_line = error_line.replace(f' {specifier}', specifier) - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_required_before_the_open_parenthesis(file_path, line_number, error_description): - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - error_line = clean_up_line(error_line) - # Find the specifier in the line and fix it - fixed_line = error_line.replace(specifier, f' {specifier}') - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - -def fix_brace_should_be_on_the_next_line(errors_file_path): - errors_fixed = True # Set to True initially to enter the loop - - while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration - - with open(errors_file_path, 'r') as errors_file: - # Read all lines at once to allow modification of the list while iterating - error_lines = errors_file.readlines() - - for i, error_line in enumerate(error_lines): - if 'that open brace { should be on the next line' in error_line: - # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) - if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values - - # Fix missing blank line after declaration - if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed - - # Add a message in the error line - error_lines[i] += " (brace moved to the next line)" - - elif 'following function declarations go on the next line' in error_line: - # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) - if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values - - # Fix missing blank line after declaration - if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed - - # Add a message in the error line - error_lines[i] += " (brace moved to the next line)" - - - -def fix_brace_on_the_next_line(file_path, line_number, errors_file_path): - # Convert line_number to integer - line_number = int(line_number) - - # Read the content of the file - with open(file_path, 'r') as file: - lines = file.readlines() - - # Check if the specified line is within the file's range - if 1 <= line_number <= len(lines): - # Find the brace '{' in the line - line = lines[line_number - 1] - - # Replace '{' with '\n{' to move it to the next line - lines[line_number - 1] = line.replace('{', '\n{') - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - - # Clean 'errors.txt' before extracting new errors - clean_errors_file(errors_file_path) - - return True # Line is fixed, return True - - return False - - -def brace_go_next_line(file_path, line_number, error_description): - specifier = '{' - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Check if the specifier is present in the error description - if specifier in error_description: - # Replace the specifier with a newline before the specifier - fixed_line = error_line.replace(f'{specifier}', f'\n{specifier}') - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - -def fix_brace_should_be_on_the_previous_line(errors_file_path): - errors_fixed = True # Set to True initially to enter the loop - - while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration - - with open(errors_file_path, 'r') as errors_file: - # Read all lines at once to allow modification of the list while iterating - error_lines = errors_file.readlines() - - for error_line in error_lines: - if 'that open brace { should be on the previous line' in error_line: - # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) - if len(variables) >= 2: - file_path, line_number = variables[:2] # Take the first two values - - # Fix missing blank line after declaration - if fix_brace_on_the_previous_line(file_path, line_number, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed - -def fix_brace_on_the_previous_line(file_path, line_number, errors_file_path): - # Convert line_number to integer - line_number = int(line_number) - - # Read the content of the file - with open(file_path, 'r') as file: - lines = file.readlines() - - line_number -= 1 - - # Find the position of the '{' in the previous line - brace_position = lines[line_number].rfind('{') - - if brace_position == -1: - return False # No '{' found in the previous line, no fix needed - - # Remove spaces and newline before the '{' - lines[line_number] = lines[line_number][:brace_position].rstrip() + '{' + lines[line_number][brace_position + 1:] - - # Delete the previous '\n' character to move the brace to the previous line - if lines[line_number - 1].endswith('\n'): - lines[line_number - 1] = lines[line_number - 1].rstrip() + ' ' if not lines[line_number - 1].endswith(' ') else lines[line_number - 1].rstrip() - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - - # Clean 'errors.txt' before extracting new errors - clean_errors_file(errors_file_path) - - return True # Line is fixed, return True - - -def fix_space_prohibited_before_semicolon(file_path, line_number, specifier): - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - - # Replace any space before the semicolon specifier - fixed_line = error_line.replace(f' {specifier}', specifier) - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_should_be_foo_star_bar(file_path, line_number, error_description): #done - # Specify the specifier - specifier = '*' - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Check conditions and fix the line accordingly - if f'foo** bar' in error_description: - fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') - elif f'foo* bar' in error_description: - fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') - elif f'foo * bar' in error_description: - fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') - elif f'foo*bar' in error_description: - fixed_line = error_line.replace(f'{specifier}', f' {specifier}') - else: - # If none of the conditions match, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_spaces_prohibited_around_that(file_path, line_number, error_description): - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") - - if specifier_start < 0 or specifier_end < 0: - # Unable to find valid specifier, return without making changes - return - - specifier = error_description[specifier_start:specifier_end] - - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') - - if context_start < 0 or context_end < 0: - # Unable to find valid context, return without making changes - return - - context = error_description[context_start:context_end].strip() - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Check if the provided line number is within the valid range - if not (1 <= int(line_number) <= len(lines)): - # Invalid line number, return without making changes - return - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Fix line according to the context conditions - if context == 'WxW': - fixed_line = error_line.replace(f' {specifier} ', f'{specifier}') - elif context == 'WxV': - fixed_line = error_line.replace(f' {specifier}', f'{specifier}') - elif context == 'VxW': - fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') - else: - # If the context doesn't match known conditions, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - -def fix_space_prohibited_after_that(file_path, line_number, error_description): #done - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") - - if specifier_start < 0 or specifier_end < 0: - # Unable to find valid specifier, return without making changes - return - - specifier = error_description[specifier_start:specifier_end] - - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') - - if context_start < 0 or context_end < 0: - # Unable to find valid context, return without making changes - return - - context = error_description[context_start:context_end].strip() - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Fix line according to the context conditions - if context == 'WxW': - fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') - elif context == 'ExW': - fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') - else: - # If the context doesn't match known conditions, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_prohibited_before_that(file_path, line_number, error_description): - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") - - if specifier_start < 0 or specifier_end < 0: - # Unable to find valid specifier, return without making changes - return - - specifier = error_description[specifier_start:specifier_end] - - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') - - if context_start < 0 or context_end < 0: - # Unable to find valid context, return without making changes - return - - context = error_description[context_start:context_end].strip() - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Fix line according to the context conditions - if context == 'WxV' or context == 'WxO' or context == 'WxE' or context == 'WxW': - fixed_line = error_line.replace(f' {specifier}', f'{specifier}') - else: - # If the context doesn't match known conditions, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_spaces_preferred_around_that(file_path, line_number, error_description): #done - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") - - if specifier_start < 0 or specifier_end < 0: - # Unable to find valid specifier, return without making changes - return - - specifier = error_description[specifier_start:specifier_end] - - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') - - if context_start < 0 or context_end < 0: - # Unable to find valid context, return without making changes - return - - context = error_description[context_start:context_end].strip() - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Check if the line already satisfies the condition - if f' {specifier} ' in error_line: - # If the required space is already present, skip the fix - return - - # Fix line according to the context conditions - if context == 'VxV': - fixed_line = error_line.replace(f'{specifier}', f' {specifier} ') - elif context == 'WxV': - fixed_line = error_line.replace(f' {specifier}', f' {specifier} ') - elif context == 'VxW': - fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') - else: - # If the context doesn't match known conditions, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_required_around_that(file_path, line_number, error_description): #done - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") - - if specifier_start < 0 or specifier_end < 0: - # Unable to find valid specifier, return without making changes - return - - specifier = error_description[specifier_start:specifier_end] - - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') - - if context_start < 0 or context_end < 0: - # Unable to find valid context, return without making changes - return - - context = error_description[context_start:context_end].strip() - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Check if the line already satisfies the condition - if f' {specifier} ' in error_line: - # If the required space is already present, skip the fix - return - - # Fix line according to the context conditions - if context == 'VxV': - fixed_line = error_line.replace(f'{specifier}', f' {specifier} ') - elif context == 'WxV': - fixed_line = error_line.replace(f' {specifier}', f' {specifier} ') - elif context == 'VxW': - fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') - else: - # If the context doesn't match known conditions, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_required_after_that(file_path, line_number, error_description): - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") - - if specifier_start < 0 or specifier_end < 0: - # Unable to find valid specifier, return without making changes - return - - specifier = error_description[specifier_start:specifier_end] - - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') - - if context_start < 0 or context_end < 0: - # Unable to find valid context, return without making changes - return - - context = error_description[context_start:context_end].strip() - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - - # Fix line according to the context conditions - if context == 'WxV' or context == 'VxV': - fixed_line = error_line.replace(f'{specifier}', f'{specifier} ') - else: - # If the context doesn't match known conditions, return without making changes - return - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_required_before_the_open_brace(file_path, line_number, error_description): - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - error_line = clean_up_line(error_line) - # Find the specifier in the line and fix it - fixed_line = error_line.replace(specifier, f' {specifier}') - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) -def fix_space_required_after_the_close_brace(file_path, line_number, error_description): - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] - - # Read the file content - with open(file_path, 'r') as file: - lines = file.readlines() - - # Find the line with the error - error_line = lines[int(line_number) - 1] - error_line = clean_up_line(error_line) - # Find the specifier in the line and fix it - fixed_line = error_line.replace(specifier, f'{specifier} ') - - # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: - file.writelines(lines) - - -# Example usage -if __name__ == "__main__": -# Assuming you have an errors.txt file with test data - errors_file_path = 'errors.txt' - process_error_file(errors_file_path) - \ No newline at end of file From e74aee22077a836ad4939f13e5a94cf3052e118a Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:03:53 +0000 Subject: [PATCH 031/103] delete unnecessary files --- dist/bettyfixer-1.4.6-py3.10.egg | Bin 29870 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 dist/bettyfixer-1.4.6-py3.10.egg diff --git a/dist/bettyfixer-1.4.6-py3.10.egg b/dist/bettyfixer-1.4.6-py3.10.egg deleted file mode 100644 index 61c6814b613bf1838888a1b14a3233da7394b998..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 29870 zcmaI7bC74vvM$`1#CG6>JwYr=4^fvWNotfQ+9F?SAC?OEH1 zi8Uip()NTm+r#S#*>c?5!qj6wDGMnd6UVom^ZW2ZQ+xk4kEY`Yc{yHDu)4k>k$(5I zn&u{WP4l`M;d@prvYM7d^qkTUnaDpo8~B8aY|OeX8`sdi`iYUhwf<|OsXG1s5?!)7 z1)JDg)gHGKmONJdM@_1c4%qb5;yD9!kU6l)Jj3x2xl^YmLGq)YrXuHj!w`futOI6y z<6E9R+GI^YaTE=rQiWxYvE!JD6bv9J#9b(pEo*d_On{KpoH@|&nZp!_GkMu4pGwZ? zSzs|Mu!@JjwISpP2R!Gy$sB-`{UGxqUe(6h&)7Hd)UCndCHIr%0obTwwu$PRrx|!M z3fmQ%_Z!e{Ad9_tV$SQ*X>OiEKJSQ))TY4}(t-F$vQr|>W*h#Vs01*|H85+`c+cxt zTJvb|BVdj)o%gjyqthIh2(2LpF?#j&L|tXvOt{^>zQ+CYeqnxLat%jr?f63jM5yo0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F!UfHs$mS-_)jG*o_@c2nZ=2-@cuF~jD5~h@agCu5&BvHkI$LOkg4w5GpmJ<@875K4d zpJ~n(=k*2V*#w5+=CekN^d)N~1DbqW%j0mqn_Cn`Bq$A^#nTP15XC)sf7JC|fE z{WcYx!AF;?w7cy)lRiY4C8X3})_feY$9DG)tOgmzRT?hsD81f@>)=hOkST=}Zcu*O zE`I;v6J{xy9C`9&c*489LsT+UN`}I8{q^#1 zx21nM$Gu+u+Melu76SnFe#5`o?*Cr?hgs8W!k^wfe>w8}>#Fyw{w0X`Z^Hj(g!CHq z+6U=3>hw?4YgeS#nAes@zcH3je`NHh!O?5PYe%Esh{`_^fAcqb&G_?+`ODPkUst`~ z*`JJmSseYj{C{&e`n{aw*I|f1L?-|6J9^D{ZEEzJ;rMsP-v@|o-Cl!UyMO!!CH(Tf z_#>Hrdx5+ry!OfXP5AQ5I_gitA44hsOysrR>~BojFAc#^zk|3c|K}io7Ue$z0DnEJ{&I%H1X%xi KM{WJr-Twhu;?i~i From 4c4689b71617ee12a350a7b8ef0918acfe7f6ded Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:13:55 +0000 Subject: [PATCH 032/103] Refactor betty_fixer.py: import statements and function names --- bettyfixer/betty_fixer.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index b161d25..b5f2fc3 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -2,10 +2,27 @@ import re import sys import os -from bettyfixer.backup import * -from bettyfixer.errors_extractor import * -from bettyfixer.extract_line import * -from bettyfixer.autoprototype import * +from bettyfixer.backup import create_backup +from bettyfixer.errors_extractor import exctract_errors +from bettyfixer.extract_line import ( + process_error_file, + clean_errors_file, + run_vi_script, + extract_functions_with_no_description, + remove_extra_spaces, + remove_unused_attribute, + fix_missing_blank_line_after_declarations, + fix_should_be_void, + fix_brace_should_be_on_the_next_line, + fix_brace_should_be_on_the_previous_line, + extract_and_print_variables +) +from bettyfixer.autoprototype import ( + betty_check, + print_check_betty_first, + print_header_name_missing, + autoproto +) HIDDEN_FILE_NAME = ".processed_files" @@ -211,7 +228,7 @@ def fix_betty_style(file_paths): fix_missing_blank_line_after_declarations(errors_file_path) remove_blank_lines_inside_comments(file_path) fix_should_be_void(errors_file_path) - More_than_5_functions_in_the_file(errors_file_path) + more_than_5_functions_in_the_file(errors_file_path) fix_brace_should_be_on_the_next_line(errors_file_path) fix_brace_should_be_on_the_previous_line(errors_file_path) content = read_file(file_path) @@ -220,7 +237,7 @@ def fix_betty_style(file_paths): betty_handler(errors_file_path) -def More_than_5_functions_in_the_file(errors_file_path): +def more_than_5_functions_in_the_file(errors_file_path): """ Fix the error 'More than 5 functions in the file' in the specified file. Args: @@ -285,7 +302,8 @@ def find_available_file_name(original_file_path): """ Find the next available file name based on the specified file path. Args: - original_file_path (str): The path of the original file to find the next available file name for. + original_file_path (str): + The path of the original file to find the next available file name for. Returns: str: The next available file name based on the original file path. """ From 0280f4ecc71cea61137f40b0fe6b4c749955222f Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:27:24 +0000 Subject: [PATCH 033/103] process_errors needs reviewing --- bettyfixer/betty_fixer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index b5f2fc3..0c101dc 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -126,7 +126,7 @@ def remove_trailing_whitespaces(content): return re.sub(r'[ \t]+$', '', content, flags=re.MULTILINE) -def process_errors(file_path): +def process_errors(file_path): # ❗ This function doesn't make sense to me [Younis] """ Process the errors for the specified file. Args: From a2084af585fdd9c54348606fe181a64584169066 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:28:23 +0000 Subject: [PATCH 034/103] Refactor code to create a new file from specified line to end --- bettyfixer/betty_fixer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 0c101dc..8dd0296 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -278,7 +278,8 @@ def more_than_5_functions_in_the_file(errors_file_path): counter += 1 if counter == 6: - # Create a new file with the content from the specified line to the end of the file + # Create a new file with the content + # from the specified line to the end of the file copy_remaining_lines( lines, block_start_line, new_file_path) # Remove the content from the main file From ee5c40a96bde75208fbcdd496ae66d165fbe5317 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:42:41 +0000 Subject: [PATCH 035/103] Fix formatting issues in extract_line.py --- bettyfixer/extract_line.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 69a09ba..cf4ef25 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -64,7 +64,8 @@ def extract_and_print_variables(error_line): Args: error_line (str): The error line to extract variables from. Returns: - tuple: A tuple containing the file path, line number, and error description. + tuple: A tuple containing the file path, line number, + and error description. """ # Split the error line to extract variables @@ -72,7 +73,8 @@ def extract_and_print_variables(error_line): if len(parts) >= 3: # Extracting file path and line number file_path, line_number, *error_parts = parts - # Join all parts except the file path and line number to get the error description + # Join all parts except the file path and line number + # to get the error description error_description = ":".join(error_parts[1:]).strip() # Further processing if needed @@ -130,7 +132,7 @@ def fix_errors_from_file(file_path, line_number, error_description): for i, message in enumerate(error_messages): if message in error_description: if i == 0: - fix_space_prohibited_between_function_name_and_open_parenthesis( + fix_space_prohibited_between_func_name_and_open_parenthesis( file_path, line_number, error_description) elif i == 1: fix_space_prohibited_after_that_open_parenthesis( @@ -187,10 +189,11 @@ def fix_should_be_void(errors_file_path): errors_fixed = True # Set to True initially to enter the loop while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration + errors_fixed = False # Resets flag at the beginning of each iteration with open(errors_file_path, 'r', encoding='utf-8') as errors_file: - # Read all lines at once to allow modification of the list while iterating + # Read all lines at once to allow modification + # of the list while iterating error_lines = errors_file.readlines() for error_line in error_lines: @@ -340,13 +343,13 @@ def fix_should_be_foo_star_star_bar(file_path, line_number, error_description): error_line = lines[int(line_number) - 1] # Check conditions and fix the line accordingly - if f'foo** bar' in error_description: + if 'foo** bar' in error_description: fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') - elif f'foo ** bar' in error_description: + elif 'foo ** bar' in error_description: fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') - elif f'foo**bar' in error_description: + elif 'foo**bar' in error_description: fixed_line = error_line.replace(f'{specifier}', f' {specifier}') - elif f'foo* *bar' in error_description: + elif 'foo* *bar' in error_description: fixed_line = error_line.replace('* *', f' {specifier}') else: # If none of the conditions match, return without making changes @@ -520,7 +523,7 @@ def extract_functions_with_no_description(file_path): return functions -def fix_space_prohibited_between_function_name_and_open_parenthesis(file_path, line_number, error_description): +def fix_space_prohibited_between_func_name_and_open_parenthesis(file_path, line_number, error_description): """ Fix the specified line in the file. Args: From b61bc50b9d3d938d52759e7753444f7ab6c40419 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 09:07:50 +0000 Subject: [PATCH 036/103] Refactor error file processing functions --- bettyfixer/extract_line.py | 47 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index cf4ef25..a21cbab 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -44,13 +44,13 @@ def remove_extra_spaces(input_text): return cleaned_text -def process_error_file(errors_file_path): +def process_error_file(error_file_path): """ Process the errors from the errors.txt file. Args: - errors_file_path (str): The path of the errors.txt file. + error_file_path (str): The path of the errors.txt file. """ - with open(errors_file_path, 'r', encoding='utf-8') as errors_file: + with open(error_file_path, 'r', encoding='utf-8') as errors_file: for error_line in errors_file: variables = extract_and_print_variables(error_line) if variables: @@ -180,42 +180,42 @@ def fix_errors_from_file(file_path, line_number, error_description): run_vi_script(file_path) -def fix_should_be_void(errors_file_path): +def fix_should_be_void(error_file_path): """ Fix errors in the specified file. Args: - errors_file_path (str): The path of the file to fix errors in. + error_file_path (str): The path of the file to fix errors in. """ errors_fixed = True # Set to True initially to enter the loop while errors_fixed: errors_fixed = False # Resets flag at the beginning of each iteration - with open(errors_file_path, 'r', encoding='utf-8') as errors_file: + with open(error_file_path, 'r', encoding='utf-8') as errors_file: # Read all lines at once to allow modification # of the list while iterating error_lines = errors_file.readlines() - for error_line in error_lines: - if 'should probably be' in error_line and '(void)' in error_line: - # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) + for err_line in error_lines: + if 'should probably be' in err_line and '(void)' in err_line: + # Extract (file_path, line_number) from the err line + variables = extract_and_print_variables(err_line) if len(variables) >= 2: # Take the first two values - file_path, line_number = variables[:2] + file_path, line_num = variables[:2] # Fix missing blank line after declaration - if should_be_void(file_path, line_number, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed + if should_be_void(file_path, line_num, 'errors.txt'): + errors_fixed = True # Set flag if line is fixed -def should_be_void(file_path, line_number, errors_file_path): +def should_be_void(file_path, line_number, error_file_path): """ Fix the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. - errors_file_path (str): The path of the errors.txt file. + error_file_path (str): The path of the errors.txt file. Returns: bool: True if the line is fixed, False otherwise. """ @@ -237,10 +237,10 @@ def should_be_void(file_path, line_number, errors_file_path): file.writelines(lines) # Clean 'errors.txt' before extracting new errors - clean_errors_file(errors_file_path) + clean_errors_file(error_file_path) # Update Betty errors in errors.txt - exctract_errors(file_path, errors_file_path) + exctract_errors(file_path, error_file_path) return True # Line is fixed, return True @@ -270,10 +270,11 @@ def fix_missing_blank_line_after_declarations(errors_file_path): errors_fixed = True # Set to True initially to enter the loop while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration + errors_fixed = False # Reset flag at the beginning of each iteration with open(errors_file_path, 'r', encoding='utf-8') as errors_file: - # Read all lines at once to allow modification of the list while iterating + # Read all lines at once to allow + # modification of the list while iterating error_lines = errors_file.readlines() for error_line in error_lines: @@ -282,16 +283,16 @@ def fix_missing_blank_line_after_declarations(errors_file_path): variables = extract_and_print_variables(error_line) if len(variables) >= 2: # Take the first two values - file_path, line_number = variables[:2] + file_path, line_num = variables[:2] # Fix missing blank line after declaration - if fix_missing_blank_line_after_declaration(file_path, line_number, 'errors.txt'): + if fix_missing_line_after_declaration(file_path, line_num, 'errors.txt'): errors_fixed = True # Set the flag if a line is fixed -def fix_missing_blank_line_after_declaration(file_path, line_number, errors_file_path): +def fix_missing_line_after_declaration(file_path, line_number, errors_file_path): """ - Fix the specified line in the file. + Fix missing blank line after the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. From bff70f9fde9a7436fb6223ff7d95c5b259124b47 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:39:11 +0000 Subject: [PATCH 037/103] Refactor variable names and update comments This commit refactors variable names for clarity and updates relevant comments to improve code readability. --- bettyfixer/extract_line.py | 70 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index a21cbab..47b95df 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -283,16 +283,16 @@ def fix_missing_blank_line_after_declarations(errors_file_path): variables = extract_and_print_variables(error_line) if len(variables) >= 2: # Take the first two values - file_path, line_num = variables[:2] + fpath, line_num = variables[:2] # Fix missing blank line after declaration - if fix_missing_line_after_declaration(file_path, line_num, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed + if fix_ln_after_declare(fpath, line_num, 'errors.txt'): + errors_fixed = True # Setflag if line is fixed -def fix_missing_line_after_declaration(file_path, line_number, errors_file_path): +def fix_ln_after_declare(file_path, line_number, errors_file_path): """ - Fix missing blank line after the specified line in the file. + Fix missing blank line after declaration. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. @@ -368,8 +368,10 @@ def remove_unused_attribute(file_name, function_name): """ Remove __attribute__((unused)) from the specified function in the file. Args: - file_name (str): The path of the file to remove __attribute__((unused)) from. - function_name (str): The name of the function to remove __attribute__((unused)) from. + file_name (str): The path of the file to remove + __attribute__((unused)) from. + function_name (str): The name of the function to remove + __attribute__((unused)) from. """ try: with open(file_name, 'r', encoding='utf-8') as file: @@ -378,7 +380,7 @@ def remove_unused_attribute(file_name, function_name): # Search for the function pattern = r'\b' + re.escape(function_name) + r'\b[^(]*\([^)]*\)' - function_declarations = {} # Dictionary to store function_name and its original line + function_declarations = {} # Dict to store function_name and its line for i, line in enumerate(lines): if re.search(pattern, line): @@ -389,7 +391,7 @@ def remove_unused_attribute(file_name, function_name): else: pass # took a copy from the original function declaration - original_declaration = lines[function_start_line] + original_declaration = lines[function_start_line] # ❗ Unused variable # Extract and remove __attribute__((unused)) match = re.search( @@ -467,7 +469,8 @@ def generate_documentation(lines, function_start_line, function_name): arguments = [] else: while ')' not in args_text and '\n' not in lines[function_start_line]: - # Iterate through the remaining lines until a closing parenthesis or a new line is encountered + # Iterate through the remaining lines until a closing parenthesis + # or a new line is encountered function_start_line += 1 args_text += lines[function_start_line].strip() @@ -876,13 +879,13 @@ def fix_should_be_foo_star_bar(file_path, line_number, error_description): # do error_line = lines[int(line_number) - 1] # Check conditions and fix the line accordingly - if f'foo** bar' in error_description: + if 'foo** bar' in error_description: fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') - elif f'foo* bar' in error_description: + elif 'foo* bar' in error_description: fixed_line = error_line.replace(f'{specifier} ', f' {specifier}') - elif f'foo * bar' in error_description: + elif 'foo * bar' in error_description: fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') - elif f'foo*bar' in error_description: + elif 'foo*bar' in error_description: fixed_line = error_line.replace(f'{specifier}', f' {specifier}') else: # If none of the conditions match, return without making changes @@ -892,7 +895,7 @@ def fix_should_be_foo_star_bar(file_path, line_number, error_description): # do lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) @@ -929,7 +932,7 @@ def fix_spaces_prohibited_around_that(file_path, line_number, error_description) lines = file.readlines() # Check if the provided line number is within the valid range - if not (1 <= int(line_number) <= len(lines)): + if not 1 <= int(line_number) <= len(lines): # Invalid line number, return without making changes return @@ -1036,7 +1039,7 @@ def fix_space_prohibited_before_that(file_path, line_number, error_description): context = error_description[context_start:context_end].strip() # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -1053,7 +1056,7 @@ def fix_space_prohibited_before_that(file_path, line_number, error_description): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) @@ -1086,7 +1089,7 @@ def fix_spaces_preferred_around_that(file_path, line_number, error_description): context = error_description[context_start:context_end].strip() # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -1112,7 +1115,7 @@ def fix_spaces_preferred_around_that(file_path, line_number, error_description): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) @@ -1145,7 +1148,7 @@ def fix_space_required_around_that(file_path, line_number, error_description): context = error_description[context_start:context_end].strip() # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -1171,7 +1174,7 @@ def fix_space_required_around_that(file_path, line_number, error_description): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) @@ -1204,7 +1207,7 @@ def fix_space_required_after_that(file_path, line_number, error_description): context = error_description[context_start:context_end].strip() # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -1221,7 +1224,7 @@ def fix_space_required_after_that(file_path, line_number, error_description): lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) @@ -1238,7 +1241,7 @@ def fix_space_required_before_the_open_brace(file_path, line_number, error_descr specifier = error_description[specifier_index:-1] # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -1251,7 +1254,7 @@ def fix_space_required_before_the_open_brace(file_path, line_number, error_descr lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) @@ -1265,28 +1268,25 @@ def fix_space_required_after_the_close_brace(file_path, line_number, error_descr """ # Extract specifier from error_description specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + specifier = error_description[specifier_index:-1] # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error error_line = lines[int(line_number) - 1] error_line = clean_up_line(error_line) # Find the specifier in the line and fix it - fixed_line = error_line.replace(specifier, f'{specifier} ') + fixed_line = error_line.replace(specifier, f'{specifier} ') # ❗ Unused variable # Replace the line in the file - lines[int(line_number) - 1] = fixed_line - - # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) # Example usage if __name__ == "__main__": # Assuming you have an errors.txt file with test data - errors_file_path = 'errors.txt' - process_error_file(errors_file_path) + ERROR_FILE_PATH = 'errors.txt' + process_error_file(ERROR_FILE_PATH) From d6c3246e29b3d6dea1e160fa71c8603b6f318737 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:51:08 +0000 Subject: [PATCH 038/103] Fix formatting issues in extract_line.py --- bettyfixer/extract_line.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 47b95df..5baf9f9 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -405,8 +405,9 @@ def remove_unused_attribute(file_name, function_name): # Restore __attribute__((unused)) if unused_attribute: - lines[function_start_line] = lines[function_start_line].replace(lines[function_start_line].strip( - ), lines[function_start_line].strip() + ' ' + unused_attribute).strip() + lines[function_start_line] = lines[function_start_line].\ + replace(lines[function_start_line].strip( + ), lines[function_start_line].strip() + ' ' + unused_attribute).strip() # Write back to the file with open(file_name, 'w', encoding='utf-8') as file: @@ -474,7 +475,8 @@ def generate_documentation(lines, function_start_line, function_name): function_start_line += 1 args_text += lines[function_start_line].strip() - # Continue searching for closing parenthesis in the line and take the word before it as the second argument + # Continue searching for closing parenthesis in the line + # and take the word before it as the second argument closing_parenthesis_pos = args_text.find(')') if closing_parenthesis_pos != -1: args_text = args_text[:closing_parenthesis_pos].strip() @@ -489,7 +491,8 @@ def generate_documentation(lines, function_start_line, function_name): documentation.append(f' * {function_name} - a Function that ...') if arguments: for arg in arguments: - # Correctly identify the second argument as the word before the last closing parenthesis + # Correctly identify the second argument as + # the word before the last closing parenthesis if arg == arguments[-1]: documentation.append(f' * @{arg}: Description of {arg}.') else: @@ -515,7 +518,7 @@ def extract_functions_with_no_description(file_path): for line in errors_file: # Check if the error description contains 'no description found for function' if 'no description found for function' in line: - # Split the line by spaces and get the word after 'no description found for function' + # Split the line by space and get the word after 'no description found for function' words = line.split() # Adjust index based on the specific position of the function name index = words.index('no') + 5 @@ -529,7 +532,7 @@ def extract_functions_with_no_description(file_path): def fix_space_prohibited_between_func_name_and_open_parenthesis(file_path, line_number, error_description): """ - Fix the specified line in the file. + Fix space prohibited between function name and open parenthesis in the specified file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. @@ -540,7 +543,7 @@ def fix_space_prohibited_between_func_name_and_open_parenthesis(file_path, line_ specifier = error_description[specifier_index:-1] # Read the file content - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error @@ -553,7 +556,7 @@ def fix_space_prohibited_between_func_name_and_open_parenthesis(file_path, line_ lines[int(line_number) - 1] = fixed_line # Write the modified content back to the file - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) @@ -1268,7 +1271,7 @@ def fix_space_required_after_the_close_brace(file_path, line_number, error_descr """ # Extract specifier from error_description specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + specifier = error_description[specifier_index:-1] # Read the file content with open(file_path, 'r', encoding='utf-8') as file: @@ -1278,7 +1281,8 @@ def fix_space_required_after_the_close_brace(file_path, line_number, error_descr error_line = lines[int(line_number) - 1] error_line = clean_up_line(error_line) # Find the specifier in the line and fix it - fixed_line = error_line.replace(specifier, f'{specifier} ') # ❗ Unused variable + fixed_line = error_line.replace( + specifier, f'{specifier} ') # ❗ Unused variable # Replace the line in the file with open(file_path, 'w', encoding='utf-8') as file: From 6a86411ec56cda62c7df0bdbf8d1aa0196804035 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 13:40:14 +0000 Subject: [PATCH 039/103] Fix unused attribute bug in extract_line.py --- bettyfixer/extract_line.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 5baf9f9..addef1d 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -384,30 +384,30 @@ def remove_unused_attribute(file_name, function_name): for i, line in enumerate(lines): if re.search(pattern, line): - function_start_line = i + fn_start_line = i # Save the original line - function_declarations[function_name] = lines[function_start_line] + function_declarations[function_name] = lines[fn_start_line] break else: pass # took a copy from the original function declaration - original_declaration = lines[function_start_line] # ❗ Unused variable + original_declaration = lines[fn_start_line] # ❗ Unused variable # Extract and remove __attribute__((unused)) match = re.search( - r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[function_start_line]) + r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[fn_start_line]) unused_attribute = match.group(1) if match else None - lines[function_start_line] = re.sub( - r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[function_start_line]) + lines[fn_start_line] = re.sub( + r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[fn_start_line]) # Call the existing function to generate documentation - generate_documentation(lines, function_start_line, function_name) + generate_documentation(lines, fn_start_line, function_name) # Restore __attribute__((unused)) if unused_attribute: - lines[function_start_line] = lines[function_start_line].\ - replace(lines[function_start_line].strip( - ), lines[function_start_line].strip() + ' ' + unused_attribute).strip() + lines[fn_start_line] = lines[fn_start_line].\ + replace(lines[fn_start_line].strip( + ), lines[fn_start_line].strip() + ' ' + unused_attribute).strip() # Write back to the file with open(file_name, 'w', encoding='utf-8') as file: From 792629ecd613f064df6eda7ac6aa7ad609cf7286 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 13:48:57 +0000 Subject: [PATCH 040/103] Fix unused attribute extraction in extract_line.py --- bettyfixer/extract_line.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index addef1d..c5424fc 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -384,30 +384,30 @@ def remove_unused_attribute(file_name, function_name): for i, line in enumerate(lines): if re.search(pattern, line): - fn_start_line = i + fn_st_line = i # function start line # Save the original line - function_declarations[function_name] = lines[fn_start_line] + function_declarations[function_name] = lines[fn_st_line] break else: pass # took a copy from the original function declaration - original_declaration = lines[fn_start_line] # ❗ Unused variable + original_declaration = lines[fn_st_line] # ❗ Unused variable # Extract and remove __attribute__((unused)) match = re.search( - r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[fn_start_line]) + r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[fn_st_line]) unused_attribute = match.group(1) if match else None - lines[fn_start_line] = re.sub( - r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[fn_start_line]) + lines[fn_st_line] = re.sub( + r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[fn_st_line]) # Call the existing function to generate documentation - generate_documentation(lines, fn_start_line, function_name) + generate_documentation(lines, fn_st_line, function_name) # Restore __attribute__((unused)) if unused_attribute: - lines[fn_start_line] = lines[fn_start_line].\ - replace(lines[fn_start_line].strip( - ), lines[fn_start_line].strip() + ' ' + unused_attribute).strip() + lines[fn_st_line] = lines[fn_st_line].\ + replace(lines[fn_st_line].strip( + ), lines[fn_st_line].strip() + ' ' + unused_attribute).strip() # Write back to the file with open(file_name, 'w', encoding='utf-8') as file: @@ -439,7 +439,7 @@ def fix_lines_in_file(file_name, function_declarations): # Replace the line with the desired format lines[i] = f' */\n{original_line}' - # Check if the next line is a blank line; if so, delete it + # Check if the next line is a blank; if so, delete it if i + 1 < len(lines) and lines[i + 1] == '\n': del lines[i + 1] break @@ -451,16 +451,16 @@ def fix_lines_in_file(file_name, function_declarations): print(f"Error: {e}") -def generate_documentation(lines, function_start_line, function_name): +def generate_documentation(lines, fn_start_ln, function_name): """ Generate documentation for the specified function in the file. Args: lines (list): A list of lines in the file. - function_start_line (int): The line number where the function starts. - function_name (str): The name of the function to generate documentation for. + fn_start_ln (int): The line number where the function starts. + function_name (str): The name of the function to generate documentation """ # Extract function arguments - args_match = re.search(r'\(([^)]*)\)', lines[function_start_line]) + args_match = re.search(r'\(([^)]*)\)', lines[fn_start_ln]) if args_match: # Extract arguments from the updated text args_text = args_match.group(1).strip() @@ -469,11 +469,11 @@ def generate_documentation(lines, function_start_line, function_name): if args_text.lower() == 'void': arguments = [] else: - while ')' not in args_text and '\n' not in lines[function_start_line]: + while ')' not in args_text and '\n' not in lines[fn_start_ln]: # Iterate through the remaining lines until a closing parenthesis # or a new line is encountered - function_start_line += 1 - args_text += lines[function_start_line].strip() + fn_start_ln += 1 + args_text += lines[fn_start_ln].strip() # Continue searching for closing parenthesis in the line # and take the word before it as the second argument @@ -501,7 +501,7 @@ def generate_documentation(lines, function_start_line, function_name): documentation.append(' */\n') # Add a new line after closing '/' # Insert documentation into the file - lines.insert(function_start_line, '\n'.join(documentation)) + lines.insert(fn_start_ln, '\n'.join(documentation)) def extract_functions_with_no_description(file_path): From b91fda74a8ff0d76a47b7bab674810c43303327c Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 13:50:31 +0000 Subject: [PATCH 041/103] Refactor argument extraction in generate_documentation function --- bettyfixer/extract_line.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index c5424fc..90558f1 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -470,7 +470,7 @@ def generate_documentation(lines, fn_start_ln, function_name): arguments = [] else: while ')' not in args_text and '\n' not in lines[fn_start_ln]: - # Iterate through the remaining lines until a closing parenthesis + # Iterate through the remaining lines until a closing '()' # or a new line is encountered fn_start_ln += 1 args_text += lines[fn_start_ln].strip() @@ -482,8 +482,9 @@ def generate_documentation(lines, fn_start_ln, function_name): args_text = args_text[:closing_parenthesis_pos].strip() arguments = args_text.split(',') - arguments = [arg.strip().split(' ')[-1].lstrip('*') if '*' in arg else arg.strip( - ).split(' ')[-1] for arg in arguments if arg.strip()] + arguments = [arg.strip().split(' ')[-1]. + lstrip('*') if '*' in arg else arg.strip(). + split(' ')[-1] for arg in arguments if arg.strip()] # Create documentation documentation = [] From 95234a422ce5970fb58afb8098b30a7c5df2d308 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 13:52:14 +0000 Subject: [PATCH 042/103] Refactor error message extraction in extract_functions_with_no_description() This commit refactors the error message extraction in the `extract_functions_with_no_description()` function in `extract_line.py`. The code now checks if the error description contains 'msg' instead of 'no description found for function'. Additionally, the code has been adjusted to correctly retrieve the word after the error message. --- bettyfixer/extract_line.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 90558f1..7d7c3ea 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -517,9 +517,10 @@ def extract_functions_with_no_description(file_path): file_path = 'errors.txt' with open(file_path, 'r', encoding='utf-8') as errors_file: for line in errors_file: - # Check if the error description contains 'no description found for function' + # Check if the error description contains msg if 'no description found for function' in line: - # Split the line by space and get the word after 'no description found for function' + # Split the line by space and get the word after + # 'no description found for function' words = line.split() # Adjust index based on the specific position of the function name index = words.index('no') + 5 From 7712e0ff2419b4db5f3a451e75598adf9abe9a59 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 4 Feb 2024 14:26:25 +0000 Subject: [PATCH 043/103] Refactor code for improved performance and readability --- bettyfixer/extract_line.py | 125 +++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 7d7c3ea..17bd6ba 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -132,16 +132,16 @@ def fix_errors_from_file(file_path, line_number, error_description): for i, message in enumerate(error_messages): if message in error_description: if i == 0: - fix_space_prohibited_between_func_name_and_open_parenthesis( + fix_space_between_func_name_open_parenthesis( file_path, line_number, error_description) elif i == 1: - fix_space_prohibited_after_that_open_parenthesis( + fix_space_after_that_open_parenthesis( file_path, line_number, error_description) elif i == 2: - fix_space_prohibited_before_that_close_parenthesis( + fix_space_before_that_close_parenthesis( file_path, line_number, error_description) elif i == 3: - fix_space_required_before_the_open_parenthesis( + fix_space_required_before_open_parenthesis( file_path, line_number, error_description) elif i == 4: fix_space_prohibited_before_semicolon( @@ -395,10 +395,10 @@ def remove_unused_attribute(file_name, function_name): # Extract and remove __attribute__((unused)) match = re.search( - r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[fn_st_line]) + r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[fn_st_line]) unused_attribute = match.group(1) if match else None lines[fn_st_line] = re.sub( - r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[fn_st_line]) + r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[fn_st_line]) # Call the existing function to generate documentation generate_documentation(lines, fn_st_line, function_name) @@ -522,7 +522,7 @@ def extract_functions_with_no_description(file_path): # Split the line by space and get the word after # 'no description found for function' words = line.split() - # Adjust index based on the specific position of the function name + # Adjust idx based on specific position of the function name index = words.index('no') + 5 function_name = words[index] @@ -532,121 +532,122 @@ def extract_functions_with_no_description(file_path): return functions -def fix_space_prohibited_between_func_name_and_open_parenthesis(file_path, line_number, error_description): +def fix_space_between_func_name_open_parenthesis(file_path, ln_num, err_desc): """ - Fix space prohibited between function name and open parenthesis in the specified file. + Fix space prohibited between function name and + open parenthesis in the specified file. Args: file_path (str): The path of the file to fix the specified line in. - line_number (str): The line number to fix. - error_description (str): The description of the error. + ln_num (str): The line number to fix. + err_desc (str): The description of the error. """ - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + # Extract specifier from err_desc + specifier_index = err_desc.find("'") + 1 + specifier = err_desc[specifier_index:-1] # Read the file content with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error - error_line = lines[int(line_number) - 1] + error_line = lines[int(ln_num) - 1] # Find the specifier in the line and fix it fixed_line = error_line.replace(f' {specifier}', specifier) # Replace the line in the file - lines[int(line_number) - 1] = fixed_line + lines[int(ln_num) - 1] = fixed_line # Write the modified content back to the file with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) -def fix_space_prohibited_after_that_open_parenthesis(file_path, line_number, error_description): +def fix_space_after_that_open_parenthesis(file_path, ln_num, err_desc): """ - Fix the specified line in the file. + Fix space prohibited after that open parenthesis in the specified file. Args: file_path (str): The path of the file to fix the specified line in. - line_number (str): The line number to fix. - error_description (str): The description of the error. + ln_num (str): The line number to fix. + err_desc (str): The description of the error. """ - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + # Extract specifier from err_desc + specifier_index = err_desc.find("'") + 1 + specifier = err_desc[specifier_index:-1] # Read the file content with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error - error_line = lines[int(line_number) - 1] + error_line = lines[int(ln_num) - 1] # Find the specifier in the line and fix it fixed_line = error_line.replace(f'{specifier} ', specifier) # Replace the line in the file - lines[int(line_number) - 1] = fixed_line + lines[int(ln_num) - 1] = fixed_line # Write the modified content back to the file with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) -def fix_space_prohibited_before_that_close_parenthesis(file_path, line_number, error_description): +def fix_space_before_that_close_parenthesis(file_path, ln_num, err_desc): """ - Fix the specified line in the file. + Fix space prohibited before that close parenthesis in the specified file. Args: file_path (str): The path of the file to fix the specified line in. - line_number (str): The line number to fix. - error_description (str): The description of the error. + ln_num (str): The line number to fix. + err_desc (str): The description of the error. """ - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + # Extract specifier from err_desc + specifier_index = err_desc.find("'") + 1 + specifier = err_desc[specifier_index:-1] # Read the file content with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error - error_line = lines[int(line_number) - 1] + error_line = lines[int(ln_num) - 1] error_line = clean_up_line(error_line) # Find the specifier in the line and fix it fixed_line = error_line.replace(f' {specifier}', specifier) # Replace the line in the file - lines[int(line_number) - 1] = fixed_line + lines[int(ln_num) - 1] = fixed_line # Write the modified content back to the file with open(file_path, 'w', encoding='utf-8') as file: file.writelines(lines) -def fix_space_required_before_the_open_parenthesis(file_path, line_number, error_description): +def fix_space_required_before_open_parenthesis(file_path, ln_num, err_desc): """ - Fix the specified line in the file. + Fix space required before the open parenthesis in the specified file. Args: file_path (str): The path of the file to fix the specified line in. - line_number (str): The line number to fix. - error_description (str): The description of the error. + ln_num (str): The line number to fix. + err_desc (str): The description of the error. """ - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + # Extract specifier from err_desc + specifier_index = err_desc.find("'") + 1 + specifier = err_desc[specifier_index:-1] # Read the file content with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Find the line with the error - error_line = lines[int(line_number) - 1] + error_line = lines[int(ln_num) - 1] error_line = clean_up_line(error_line) # Find the specifier in the line and fix it fixed_line = error_line.replace(specifier, f' {specifier}') # Replace the line in the file - lines[int(line_number) - 1] = fixed_line + lines[int(ln_num) - 1] = fixed_line # Write the modified content back to the file with open(file_path, 'w', encoding='utf-8') as file: @@ -662,66 +663,66 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): errors_fixed = True # Set to True initially to enter the loop while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration + errors_fixed = False # Reset flag at the beginning of each iteration with open(errors_file_path, 'r', encoding='utf-8') as errors_file: - # Read all lines at once to allow modification of the list while iterating + # Read all lines at once to allow modification list while iterating error_lines = errors_file.readlines() - for i, error_line in enumerate(error_lines): - if 'that open brace { should be on the next line' in error_line: + for i, err_line in enumerate(error_lines): + if 'that open brace { should be on the next line' in err_line: # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) + variables = extract_and_print_variables(err_line) if len(variables) >= 2: # Take the first two values - file_path, line_number = variables[:2] + f_path, ln_num = variables[:2] # Fix missing blank line after declaration - if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): + if fix_brace_on_next_line(f_path, ln_num, 'errors.txt'): errors_fixed = True # Set the flag if a line is fixed # Add a message in the error line error_lines[i] += " (brace moved to the next line)" - elif 'following function declarations go on the next line' in error_line: - # Extract (file_path, line_number) from the error line - variables = extract_and_print_variables(error_line) + elif 'following function declarations go on the next line' in err_line: + # Extract (f_path, ln_num) from the error line + variables = extract_and_print_variables(err_line) if len(variables) >= 2: # Take the first two values - file_path, line_number = variables[:2] + f_path, ln_num = variables[:2] # Fix missing blank line after declaration - if fix_brace_on_the_next_line(file_path, line_number, 'errors.txt'): + if fix_brace_on_next_line(f_path, ln_num, 'errors.txt'): errors_fixed = True # Set the flag if a line is fixed # Add a message in the error line error_lines[i] += " (brace moved to the next line)" -def fix_brace_on_the_next_line(file_path, line_number, errors_file_path): +def fix_brace_on_next_line(file_path, ln_num, errors_file_path): """ Fix the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. - line_number (str): The line number to fix. + ln_num (str): The line number to fix. errors_file_path (str): The path of the errors.txt file. Returns: bool: True if the line is fixed, False otherwise. """ - # Convert line_number to integer - line_number = int(line_number) + # Convert ln_num to integer + ln_num = int(ln_num) # Read the content of the file with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() # Check if the specified line is within the file's range - if 1 <= line_number <= len(lines): + if 1 <= ln_num <= len(lines): # Find the brace '{' in the line - line = lines[line_number - 1] + line = lines[ln_num - 1] # Replace '{' with '\n{' to move it to the next line - lines[line_number - 1] = line.replace('{', '\n{') + lines[ln_num - 1] = line.replace('{', '\n{') # Write the modified content back to the file with open(file_path, 'w', encoding='utf-8') as file: From 402bedc907f13947ee4bd380196a07e04a5ffa7c Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 06:08:10 +0000 Subject: [PATCH 044/103] Refactor delete_files and autoproto functions --- bettyfixer/autoprototype.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bettyfixer/autoprototype.py b/bettyfixer/autoprototype.py index a9a67c8..246931d 100644 --- a/bettyfixer/autoprototype.py +++ b/bettyfixer/autoprototype.py @@ -133,7 +133,7 @@ def delete_files(tags, temp_tags): tags (str): Tags file name. temp_tags (str): Temp tags file name. """ - command = "rm {0} {1}".format(tags, temp_tags) + command = f"rm {tags} {temp_tags}" subprocess.run(command, shell=True, check=True) @@ -162,9 +162,9 @@ def autoproto(directory, header): """ check1, msg1 = check_header_file(header) check2, msg2 = check_ctags() - if (not check1): + if not check1: print_ctags_header_error(msg1) - elif (not check2): + elif not check2: print_ctags_header_error(msg2) if generate_tags(directory) is not False: filtered_tags = filter_tags(directory, 'tags') From b24612de3e5b337e38b7f47cb769909efcabbc69 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 06:08:14 +0000 Subject: [PATCH 045/103] Fix function counter bug in betty_fixer.py --- bettyfixer/betty_fixer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 8dd0296..478fb78 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -278,7 +278,7 @@ def more_than_5_functions_in_the_file(errors_file_path): counter += 1 if counter == 6: - # Create a new file with the content + # Create a new file with the content # from the specified line to the end of the file copy_remaining_lines( lines, block_start_line, new_file_path) From 57339dfeaf293120e90d7cd7a809a238ea35ebf3 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 06:08:19 +0000 Subject: [PATCH 046/103] Fix unused variable issue in extract_line.py and fix space required after the close brace in fix_space_required_after_the_close_brace function --- bettyfixer/extract_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 17bd6ba..c8b20a6 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -391,7 +391,7 @@ def remove_unused_attribute(file_name, function_name): else: pass # took a copy from the original function declaration - original_declaration = lines[fn_st_line] # ❗ Unused variable + original_declaration = lines[fn_st_line] # ❗ Unused variable [Younis] # Extract and remove __attribute__((unused)) match = re.search( @@ -1285,7 +1285,7 @@ def fix_space_required_after_the_close_brace(file_path, line_number, error_descr error_line = clean_up_line(error_line) # Find the specifier in the line and fix it fixed_line = error_line.replace( - specifier, f'{specifier} ') # ❗ Unused variable + specifier, f'{specifier} ') # ❗ Unused variable [Younis] # Replace the line in the file with open(file_path, 'w', encoding='utf-8') as file: From 37ca9a2054051d1f411dcc29a7251bac8116425c Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 07:30:46 +0000 Subject: [PATCH 047/103] Add Betty Fixer functionality and improve error handling --- bettyfixer/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bettyfixer/__init__.py b/bettyfixer/__init__.py index 51c9398..121bbec 100644 --- a/bettyfixer/__init__.py +++ b/bettyfixer/__init__.py @@ -1,2 +1,6 @@ +""" +This module provides the Betty Fixer functionality. +""" + from .betty_fixer import * # modify_main_files(sys.argv[1:]) From 5d8122e456138a3de9a2211650ca3c22463b6abe Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 07:30:52 +0000 Subject: [PATCH 048/103] Refactor tag filtering in autoprototype.py --- bettyfixer/autoprototype.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bettyfixer/autoprototype.py b/bettyfixer/autoprototype.py index 246931d..0975308 100644 --- a/bettyfixer/autoprototype.py +++ b/bettyfixer/autoprototype.py @@ -91,8 +91,11 @@ def filter_tags(directory, tags_file): temp_tags_path = os.path.join(directory, 'temp_tags') tags_path = os.path.join(directory, tags_file) - sed_command = r"cat {0} | sed -n 's/^.*\/^\(.*\)/\1/p' | sed 's/\(.*\)\$.*/\1/' | sed 's/;$//' | uniq | sed '/int main(/d' | sed '/.*:/d' | sed 's/$/;/g' > {1}".format( - tags_path, temp_tags_path) + sed_command = ( + f"cat {tags_path} | sed -n 's/^.*\\/\\(.*\\)/\\1/p' | " + f"sed 's/\\(.*\\)\\$.*/\\1/' | sed 's/;$//' | uniq | " + f"sed '/int main(/d' | sed '/.*:/d' | sed 's/$/;/g' > {temp_tags_path}" + ) # Run the sed_command using subprocess subprocess.run(sed_command, shell=True, check=True) From 2dce37992433d43770dc164f04d8fcfc5f9154e7 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 07:30:58 +0000 Subject: [PATCH 049/103] Add specific error handling in create_backup function --- bettyfixer/backup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bettyfixer/backup.py b/bettyfixer/backup.py index 76f627f..bb28974 100644 --- a/bettyfixer/backup.py +++ b/bettyfixer/backup.py @@ -15,5 +15,11 @@ def create_backup(file_path): shutil.copy2(file_path, backup_path) except FileNotFoundError: print(f"Error creating backup for {file_path}: File not found.") - except Exception as e: + except shutil.SameFileError: + print(f"Error creating backup for {file_path}: Same file error.") + except IsADirectoryError: + print(f"Error creating backup for {file_path}: Is a directory error.") + except PermissionError: + print(f"Error creating backup for {file_path}: Permission error.") + except OSError as e: print(f"Unexpected error in create_backup for {file_path}: {e}") From 592b4a44e0b828d98cb70e69d6d76388cecb5912 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 07:31:04 +0000 Subject: [PATCH 050/103] Fix error handling in errors_extractor.py --- bettyfixer/errors_extractor.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bettyfixer/errors_extractor.py b/bettyfixer/errors_extractor.py index 4b33e15..a7fa82c 100644 --- a/bettyfixer/errors_extractor.py +++ b/bettyfixer/errors_extractor.py @@ -25,7 +25,7 @@ def exctract_errors(file_path, output_file): errors_file_path.write(output) except subprocess.CalledProcessError as e: # Handle the case when Betty returns a non-zero exit code - pass + pass # ❗ # Append the error output to the common errors.txt file with open(output_file, 'a', encoding='utf-8') as errors_file_path: errors_file_path.write(e.stdout) @@ -39,11 +39,11 @@ def exctract_errors(file_path, output_file): sys.exit(1) # Specify the common errors.txt file in the current directory - errors_file_path = 'errors.txt' + ERROR_FILE_PATH = 'errors.txt' # Clear the content of the errors.txt file before appending new errors - open(errors_file_path, 'w', encoding='utf-8').close() + open(ERROR_FILE_PATH, 'w', encoding='utf-8').close() # Iterate over each file provided as a command-line argument - for file_path in sys.argv[1:]: - exctract_errors(file_path, errors_file_path) + for FILE_PATH in sys.argv[1:]: + exctract_errors(FILE_PATH, ERROR_FILE_PATH) From 2f3aada79ebe2a51d05d956e9c4d30022631438b Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Mon, 5 Feb 2024 07:31:10 +0000 Subject: [PATCH 051/103] Refactor line extraction logic in extract_line.py --- bettyfixer/extract_line.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index c8b20a6..452c540 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -431,18 +431,18 @@ def fix_lines_in_file(file_name, function_declarations): lines = file.readlines() # Iterate through each line in file - for i, line in enumerate(lines): - if '*/' in line and 'unused' in line: - # Check if any function_name is found in this line - for func_name, original_line in function_declarations.items(): - if func_name in line: - # Replace the line with the desired format - lines[i] = f' */\n{original_line}' - - # Check if the next line is a blank; if so, delete it - if i + 1 < len(lines) and lines[i + 1] == '\n': - del lines[i + 1] - break + for i, line in enumerate(lines): + if '*/' in line and 'unused' in line: + # Check if any function_name is found in this line + for func_name, original_line in function_declarations.items(): + if func_name in line: + # Replace the line with the desired format + lines[i] = f' */\n{original_line}' + + # Check if the next line is a blank; if so, delete it + if i + 1 < len(lines) and lines[i + 1] == '\n': + del lines[i + 1] + break # Write back to the file with open(file_name, 'w', encoding='utf-8') as file: From 61b73391ed6b581becc0eac75df6815e5054b6ee Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:18:38 +0300 Subject: [PATCH 052/103] Refactor process_errors function --- bettyfixer/betty_fixer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 478fb78..8347e50 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -126,7 +126,8 @@ def remove_trailing_whitespaces(content): return re.sub(r'[ \t]+$', '', content, flags=re.MULTILINE) -def process_errors(file_path): # ❗ This function doesn't make sense to me [Younis] +# ❗ This function doesn't make sense to me [Younis] +def process_errors(file_path): """ Process the errors for the specified file. Args: From 33c64fed1cdbc976c6efa0913545d1f3a1e64a98 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:27:56 +0300 Subject: [PATCH 053/103] Fix variable name in process_errors function --- bettyfixer/betty_fixer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 8347e50..4f431d7 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -134,8 +134,8 @@ def process_errors(file_path): file_path (str): The path of the file to process the errors for. """ # Process the errors for the specified file - errors_file_path = 'errors.txt' - process_error_file(errors_file_path) + file_path = 'errors.txt' + process_error_file(file_path) def fix_betty_warnings(content, file_path): From 5f3ac3f3aad85fd8f36bf5f5d71caab8e672634f Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:39:58 +0300 Subject: [PATCH 054/103] Refactor code formatting and fix comments*** --- bettyfixer/betty_fixer.py | 57 ++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 4f431d7..dc65200 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -72,7 +72,8 @@ def remove_consecutive_blank_lines(content): """ Remove multiple consecutive blank lines from the specified content. Args: - content (str): The content to remove multiple consecutive blank lines from. + content (str): + The content to remove multiple consecutive blank lines from. Returns: str: The content with multiple consecutive blank lines removed. """ @@ -91,7 +92,8 @@ def add_parentheses_around_return(content): # Add parentheses around return values if not already present content = re.sub(r'return[ ]+([^(][^;]+);', r'return (\1);', content) - # Add parentheses around return values if no value is present and not already in parentheses + # Add parentheses around return values if no value + # is present and not already in parentheses content = re.sub(r'return[ ]+([^;()]+);', r'return (\1);', content) # Check if space after semicolon before closing brace '}' is needed @@ -110,8 +112,9 @@ def fix_comments(content): Returns: str: The content with comments fixed. """ - # Remove single-line comments (//) found alone in a line or after a code line - return re.sub(r'([^;])\s*//.*|^\s*//.*', r'\1', content, flags=re.MULTILINE) + # Remove single-line comments (//) found alone in line or after a code line + return re.sub( + r'([^;])\s*//.*|^\s*//.*', r'\1', content, flags=re.MULTILINE) def remove_trailing_whitespaces(content): @@ -162,7 +165,8 @@ def remove_blank_lines_inside_comments(file_path): """ Remove blank lines inside comments in the specified file. Args: - file_path (str): The path of the file to remove blank lines inside comments from. + file_path (str): + The path of the file to remove blank lines inside comments from. """ clean_errors_file('errors.txt') # Read the content of the file @@ -175,7 +179,7 @@ def remove_blank_lines_inside_comments(file_path): # Find the next line starting with ' */' (declaration ending) for j in range(i + 1, len(lines)): if lines[j].strip().startswith('*/'): - # Remove any blank lines between declaration beginning and ending + # Remove any blank line <- declaration beginning and ending for k in range(i + 1, j): if lines[k].strip() == '': del lines[k] @@ -242,16 +246,18 @@ def more_than_5_functions_in_the_file(errors_file_path): """ Fix the error 'More than 5 functions in the file' in the specified file. Args: - errors_file_path (str): The path of the errors file to fix the error in. + errors_file_path (str): + The path of the errors file to fix the error in. """ # Set to True initially to enter the loop errors_fixed = True while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration + errors_fixed = False # Reset flag at the beginning of each iteration with open(errors_file_path, 'r', encoding='utf-8') as errors_file: - # Read all lines at once to allow modification of the list while iterating + # Read all lines at once to allow + # modification of the list while iterating error_lines = errors_file.readlines() for error_line in error_lines: @@ -259,42 +265,48 @@ def more_than_5_functions_in_the_file(errors_file_path): variables = extract_and_print_variables(error_line) if len(variables) >= 2: file_path, _ = variables[:2] - line_number = 1 # Assuming you want to start from the first line + line_number = 1 # Assume to start from the first line with open(file_path, 'r', encoding='utf-8') as file: lines = file.readlines() - # Find the next available file name (file1.c, file2.c, etc.) + # Find the next avail file name (file1.c, file2.c, ..) new_file_path = find_available_file_name(file_path) # Count the /** ... */ blocks counter = 0 - inside_block = False + in_block = False block_start_line = 0 for idx, line in enumerate(lines): if line.strip().startswith('/**'): - inside_block = True + in_block = True block_start_line = idx - elif inside_block and line.strip().startswith('*/'): - inside_block = False + elif in_block and line.strip().startswith('*/'): + in_block = False counter += 1 if counter == 6: # Create a new file with the content - # from the specified line to the end of the file + # from the specified line to end of the file copy_remaining_lines( lines, block_start_line, new_file_path) # Remove the content from the main file del lines[block_start_line:] - # Write the modified content back to the main file - with open(file_path, 'w', encoding='utf-8') as main_file: + # Write the modified content back to main file + with open( + file_path, + 'w', + encoding='utf-8' + ) as main_file: main_file.write(''.join(lines)) - # Clean 'errors.txt' before extracting new errors + # Clean 'errors.txt' before + # extracting new errors open(errors_file_path, 'w', encoding='utf-8').close() # Update Betty errors in errors.txt exctract_errors( new_file_path, errors_file_path) - errors_fixed = True # Set the flag if a line is fixed + # Set the flag if line is fixed + errors_fixed = True break line_number += 1 @@ -304,8 +316,9 @@ def find_available_file_name(original_file_path): """ Find the next available file name based on the specified file path. Args: - original_file_path (str): - The path of the original file to find the next available file name for. + original_file_path (str): + The path of the original file to find + the next available file name for. Returns: str: The next available file name based on the original file path. """ From 77b5a1ce3ae19ce61a6a958b09d21e6d7b568068 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:40:32 +0300 Subject: [PATCH 055/103] Refactor file name generation for sequential numbering --- bettyfixer/betty_fixer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index dc65200..ccaee9a 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -326,7 +326,8 @@ def find_available_file_name(original_file_path): counter = 1 while True: - # Remove :01d from the format to allow for sequential numbering without leading zeros + # Remove :01d from the format to allow for sequential + # numbering without leading zeros new_file_path = f'{base_name}{counter}{extension}' if not os.path.exists(new_file_path): return new_file_path From a5da35f894ff31243bada2392cb6344ffdadafa9 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:44:13 +0300 Subject: [PATCH 056/103] Refactor code formatting and file handling*** --- bettyfixer/betty_fixer.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index ccaee9a..0dfcd92 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -342,7 +342,7 @@ def copy_remaining_lines(lines, start_line, new_file_path): start_line (int): The line number to start copying from. new_file_path (str): The path of the new file to copy the lines to. """ - # Create a new file with the content from the specified line to the end of the file + # Create a new file with content from the specified line to the end of file with open(new_file_path, 'w', encoding='utf-8') as new_file: new_file.write(''.join(lines[start_line:])) @@ -351,10 +351,12 @@ def betty_handler(errors_file_path): """ Handle Betty errors in the specified file. Args: - errors_file_path (str): The path of the errors file to handle Betty errors in. + errors_file_path (str): + The path of the errors file to handle Betty errors in. """ with open(errors_file_path, 'r', encoding='utf-8') as errors_file: - # Read all lines at once to allow modification of the list while iterating + # Read all lines at once to allow modification + # of the list while iterating error_lines = errors_file.readlines() messages = ["More than 40 lines in a function", @@ -420,8 +422,8 @@ def copy_files_to_tasks(files): ).startswith("#include") or not line.strip().endswith('.h"')] # Write the modified content to the destination file - with open(destination_path, 'w', encoding='utf-8') as destination_file: - destination_file.write(''.join(filtered_content)) + with open(destination_path, 'w', encoding='utf-8') as dest_file: + dest_file.write(''.join(filtered_content)) def modify_main_files(files): @@ -440,10 +442,12 @@ def modify_main_files(files): include_lines = [line.strip() for line in content if line.strip( ).startswith("#include") and line.strip().endswith('.h"')] - # Write the modified content to the main file, adding an empty line at the end + # Write the modified content to the main file, + # adding an empty line at the end with open(file_path, 'w', encoding='utf-8') as main_file: main_file.write('\n'.join( - include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) + include_lines + [ + f'#include "tasks/{os.path.basename(file_path)}"\n'])) def record_processed_file(filename): @@ -481,7 +485,9 @@ def main(): sys.exit(1) if len(sys.argv) < 2: - print("Usage: python -m betty_fixer_package.betty_fixer file1.c file2.c ...") + print( + "Usage: python -m betty_fixer_package.betty_fixer\ + file1.c file2.c ...") sys.exit(1) if "-H" in sys.argv and len(sys.argv) > 2: From 8fa5728b719ea17f3b338b47e606a6f78366bafd Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:14:20 +0300 Subject: [PATCH 057/103] Fix unused variable and exception handling in extract_line.py --- bettyfixer/extract_line.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index c8b20a6..ce4d39f 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -391,14 +391,16 @@ def remove_unused_attribute(file_name, function_name): else: pass # took a copy from the original function declaration - original_declaration = lines[fn_st_line] # ❗ Unused variable [Younis] + # original_declaration = lines[fn_st_line]# ❗ Unused variable [Younis] # Extract and remove __attribute__((unused)) match = re.search( r'(__attribute__\s*\(\s*\(\s*unused\s*\)\s*\))', lines[fn_st_line]) unused_attribute = match.group(1) if match else None lines[fn_st_line] = re.sub( - r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', '', lines[fn_st_line]) + r'__attribute__\s*\(\s*\(\s*unused\s*\)\s*\)', + '', + lines[fn_st_line]) # Call the existing function to generate documentation generate_documentation(lines, fn_st_line, function_name) @@ -414,8 +416,14 @@ def remove_unused_attribute(file_name, function_name): file.writelines(lines) fix_lines_in_file(file_name, function_declarations) - except Exception as e: - print(f"Error: {e}") + except ValueError as e: + print(f"ValueError: {e}") + except FileNotFoundError as e: + print(f"FileNotFoundError: {e}") + except PermissionError as e: + print(f"PermissionError: {e}") + except OSError as e: + print(f"OSError: {e}") def fix_lines_in_file(file_name, function_declarations): @@ -447,8 +455,14 @@ def fix_lines_in_file(file_name, function_declarations): # Write back to the file with open(file_name, 'w', encoding='utf-8') as file: file.writelines(lines) - except Exception as e: - print(f"Error: {e}") + except ValueError as e: + print(f"ValueError: {e}") + except FileNotFoundError as e: + print(f"FileNotFoundError: {e}") + except PermissionError as e: + print(f"PermissionError: {e}") + except OSError as e: + print(f"OSError: {e}") def generate_documentation(lines, fn_start_ln, function_name): @@ -678,8 +692,8 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): f_path, ln_num = variables[:2] # Fix missing blank line after declaration - if fix_brace_on_next_line(f_path, ln_num, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed + if fix_brace_next_line(f_path, ln_num, 'errors.txt'): + errors_fixed = True # Set flag if a line is fixed # Add a message in the error line error_lines[i] += " (brace moved to the next line)" @@ -692,14 +706,14 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): f_path, ln_num = variables[:2] # Fix missing blank line after declaration - if fix_brace_on_next_line(f_path, ln_num, 'errors.txt'): + if fix_brace_next_line(f_path, ln_num, 'errors.txt'): errors_fixed = True # Set the flag if a line is fixed # Add a message in the error line error_lines[i] += " (brace moved to the next line)" -def fix_brace_on_next_line(file_path, ln_num, errors_file_path): +def fix_brace_next_line(file_path, ln_num, errors_file_path): """ Fix the specified line in the file. Args: @@ -1284,7 +1298,7 @@ def fix_space_required_after_the_close_brace(file_path, line_number, error_descr error_line = lines[int(line_number) - 1] error_line = clean_up_line(error_line) # Find the specifier in the line and fix it - fixed_line = error_line.replace( + error_line.replace( specifier, f'{specifier} ') # ❗ Unused variable [Younis] # Replace the line in the file From adb384c23cc9491bd27e5d7caa18d779ab0a971e Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:34:10 +0300 Subject: [PATCH 058/103] Refactor code for improved performance and readability --- bettyfixer/extract_line.py | 106 +++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 47 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index ce4d39f..95c9a7f 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -698,7 +698,8 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): # Add a message in the error line error_lines[i] += " (brace moved to the next line)" - elif 'following function declarations go on the next line' in err_line: + elif ('following function declarations go on ' + 'the next line') in err_line: # Extract (f_path, ln_num) from the error line variables = extract_and_print_variables(err_line) if len(variables) >= 2: @@ -707,7 +708,7 @@ def fix_brace_should_be_on_the_next_line(errors_file_path): # Fix missing blank line after declaration if fix_brace_next_line(f_path, ln_num, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed + errors_fixed = True # Set flag if a line is fixed # Add a message in the error line error_lines[i] += " (brace moved to the next line)" @@ -790,14 +791,15 @@ def fix_brace_should_be_on_the_previous_line(errors_file_path): errors_fixed = True # Set to True initially to enter the loop while errors_fixed: - errors_fixed = False # Reset the flag at the beginning of each iteration + errors_fixed = False # Reset flag at the beginning of each iteration with open(errors_file_path, 'r', encoding='utf-8') as errors_file: - # Read all lines at once to allow modification of the list while iterating + # Read all lines at once allow modification of list while iterating error_lines = errors_file.readlines() for error_line in error_lines: - if 'that open brace { should be on the previous line' in error_line: + if ('that open brace { ' + 'should be on the previous line') in error_line: # Extract (file_path, line_number) from the error line variables = extract_and_print_variables(error_line) if len(variables) >= 2: @@ -805,8 +807,12 @@ def fix_brace_should_be_on_the_previous_line(errors_file_path): file_path, line_number = variables[:2] # Fix missing blank line after declaration - if fix_brace_on_the_previous_line(file_path, line_number, 'errors.txt'): - errors_fixed = True # Set the flag if a line is fixed + if fix_brace_on_the_previous_line( + file_path, + line_number, + 'errors.txt' + ): + errors_fixed = True # Set flag if a line is fixed def fix_brace_on_the_previous_line(file_path, line_number, errors_file_path): @@ -840,8 +846,9 @@ def fix_brace_on_the_previous_line(file_path, line_number, errors_file_path): # Delete the previous '\n' character to move the brace to the previous line if lines[line_number - 1].endswith('\n'): - lines[line_number - 1] = lines[line_number - 1].rstrip() + ' ' if not lines[line_number - - 1].endswith(' ') else lines[line_number - 1].rstrip() + lines[line_number - 1] = lines[line_number - 1]\ + .rstrip() + ' ' if not lines[line_number - 1]\ + .endswith(' ') else lines[line_number - 1].rstrip() # Write the modified content back to the file with open(file_path, 'w', encoding='utf-8') as file: @@ -880,7 +887,7 @@ def fix_space_prohibited_before_semicolon(file_path, line_number, specifier): file.writelines(lines) -def fix_should_be_foo_star_bar(file_path, line_number, error_description): # done +def fix_should_be_foo_star_bar(file_path, line_number, error_description): """ Fix the specified line in the file. Args: @@ -919,33 +926,33 @@ def fix_should_be_foo_star_bar(file_path, line_number, error_description): # do file.writelines(lines) -def fix_spaces_prohibited_around_that(file_path, line_number, error_description): +def fix_spaces_prohibited_around_that(file_path, line_number, err_desc): """ Fix the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. - error_description (str): The description of the error. + err_desc (str): The description of the error. """ - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") + # Find the specifier between two single quotes in the err_desc + specifier_start = err_desc.find("'") + 1 + specifier_end = err_desc.rfind("'") if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return - specifier = error_description[specifier_start:specifier_end] + specifier = err_desc[specifier_start:specifier_end] - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') + # Extract context from the end of err_desc (ctx:context) between : and ) + context_start = err_desc.rfind(':') + 1 + context_end = err_desc.rfind(')') if context_start < 0 or context_end < 0: # Unable to find valid context, return without making changes return - context = error_description[context_start:context_end].strip() + context = err_desc[context_start:context_end].strip() # Read the file content with open(file_path, 'r', encoding='utf-8') as file: @@ -967,7 +974,8 @@ def fix_spaces_prohibited_around_that(file_path, line_number, error_description) elif context == 'VxW': fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') else: - # If the context doesn't match known conditions, return without making changes + # If the context doesn't match known conditions + # return without making changes return # Replace the line in the file @@ -996,7 +1004,8 @@ def fix_space_prohibited_after_that(file_path, line_number, error_description): specifier = error_description[specifier_start:specifier_end] - # Extract context from the end of error_description (ctx:context) between : and ) + # Extract context from the end of error_description + # (ctx:context) between : and ) context_start = error_description.rfind(':') + 1 context_end = error_description.rfind(')') @@ -1019,7 +1028,8 @@ def fix_space_prohibited_after_that(file_path, line_number, error_description): elif context == 'ExW': fixed_line = error_line.replace(f'{specifier} ', f'{specifier}') else: - # If the context doesn't match known conditions, return without making changes + # If the context doesn't match known conditions, + # return without making changes return # Replace the line in the file @@ -1030,33 +1040,33 @@ def fix_space_prohibited_after_that(file_path, line_number, error_description): file.writelines(lines) -def fix_space_prohibited_before_that(file_path, line_number, error_description): +def fix_space_prohibited_before_that(file_path, line_number, err_desc): """ Fix the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. - error_description (str): The description of the error. + err_desc (str): The description of the error. """ - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") + # Find the specifier between two single quotes in the err_desc + specifier_start = err_desc.find("'") + 1 + specifier_end = err_desc.rfind("'") if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return - specifier = error_description[specifier_start:specifier_end] + specifier = err_desc[specifier_start:specifier_end] - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') + # Extract context from the end of err_desc (ctx:context) between : and ) + context_start = err_desc.rfind(':') + 1 + context_end = err_desc.rfind(')') if context_start < 0 or context_end < 0: # Unable to find valid context, return without making changes return - context = error_description[context_start:context_end].strip() + context = err_desc[context_start:context_end].strip() # Read the file content with open(file_path, 'r', encoding='utf-8') as file: @@ -1066,10 +1076,11 @@ def fix_space_prohibited_before_that(file_path, line_number, error_description): error_line = lines[int(line_number) - 1] # Fix line according to the context conditions - if context == 'WxV' or context == 'WxO' or context == 'WxE' or context == 'WxW': + if context in ['WxV', 'WxO', 'WxE', 'WxW']: fixed_line = error_line.replace(f' {specifier}', f'{specifier}') else: - # If the context doesn't match known conditions, return without making changes + # If the context doesn't match known conditions, + # return without making changes return # Replace the line in the file @@ -1080,33 +1091,33 @@ def fix_space_prohibited_before_that(file_path, line_number, error_description): file.writelines(lines) -def fix_spaces_preferred_around_that(file_path, line_number, error_description): +def fix_spaces_preferred_around_that(file_path, line_number, err_desc): """ Fix the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. - error_description (str): The description of the error. + err_desc (str): The description of the error. """ - # Find the specifier between two single quotes in the error_description - specifier_start = error_description.find("'") + 1 - specifier_end = error_description.rfind("'") + # Find the specifier between two single quotes in the err_desc + specifier_start = err_desc.find("'") + 1 + specifier_end = err_desc.rfind("'") if specifier_start < 0 or specifier_end < 0: # Unable to find valid specifier, return without making changes return - specifier = error_description[specifier_start:specifier_end] + specifier = err_desc[specifier_start:specifier_end] - # Extract context from the end of error_description (ctx:context) between : and ) - context_start = error_description.rfind(':') + 1 - context_end = error_description.rfind(')') + # Extract context from the end of err_desc (ctx:context) between : and ) + context_start = err_desc.rfind(':') + 1 + context_end = err_desc.rfind(')') if context_start < 0 or context_end < 0: # Unable to find valid context, return without making changes return - context = error_description[context_start:context_end].strip() + context = err_desc[context_start:context_end].strip() # Read the file content with open(file_path, 'r', encoding='utf-8') as file: @@ -1128,7 +1139,8 @@ def fix_spaces_preferred_around_that(file_path, line_number, error_description): elif context == 'VxW': fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') else: - # If the context doesn't match known conditions, return without making changes + # If the context doesn't match known conditions, + # return without making changes return # Replace the line in the file @@ -1139,7 +1151,7 @@ def fix_spaces_preferred_around_that(file_path, line_number, error_description): file.writelines(lines) -def fix_space_required_around_that(file_path, line_number, error_description): # done +def fix_space_required_around_that(file_path, line_number, error_description): """ Fix the specified line in the file. Args: From bedfeb0f4d5923e3b24b21b120472093ac1dc410 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:34:46 +0300 Subject: [PATCH 059/103] Refactor context extraction in extract_line.py --- bettyfixer/extract_line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 95c9a7f..d7c7729 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -1169,7 +1169,8 @@ def fix_space_required_around_that(file_path, line_number, error_description): specifier = error_description[specifier_start:specifier_end] - # Extract context from the end of error_description (ctx:context) between : and ) + # Extract context from the end of + # error_description (ctx:context) between : and ) context_start = error_description.rfind(':') + 1 context_end = error_description.rfind(')') From 52eb3d701cf11f9ce0540798afbbf9dadcca74d5 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:36:15 +0300 Subject: [PATCH 060/103] Refactor code for better readability and maintainability --- bettyfixer/extract_line.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index d7c7729..54c2333 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -1200,7 +1200,8 @@ def fix_space_required_around_that(file_path, line_number, error_description): elif context == 'VxW': fixed_line = error_line.replace(f'{specifier} ', f' {specifier} ') else: - # If the context doesn't match known conditions, return without making changes + # If the context doesn't match known conditions, + # return without making changes return # Replace the line in the file @@ -1229,7 +1230,8 @@ def fix_space_required_after_that(file_path, line_number, error_description): specifier = error_description[specifier_start:specifier_end] - # Extract context from the end of error_description (ctx:context) between : and ) + # Extract context from the end of error_description + # (ctx:context) between : and ) context_start = error_description.rfind(':') + 1 context_end = error_description.rfind(')') @@ -1250,7 +1252,8 @@ def fix_space_required_after_that(file_path, line_number, error_description): if context == 'WxV' or context == 'VxV': fixed_line = error_line.replace(f'{specifier}', f'{specifier} ') else: - # If the context doesn't match known conditions, return without making changes + # If the context doesn't match known conditions, + # return without making changes return # Replace the line in the file @@ -1261,17 +1264,17 @@ def fix_space_required_after_that(file_path, line_number, error_description): file.writelines(lines) -def fix_space_required_before_the_open_brace(file_path, line_number, error_description): +def fix_space_required_before_the_open_brace(file_path, line_number, err_desc): """ Fix the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. - error_description (str): The description of the error. + err_desc (str): The description of the error. """ - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + # Extract specifier from err_desc + specifier_index = err_desc.find("'") + 1 + specifier = err_desc[specifier_index:-1] # Read the file content with open(file_path, 'r', encoding='utf-8') as file: From 7de4d2d309fa0832c46896938dc078f61f64cf3a Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:36:58 +0300 Subject: [PATCH 061/103] Refactor error description variable name in extract_line.py --- bettyfixer/extract_line.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 54c2333..db8b2bc 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -1294,17 +1294,17 @@ def fix_space_required_before_the_open_brace(file_path, line_number, err_desc): file.writelines(lines) -def fix_space_required_after_the_close_brace(file_path, line_number, error_description): +def fix_space_required_after_the_close_brace(file_path, line_number, err_desc): """ Fix the specified line in the file. Args: file_path (str): The path of the file to fix the specified line in. line_number (str): The line number to fix. - error_description (str): The description of the error. + err_desc (str): The description of the error. """ - # Extract specifier from error_description - specifier_index = error_description.find("'") + 1 - specifier = error_description[specifier_index:-1] + # Extract specifier from err_desc + specifier_index = err_desc.find("'") + 1 + specifier = err_desc[specifier_index:-1] # Read the file content with open(file_path, 'r', encoding='utf-8') as file: From 675a1464ccb95e5a8e4ab0950941913faf511c87 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:58:25 +0300 Subject: [PATCH 062/103] Add recursive-exclude for errors_logs in MANIFEST.in --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index bb3ec5f..e93123f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ include README.md +recursive-exclude errors_logs * \ No newline at end of file From 6224caa17832d06415181682892a60b4e07b929b Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:58:33 +0300 Subject: [PATCH 063/103] Fix code formatting and documentation issues --- errors_logs/autoprototype.md | 135 +++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 errors_logs/autoprototype.md diff --git a/errors_logs/autoprototype.md b/errors_logs/autoprototype.md new file mode 100644 index 0000000..5ba1980 --- /dev/null +++ b/errors_logs/autoprototype.md @@ -0,0 +1,135 @@ +************* Module bettyfixer.autoprototype +bettyfixer/autoprototype.py:12: [C0301(line-too-long), ] Line too long (124/100) +bettyfixer/autoprototype.py:28: [C0301(line-too-long), ] Line too long (123/100) +bettyfixer/autoprototype.py:36: [C0301(line-too-long), ] Line too long (106/100) +bettyfixer/autoprototype.py:44: [C0301(line-too-long), ] Line too long (143/100) +bettyfixer/autoprototype.py:53: [C0301(line-too-long), ] Line too long (199/100) +bettyfixer/autoprototype.py:54: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:85: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:87: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:90: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:91: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:92: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:92: [C0325(superfluous-parens), ] Unnecessary parens after 'if' keyword +bettyfixer/autoprototype.py:93: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:94: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:94: [C0325(superfluous-parens), ] Unnecessary parens after 'elif' keyword +bettyfixer/autoprototype.py:95: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:96: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:97: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:98: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:98: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:99: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 +bettyfixer/autoprototype.py:100: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 +bettyfixer/autoprototype.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/autoprototype.py:9: [C0116(missing-function-docstring), betty_check] Missing function or method docstring +bettyfixer/autoprototype.py:27: [C0116(missing-function-docstring), print_check_betty_first] Missing function or method docstring +bettyfixer/autoprototype.py:29: [C0116(missing-function-docstring), print_header_name_missing] Missing function or method docstring +bettyfixer/autoprototype.py:31: [C0116(missing-function-docstring), print_Ctags_header_error] Missing function or method docstring +bettyfixer/autoprototype.py:31: [C0103(invalid-name), print_Ctags_header_error] Function name "print_Ctags_header_error" doesn't conform to snake_case naming style +bettyfixer/autoprototype.py:34: [C0116(missing-function-docstring), check_ctags] Missing function or method docstring +bettyfixer/autoprototype.py:42: [C0116(missing-function-docstring), generate_tags] Missing function or method docstring +bettyfixer/autoprototype.py:44: [W1309(f-string-without-interpolation), generate_tags] Using an f-string that does not have any interpolated variables +bettyfixer/autoprototype.py:49: [C0116(missing-function-docstring), filter_tags] Missing function or method docstring +bettyfixer/autoprototype.py:53: [C0209(consider-using-f-string), filter_tags] Formatting a regular string which could be an f-string +bettyfixer/autoprototype.py:59: [R1705(no-else-return), filter_tags] Unnecessary "else" after "return", remove the "else" and de-indent the code inside it +bettyfixer/autoprototype.py:60: [W1514(unspecified-encoding), filter_tags] Using open without explicitly specifying an encoding +bettyfixer/autoprototype.py:69: [C0116(missing-function-docstring), create_header] Missing function or method docstring +bettyfixer/autoprototype.py:73: [W1514(unspecified-encoding), create_header] Using open without explicitly specifying an encoding +bettyfixer/autoprototype.py:78: [C0116(missing-function-docstring), delete_files] Missing function or method docstring +bettyfixer/autoprototype.py:79: [C0209(consider-using-f-string), delete_files] Formatting a regular string which could be an f-string +bettyfixer/autoprototype.py:83: [C0116(missing-function-docstring), check_header_file] Missing function or method docstring +bettyfixer/autoprototype.py:89: [C0116(missing-function-docstring), autoproto] Missing function or method docstring +bettyfixer/autoprototype.py:96: [C0121(singleton-comparison), autoproto] Comparison 'generate_tags(directory) != False' should be 'generate_tags(directory) is not False' if checking for the singleton value False, or 'generate_tags(directory)' if testing for truthiness +bettyfixer/autoprototype.py:98: [C0121(singleton-comparison), autoproto] Comparison 'filtered_tags != None' should be 'filtered_tags is not None' +bettyfixer/autoprototype.py:6: [C0411(wrong-import-order), ] standard import "import glob" should be placed before "from colorama import Fore" +bettyfixer/autoprototype.py:1: [W0611(unused-import), ] Unused import argparse +bettyfixer/autoprototype.py:4: [W0611(unused-import), ] Unused import re + + +## Report +====== +**79 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |11 |NC |NC |0.00 |9.09 | + + + +External dependencies +--------------------- +:: + + colorama (bettyfixer.autoprototype) + + + +102 lines have been analyzed + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |82 |80.39 |NC |NC | +|docstring |0 |0.00 |NC |NC | +|comment |5 |4.90 |NC |NC | +|empty |15 |14.71 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|===========|=======|=========|===========| +|convention |29 |NC |NC | +|refactor |1 |NC |NC | +|warning |16 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +| message id | occurrences | +|--------------------------------|-------------| +| missing-function-docstring | 11 | +| bad-indentation | 11 | +| line-too-long | 5 | +| trailing-whitespace | 4 | +| unused-import | 2 | +| unspecified-encoding | 2 | +| superfluous-parens | 2 | +| singleton-comparison | 2 | +| consider-using-f-string | 2 | +| wrong-import-order | 1 | +| no-else-return | 1 | +| missing-module-docstring | 1 | +| invalid-name | 1 | +| f-string-without-interpolation | 1 | + + + + +----------------------------------- +Your code has been rated at 4.18/10 + From b8d56d2656222866f3a22a5b0cb6b0bc5769b0d3 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:58:37 +0300 Subject: [PATCH 064/103] Fix code formatting and documentation issues --- errors_logs/backup.md | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 errors_logs/backup.md diff --git a/errors_logs/backup.md b/errors_logs/backup.md new file mode 100644 index 0000000..75fc26a --- /dev/null +++ b/errors_logs/backup.md @@ -0,0 +1,78 @@ +************* Module bettyfixer.backup +bettyfixer/backup.py:12: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/backup.py:13: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/backup.py:14: [C0305(trailing-newlines), ] Trailing newlines +bettyfixer/backup.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/backup.py:3: [C0116(missing-function-docstring), create_backup] Missing function or method docstring +bettyfixer/backup.py:10: [W0718(broad-exception-caught), create_backup] Catching too general exception Exception + + +## Report +====== +**9 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |1 |NC |NC |0.00 |0.00 | + + + +16 lines have been analyzed + +Raw metrics +----------- + +| type | number | % | previous | difference | +|-----------|--------|-------|----------|------------| +| code | 11 | 68.75 | NC | NC | +| docstring | 0 | 0.00 | NC | NC | +| comment | 1 | 6.25 | NC | NC | +| empty | 4 | 25.00 | NC | NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |5 |NC |NC | +|refactor |0 |NC |NC | +|warning |1 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +| message id | occurrences | +|---------------------------|-------------| +| trailing-whitespace | 2 | +| trailing-newlines | 1 | +| missing-module-docstring | 1 | +| missing-function-docstring| 1 | +| broad-exception-caught | 1 | + + + + +----------------------------------- +Your code has been rated at 3.33/10 + From a84e17a80cdb508dab131b42ab3bb61e7c63bcd3 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:58:53 +0300 Subject: [PATCH 065/103] Fix bug in login functionality*** ***Refactor code for improved performance*** ***Add new feature for user authentication*** ***Update UI for better user experience*** ***Fix typo in variable name*** ***Optimize database queries*** ***Add error handling for edge cases*** ***Update dependencies to latest versions*** ***Remove unused code*** ***Improve code readability and maintainability --- errors_logs/betty_fixer.md | 168 +++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 errors_logs/betty_fixer.md diff --git a/errors_logs/betty_fixer.md b/errors_logs/betty_fixer.md new file mode 100644 index 0000000..5167a52 --- /dev/null +++ b/errors_logs/betty_fixer.md @@ -0,0 +1,168 @@ +************* Module bettyfixer.betty_fixer +bettyfixer/betty_fixer.py:29: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/betty_fixer.py:117: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/betty_fixer.py:177: [C0301(line-too-long), ] Line too long (115/100) +bettyfixer/betty_fixer.py:208: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/betty_fixer.py:258: [C0301(line-too-long), ] Line too long (136/100) +bettyfixer/betty_fixer.py:273: [C0301(line-too-long), ] Line too long (130/100) +bettyfixer/betty_fixer.py:277: [C0301(line-too-long), ] Line too long (109/100) +bettyfixer/betty_fixer.py:303: [C0325(superfluous-parens), ] Unnecessary parens after 'if' keyword +bettyfixer/betty_fixer.py:330: [C0304(missing-final-newline), ] Final newline missing +bettyfixer/betty_fixer.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/betty_fixer.py:4: [W0401(wildcard-import), ] Wildcard import bettyfixer.backup +bettyfixer/betty_fixer.py:5: [W0401(wildcard-import), ] Wildcard import bettyfixer.errors_extractor +bettyfixer/betty_fixer.py:6: [W0401(wildcard-import), ] Wildcard import bettyfixer.extract_line +bettyfixer/betty_fixer.py:7: [W0401(wildcard-import), ] Wildcard import bettyfixer.autoprototype +bettyfixer/betty_fixer.py:11: [C0116(missing-function-docstring), read_file] Missing function or method docstring +bettyfixer/betty_fixer.py:11: [W0621(redefined-outer-name), read_file] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:12: [W1514(unspecified-encoding), read_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:16: [C0116(missing-function-docstring), write_file] Missing function or method docstring +bettyfixer/betty_fixer.py:16: [W0621(redefined-outer-name), write_file] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:17: [W1514(unspecified-encoding), write_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:20: [C0116(missing-function-docstring), add_line_without_newline] Missing function or method docstring +bettyfixer/betty_fixer.py:20: [W0621(redefined-outer-name), add_line_without_newline] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:22: [W1514(unspecified-encoding), add_line_without_newline] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:27: [W1514(unspecified-encoding), add_line_without_newline] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:30: [C0116(missing-function-docstring), remove_consecutive_blank_lines] Missing function or method docstring +bettyfixer/betty_fixer.py:34: [C0116(missing-function-docstring), add_parentheses_around_return] Missing function or method docstring +bettyfixer/betty_fixer.py:48: [C0116(missing-function-docstring), fix_comments] Missing function or method docstring +bettyfixer/betty_fixer.py:52: [C0116(missing-function-docstring), remove_trailing_whitespaces] Missing function or method docstring +bettyfixer/betty_fixer.py:57: [C0116(missing-function-docstring), process_errors] Missing function or method docstring +bettyfixer/betty_fixer.py:57: [W0621(redefined-outer-name), process_errors] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:59: [W0621(redefined-outer-name), process_errors] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:57: [W0613(unused-argument), process_errors] Unused argument 'file_path' +bettyfixer/betty_fixer.py:62: [C0116(missing-function-docstring), fix_betty_warnings] Missing function or method docstring +bettyfixer/betty_fixer.py:62: [W0621(redefined-outer-name), fix_betty_warnings] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:73: [C0116(missing-function-docstring), remove_blank_lines_inside_comments] Missing function or method docstring +bettyfixer/betty_fixer.py:73: [W0621(redefined-outer-name), remove_blank_lines_inside_comments] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:76: [W1514(unspecified-encoding), remove_blank_lines_inside_comments] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:91: [W1514(unspecified-encoding), remove_blank_lines_inside_comments] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:80: [R1702(too-many-nested-blocks), remove_blank_lines_inside_comments] Too many nested blocks (6/5) +bettyfixer/betty_fixer.py:94: [C0116(missing-function-docstring), fix_betty_style] Missing function or method docstring +bettyfixer/betty_fixer.py:95: [W0621(redefined-outer-name), fix_betty_style] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:111: [W0621(redefined-outer-name), fix_betty_style] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:115: [W1514(unspecified-encoding), fix_betty_style] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:121: [W1514(unspecified-encoding), fix_betty_style] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:141: [C0116(missing-function-docstring), More_than_5_functions_in_the_file] Missing function or method docstring +bettyfixer/betty_fixer.py:141: [C0103(invalid-name), More_than_5_functions_in_the_file] Function name "More_than_5_functions_in_the_file" doesn't conform to snake_case naming style +bettyfixer/betty_fixer.py:141: [R0914(too-many-locals), More_than_5_functions_in_the_file] Too many local variables (17/15) +bettyfixer/betty_fixer.py:141: [W0621(redefined-outer-name), More_than_5_functions_in_the_file] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:156: [W0621(redefined-outer-name), More_than_5_functions_in_the_file] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:148: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:158: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:182: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:185: [R1732(consider-using-with), More_than_5_functions_in_the_file] Consider using 'with' for resource-allocating operations +bettyfixer/betty_fixer.py:185: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:193: [C0116(missing-function-docstring), find_available_file_name] Missing function or method docstring +bettyfixer/betty_fixer.py:204: [C0116(missing-function-docstring), copy_remaining_lines] Missing function or method docstring +bettyfixer/betty_fixer.py:206: [W1514(unspecified-encoding), copy_remaining_lines] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:210: [C0116(missing-function-docstring), betty_handler] Missing function or method docstring +bettyfixer/betty_fixer.py:210: [W0621(redefined-outer-name), betty_handler] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:225: [W0621(redefined-outer-name), betty_handler] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:211: [W1514(unspecified-encoding), betty_handler] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:228: [C0116(missing-function-docstring), other_handlers] Missing function or method docstring +bettyfixer/betty_fixer.py:228: [W0621(redefined-outer-name), other_handlers] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:229: [W0621(redefined-outer-name), other_handlers] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:243: [C0116(missing-function-docstring), create_tasks_directory] Missing function or method docstring +bettyfixer/betty_fixer.py:248: [C0116(missing-function-docstring), copy_files_to_tasks] Missing function or method docstring +bettyfixer/betty_fixer.py:250: [W0621(redefined-outer-name), copy_files_to_tasks] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:254: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:261: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:265: [C0116(missing-function-docstring), modify_main_files] Missing function or method docstring +bettyfixer/betty_fixer.py:267: [W0621(redefined-outer-name), modify_main_files] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:269: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:276: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:280: [C0116(missing-function-docstring), record_processed_file] Missing function or method docstring +bettyfixer/betty_fixer.py:281: [W1514(unspecified-encoding), record_processed_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:284: [C0116(missing-function-docstring), is_file_processed] Missing function or method docstring +bettyfixer/betty_fixer.py:288: [W1514(unspecified-encoding), is_file_processed] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:292: [C0116(missing-function-docstring), main] Missing function or method docstring +bettyfixer/betty_fixer.py:303: [C0121(singleton-comparison), main] Comparison 'v == False' should be 'v is False' if checking for the singleton value False, or 'not v' if testing for falsiness +bettyfixer/betty_fixer.py:318: [R1732(consider-using-with), main] Consider using 'with' for resource-allocating operations +bettyfixer/betty_fixer.py:318: [W1514(unspecified-encoding), main] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:4: [W0614(unused-wildcard-import), ] Unused import(s) shutil from wildcard import of bettyfixer.backup +bettyfixer/betty_fixer.py:5: [W0614(unused-wildcard-import), ] Unused import(s) subprocess, errors_file_path and file_path from wildcard import of bettyfixer.errors_extractor +bettyfixer/betty_fixer.py:6: [W0614(unused-wildcard-import), ] Unused import(s) clean_up_line, fix_errors_from_file, should_be_void, fix_missing_blank_line_after_declaration, fix_should_be_foo_star_star_bar, fix_lines_in_file, generate_documentation, fix_space_prohibited_between_function_name_and_open_parenthesis, fix_space_prohibited_after_that_open_parenthesis, fix_space_prohibited_before_that_close_parenthesis, fix_space_required_before_the_open_parenthesis, fix_brace_on_the_next_line, brace_go_next_line, fix_brace_on_the_previous_line, fix_space_prohibited_before_semicolon, fix_should_be_foo_star_bar, fix_spaces_prohibited_around_that, fix_space_prohibited_after_that, fix_space_prohibited_before_that, fix_spaces_preferred_around_that, fix_space_required_around_that, fix_space_required_after_that, fix_space_required_before_the_open_brace and fix_space_required_after_the_close_brace from wildcard import of bettyfixer.extract_line +bettyfixer/betty_fixer.py:7: [W0614(unused-wildcard-import), ] Unused import(s) argparse, glob, print_Ctags_header_error, check_ctags, generate_tags, filter_tags, create_header, delete_files, check_header_file and Fore from wildcard import of bettyfixer.autoprototype + + + ## Report +====== +**210 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |22 |NC |NC |0.00 |4.55 | + + + +**332 lines have been analyzed** + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |215 |64.76 |NC |NC | +|docstring |1 |0.30 |NC |NC | +|comment |50 |15.06 |NC |NC | +|empty |66 |19.88 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |34 |NC |NC | +|refactor |4 |NC |NC | +|warning |47 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +| message id | occurrences | +|---------------------------|-------------| +| missing-function-docstring| 22 | +| unspecified-encoding | 21 | +| redefined-outer-name | 17 | +| wildcard-import | 4 | +| unused-wildcard-import | 4 | +| line-too-long | 4 | +| trailing-whitespace | 3 | +| consider-using-with | 2 | +| unused-argument | 1 | +| too-many-nested-blocks | 1 | +| too-many-locals | 1 | +| superfluous-parens | 1 | +| singleton-comparison | 1 | +| missing-module-docstring | 1 | +| missing-final-newline | 1 | +| invalid-name | 1 | + + + + +----------------------------------- +Your code has been rated at 5.95/10 + From b07302b99bca935508010ae96a00bc1e04cdeb60 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:58:59 +0300 Subject: [PATCH 066/103] Fix code formatting and documentation issues --- errors_logs/betty_handler.md | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 errors_logs/betty_handler.md diff --git a/errors_logs/betty_handler.md b/errors_logs/betty_handler.md new file mode 100644 index 0000000..6611154 --- /dev/null +++ b/errors_logs/betty_handler.md @@ -0,0 +1,84 @@ +************* Module bettyfixer.betty_handler +bettyfixer/betty_handler.py:24: [C0301(line-too-long), ] Line too long (136/100) +bettyfixer/betty_handler.py:38: [C0301(line-too-long), ] Line too long (130/100) +bettyfixer/betty_handler.py:42: [C0301(line-too-long), ] Line too long (109/100) +bettyfixer/betty_handler.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/betty_handler.py:4: [C0116(missing-function-docstring), other_handler] Missing function or method docstring +bettyfixer/betty_handler.py:9: [C0116(missing-function-docstring), create_tasks_directory] Missing function or method docstring +bettyfixer/betty_handler.py:14: [C0116(missing-function-docstring), copy_files_to_tasks] Missing function or method docstring +bettyfixer/betty_handler.py:20: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_handler.py:27: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_handler.py:30: [C0116(missing-function-docstring), modify_main_files] Missing function or method docstring +bettyfixer/betty_handler.py:34: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding +bettyfixer/betty_handler.py:41: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding + + +Report +------ +33 statements analysed. + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |4 |NC |NC |0.00 |0.00 | + +
+ + +**61 lines have been analyzed** + +**Raw metrics** +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |35 |57.38 |NC |NC | +|docstring |0 |0.00 |NC |NC | +|comment |13 |21.31 |NC |NC | +|empty |13 |21.31 |NC |NC | + +
+ +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |8 |NC |NC | +|refactor |0 |NC |NC | +|warning |4 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +|message id |occurrences | +|---------------------------|------------| +|unspecified-encoding |4 | +|missing-function-docstring |4 | +|line-too-long |3 | +|missing-module-docstring |1 | + + +
+ +----------------------------------- +Your code has been rated at 6.36/10 + From 2d7247234a84b61e467ac8be230b561635f3c104 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:59:04 +0300 Subject: [PATCH 067/103] Add errors_extractor.md with code analysis results --- errors_logs/errors_exractor.md | 86 ++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 errors_logs/errors_exractor.md diff --git a/errors_logs/errors_exractor.md b/errors_logs/errors_exractor.md new file mode 100644 index 0000000..9065d34 --- /dev/null +++ b/errors_logs/errors_exractor.md @@ -0,0 +1,86 @@ +************* Module bettyfixer.errors_extractor +bettyfixer/errors_extractor.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/errors_extractor.py:4: [C0116(missing-function-docstring), exctract_errors] Missing function or method docstring +bettyfixer/errors_extractor.py:4: [W0621(redefined-outer-name), exctract_errors] Redefining name 'file_path' from outer scope (line 36) +bettyfixer/errors_extractor.py:13: [W0621(redefined-outer-name), exctract_errors] Redefining name 'errors_file_path' from outer scope (line 30) +bettyfixer/errors_extractor.py:13: [W1514(unspecified-encoding), exctract_errors] Using open without explicitly specifying an encoding +bettyfixer/errors_extractor.py:17: [W0107(unnecessary-pass), exctract_errors] Unnecessary pass statement +bettyfixer/errors_extractor.py:19: [W1514(unspecified-encoding), exctract_errors] Using open without explicitly specifying an encoding +bettyfixer/errors_extractor.py:30: [C0103(invalid-name), ] Constant name "errors_file_path" doesn't conform to UPPER_CASE naming style +bettyfixer/errors_extractor.py:33: [R1732(consider-using-with), ] Consider using 'with' for resource-allocating operations +bettyfixer/errors_extractor.py:33: [W1514(unspecified-encoding), ] Using open without explicitly specifying an encoding + + +## Report +------ + +**21 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |1 |NC |NC |0.00 |0.00 | + + + +**39 lines have been analyzed** + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |23 |58.97 |NC |NC | +|docstring |0 |0.00 |NC |NC | +|comment |9 |23.08 |NC |NC | +|empty |7 |17.95 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |3 |NC |NC | +|refactor |1 |NC |NC | +|warning |6 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +|message id |occurrences | +|---------------------------|------------| +|unspecified-encoding |3 | +|redefined-outer-name |2 | +|unnecessary-pass |1 | +|missing-module-docstring |1 | +|missing-function-docstring |1 | +|invalid-name |1 | +|consider-using-with |1 | + +
+ + + +----------------------------------- +Your code has been rated at 5.24/10 + From b0f866028b6be8527c93381603d6e0eb713d87d4 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:59:08 +0300 Subject: [PATCH 068/103] Refactor code to improve performance and readability --- errors_logs/extract_line.md | 247 ++++++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 errors_logs/extract_line.md diff --git a/errors_logs/extract_line.md b/errors_logs/extract_line.md new file mode 100644 index 0000000..14ef1c1 --- /dev/null +++ b/errors_logs/extract_line.md @@ -0,0 +1,247 @@ +************* Module bettyfixer.extract_line +bettyfixer/extract_line.py:31: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:78: [C0301(line-too-long), ] Line too long (122/100) +bettyfixer/extract_line.py:80: [C0301(line-too-long), ] Line too long (107/100) +bettyfixer/extract_line.py:82: [C0301(line-too-long), ] Line too long (109/100) +bettyfixer/extract_line.py:84: [C0301(line-too-long), ] Line too long (105/100) +bettyfixer/extract_line.py:148: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:187: [C0301(line-too-long), ] Line too long (106/100) +bettyfixer/extract_line.py:209: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:259: [C0301(line-too-long), ] Line too long (107/100) +bettyfixer/extract_line.py:262: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 +bettyfixer/extract_line.py:267: [C0301(line-too-long), ] Line too long (102/100) +bettyfixer/extract_line.py:269: [C0301(line-too-long), ] Line too long (122/100) +bettyfixer/extract_line.py:276: [C0301(line-too-long), ] Line too long (180/100) +bettyfixer/extract_line.py:299: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:310: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:323: [C0301(line-too-long), ] Line too long (110/100) +bettyfixer/extract_line.py:327: [C0301(line-too-long), ] Line too long (119/100) +bettyfixer/extract_line.py:333: [C0301(line-too-long), ] Line too long (146/100) +bettyfixer/extract_line.py:341: [C0301(line-too-long), ] Line too long (104/100) +bettyfixer/extract_line.py:359: [C0301(line-too-long), ] Line too long (101/100) +bettyfixer/extract_line.py:361: [C0301(line-too-long), ] Line too long (113/100) +bettyfixer/extract_line.py:368: [C0301(line-too-long), ] Line too long (111/100) +bettyfixer/extract_line.py:382: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:388: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:452: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:504: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:507: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:517: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:519: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:570: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:580: [C0301(line-too-long), ] Line too long (117/100) +bettyfixer/extract_line.py:584: [C0301(line-too-long), ] Line too long (151/100) +bettyfixer/extract_line.py:589: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:649: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:671: [C0325(superfluous-parens), ] Unnecessary parens after 'not' keyword +bettyfixer/extract_line.py:700: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:743: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:784: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:807: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:822: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:834: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:857: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:872: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:884: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/extract_line.py:7: [C0116(missing-function-docstring), run_vi_script] Missing function or method docstring +bettyfixer/extract_line.py:11: [W1510(subprocess-run-check), run_vi_script] 'subprocess.run' used without explicitly defining the value for 'check'. +bettyfixer/extract_line.py:13: [C0116(missing-function-docstring), remove_extra_spaces] Missing function or method docstring +bettyfixer/extract_line.py:24: [C0116(missing-function-docstring), process_error_file] Missing function or method docstring +bettyfixer/extract_line.py:24: [W0621(redefined-outer-name), process_error_file] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:25: [W1514(unspecified-encoding), process_error_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:32: [C0116(missing-function-docstring), extract_and_print_variables] Missing function or method docstring +bettyfixer/extract_line.py:44: [C0116(missing-function-docstring), clean_up_line] Missing function or method docstring +bettyfixer/extract_line.py:53: [C0116(missing-function-docstring), fix_errors_from_file] Missing function or method docstring +bettyfixer/extract_line.py:53: [R0912(too-many-branches), fix_errors_from_file] Too many branches (18/12) +bettyfixer/extract_line.py:110: [C0116(missing-function-docstring), fix_should_be_void] Missing function or method docstring +bettyfixer/extract_line.py:110: [W0621(redefined-outer-name), fix_should_be_void] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:116: [W1514(unspecified-encoding), fix_should_be_void] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:132: [C0116(missing-function-docstring), should_be_void] Missing function or method docstring +bettyfixer/extract_line.py:132: [W0621(redefined-outer-name), should_be_void] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:139: [W1514(unspecified-encoding), should_be_void] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:146: [W1514(unspecified-encoding), should_be_void] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:159: [C0116(missing-function-docstring), clean_errors_file] Missing function or method docstring +bettyfixer/extract_line.py:159: [W0621(redefined-outer-name), clean_errors_file] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:163: [R1732(consider-using-with), clean_errors_file] Consider using 'with' for resource-allocating operations +bettyfixer/extract_line.py:163: [W1514(unspecified-encoding), clean_errors_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:169: [C0116(missing-function-docstring), fix_missing_blank_line_after_declarations] Missing function or method docstring +bettyfixer/extract_line.py:169: [W0621(redefined-outer-name), fix_missing_blank_line_after_declarations] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:175: [W1514(unspecified-encoding), fix_missing_blank_line_after_declarations] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:190: [C0116(missing-function-docstring), fix_missing_blank_line_after_declaration] Missing function or method docstring +bettyfixer/extract_line.py:190: [W0621(redefined-outer-name), fix_missing_blank_line_after_declaration] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:195: [W1514(unspecified-encoding), fix_missing_blank_line_after_declaration] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:207: [W1514(unspecified-encoding), fix_missing_blank_line_after_declaration] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:215: [C0116(missing-function-docstring), fix_should_be_foo_star_star_bar] Missing function or method docstring +bettyfixer/extract_line.py:220: [W1514(unspecified-encoding), fix_should_be_foo_star_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:227: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:229: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:231: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:233: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:243: [W1514(unspecified-encoding), fix_should_be_foo_star_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:246: [C0116(missing-function-docstring), remove_unused_attribute] Missing function or method docstring +bettyfixer/extract_line.py:283: [W0718(broad-exception-caught), remove_unused_attribute] Catching too general exception Exception +bettyfixer/extract_line.py:248: [W1514(unspecified-encoding), remove_unused_attribute] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:279: [W1514(unspecified-encoding), remove_unused_attribute] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:264: [W0612(unused-variable), remove_unused_attribute] Unused variable 'original_declaration' +bettyfixer/extract_line.py:286: [C0116(missing-function-docstring), fix_lines_in_file] Missing function or method docstring +bettyfixer/extract_line.py:308: [W0718(broad-exception-caught), fix_lines_in_file] Catching too general exception Exception +bettyfixer/extract_line.py:288: [W1514(unspecified-encoding), fix_lines_in_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:306: [W1514(unspecified-encoding), fix_lines_in_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:287: [R1702(too-many-nested-blocks), fix_lines_in_file] Too many nested blocks (6/5) +bettyfixer/extract_line.py:311: [C0116(missing-function-docstring), generate_documentation] Missing function or method docstring +bettyfixer/extract_line.py:352: [C0116(missing-function-docstring), extract_functions_with_no_description] Missing function or method docstring +bettyfixer/extract_line.py:355: [W1514(unspecified-encoding), extract_functions_with_no_description] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:368: [C0116(missing-function-docstring), fix_space_prohibited_between_function_name_and_open_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:374: [W1514(unspecified-encoding), fix_space_prohibited_between_function_name_and_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:387: [W1514(unspecified-encoding), fix_space_prohibited_between_function_name_and_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:389: [C0116(missing-function-docstring), fix_space_prohibited_after_that_open_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:395: [W1514(unspecified-encoding), fix_space_prohibited_after_that_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:408: [W1514(unspecified-encoding), fix_space_prohibited_after_that_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:410: [C0116(missing-function-docstring), fix_space_prohibited_before_that_close_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:416: [W1514(unspecified-encoding), fix_space_prohibited_before_that_close_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:429: [W1514(unspecified-encoding), fix_space_prohibited_before_that_close_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:431: [C0116(missing-function-docstring), fix_space_required_before_the_open_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:437: [W1514(unspecified-encoding), fix_space_required_before_the_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:450: [W1514(unspecified-encoding), fix_space_required_before_the_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:453: [C0116(missing-function-docstring), fix_brace_should_be_on_the_next_line] Missing function or method docstring +bettyfixer/extract_line.py:453: [W0621(redefined-outer-name), fix_brace_should_be_on_the_next_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:459: [W1514(unspecified-encoding), fix_brace_should_be_on_the_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:492: [C0116(missing-function-docstring), fix_brace_on_the_next_line] Missing function or method docstring +bettyfixer/extract_line.py:492: [W0621(redefined-outer-name), fix_brace_on_the_next_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:497: [W1514(unspecified-encoding), fix_brace_on_the_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:509: [W1514(unspecified-encoding), fix_brace_on_the_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:520: [C0116(missing-function-docstring), brace_go_next_line] Missing function or method docstring +bettyfixer/extract_line.py:524: [W1514(unspecified-encoding), brace_go_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:539: [W1514(unspecified-encoding), brace_go_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:542: [C0116(missing-function-docstring), fix_brace_should_be_on_the_previous_line] Missing function or method docstring +bettyfixer/extract_line.py:542: [W0621(redefined-outer-name), fix_brace_should_be_on_the_previous_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:548: [W1514(unspecified-encoding), fix_brace_should_be_on_the_previous_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:563: [C0116(missing-function-docstring), fix_brace_on_the_previous_line] Missing function or method docstring +bettyfixer/extract_line.py:563: [W0621(redefined-outer-name), fix_brace_on_the_previous_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:568: [W1514(unspecified-encoding), fix_brace_on_the_previous_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:587: [W1514(unspecified-encoding), fix_brace_on_the_previous_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:596: [C0116(missing-function-docstring), fix_space_prohibited_before_semicolon] Missing function or method docstring +bettyfixer/extract_line.py:599: [W1514(unspecified-encoding), fix_space_prohibited_before_semicolon] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:613: [W1514(unspecified-encoding), fix_space_prohibited_before_semicolon] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:615: [C0116(missing-function-docstring), fix_should_be_foo_star_bar] Missing function or method docstring +bettyfixer/extract_line.py:620: [W1514(unspecified-encoding), fix_should_be_foo_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:627: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:629: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:631: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:633: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:643: [W1514(unspecified-encoding), fix_should_be_foo_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:645: [C0116(missing-function-docstring), fix_spaces_prohibited_around_that] Missing function or method docstring +bettyfixer/extract_line.py:667: [W1514(unspecified-encoding), fix_spaces_prohibited_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:693: [W1514(unspecified-encoding), fix_spaces_prohibited_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:696: [C0116(missing-function-docstring), fix_space_prohibited_after_that] Missing function or method docstring +bettyfixer/extract_line.py:718: [W1514(unspecified-encoding), fix_space_prohibited_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:737: [W1514(unspecified-encoding), fix_space_prohibited_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:739: [C0116(missing-function-docstring), fix_space_prohibited_before_that] Missing function or method docstring +bettyfixer/extract_line.py:761: [W1514(unspecified-encoding), fix_space_prohibited_before_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:768: [R1714(consider-using-in), fix_space_prohibited_before_that] Consider merging these comparisons with 'in' by using 'context in ('WxV', 'WxO', 'WxE', 'WxW')'. Use a set instead if elements are hashable. +bettyfixer/extract_line.py:778: [W1514(unspecified-encoding), fix_space_prohibited_before_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:780: [C0116(missing-function-docstring), fix_spaces_preferred_around_that] Missing function or method docstring +bettyfixer/extract_line.py:802: [W1514(unspecified-encoding), fix_spaces_preferred_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:828: [W1514(unspecified-encoding), fix_spaces_preferred_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:830: [C0116(missing-function-docstring), fix_space_required_around_that] Missing function or method docstring +bettyfixer/extract_line.py:852: [W1514(unspecified-encoding), fix_space_required_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:878: [W1514(unspecified-encoding), fix_space_required_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:880: [C0116(missing-function-docstring), fix_space_required_after_that] Missing function or method docstring +bettyfixer/extract_line.py:902: [W1514(unspecified-encoding), fix_space_required_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:909: [R1714(consider-using-in), fix_space_required_after_that] Consider merging these comparisons with 'in' by using 'context in ('WxV', 'VxV')'. Use a set instead if elements are hashable. +bettyfixer/extract_line.py:919: [W1514(unspecified-encoding), fix_space_required_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:921: [C0116(missing-function-docstring), fix_space_required_before_the_open_brace] Missing function or method docstring +bettyfixer/extract_line.py:927: [W1514(unspecified-encoding), fix_space_required_before_the_open_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:940: [W1514(unspecified-encoding), fix_space_required_before_the_open_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:942: [C0116(missing-function-docstring), fix_space_required_after_the_close_brace] Missing function or method docstring +bettyfixer/extract_line.py:948: [W1514(unspecified-encoding), fix_space_required_after_the_close_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:961: [W1514(unspecified-encoding), fix_space_required_after_the_close_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:968: [C0103(invalid-name), ] Constant name "errors_file_path" doesn't conform to UPPER_CASE naming style +bettyfixer/extract_line.py:4: [C0411(wrong-import-order), ] standard import "import os" should be placed before "from bettyfixer.errors_extractor import exctract_errors" +bettyfixer/extract_line.py:5: [C0411(wrong-import-order), ] standard import "import subprocess" should be placed before "from bettyfixer.errors_extractor import exctract_errors" + + + ## Report + +**522 statements analysed.** + +Statistics by type +------------------ + +| type | number | old number | difference | %documented | %badname | +|----------|--------|------------|------------|-------------|----------| +| module | 1 | 1 | = | 0.00 | 0.00 | +| class | 0 | NC | NC | 0 | 0 | +| method | 0 | NC | NC | 0 | 0 | +| function | 35 | 35 | = | 0.00 | 0.00 | + + +**971 lines have been analyzed** + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |536 |55.20 |NC |NC | +|docstring |16 |1.65 |NC |NC | +|comment |206 |21.22 |NC |NC | +|empty |213 |21.94 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |0 |0 | +|percent duplicated lines |0.000 |0.000 |= | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |82 |82 |82 | +|refactor |5 |5 |5 | +|warning |74 |74 |74 | +|error |0 |0 |0 | + + + +Messages +-------- + + +| message id | occurrences | +|------------------------------- | ------------| +| unspecified-encoding | 51 | +| missing-function-docstring | 35 | +| trailing-whitespace | 24 | +| line-too-long | 18 | +| redefined-outer-name | 10 | +| f-string-without-interpolation | 8 | +| wrong-import-order | 2 | +| consider-using-in | 2 | +| broad-exception-caught | 2 | +| unused-variable | 1 | +| too-many-nested-blocks | 1 | +| too-many-branches | 1 | +| superfluous-parens | 1 | +| subprocess-run-check | 1 | +| missing-module-docstring | 1 | +| invalid-name | 1 | +| consider-using-with | 1 | +| bad-indentation | 1 | + + + + + +------------------------------------------------------------------ +Your code has been rated at 6.92/10 (previous run: 6.92/10, +0.00) + From 42fd7f4f36b1961c384411b81ce506c0da3d4ec1 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:33:44 +0300 Subject: [PATCH 069/103] Refactor betty_check function and improve code readability --- bettyfixer/autoprototype.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/bettyfixer/autoprototype.py b/bettyfixer/autoprototype.py index 246931d..d1dfaf2 100644 --- a/bettyfixer/autoprototype.py +++ b/bettyfixer/autoprototype.py @@ -11,12 +11,14 @@ def betty_check(): """Check if betty is installed and if there are any errors in the files. Returns: - bool: True if betty is installed and there are no errors, False otherwise. + bool: True if betty is installed and there are no errors, + False otherwise. """ try: c_files = glob.glob("*.c") result1 = subprocess.run(["betty"] + c_files, check=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True) except subprocess.CalledProcessError as e: print(e) @@ -59,7 +61,8 @@ def check_ctags(): stderr=subprocess.PIPE, check=True) return True, None except subprocess.CalledProcessError: - msg = "ctags is not installed. Please install ctags before running this script." + msg = "ctags is not installed. \ + Please install ctags before running this script." return False, msg @@ -71,8 +74,10 @@ def generate_tags(directory): bool: True if ctags is generated successfully, False otherwise. """ try: - subprocess.run(['ctags', '-R', '--c-kinds=+p', '--fields=+S', '--extra=+q', - '--languages=c', '--langmap=c:.c', directory], check=True) + subprocess.run(['ctags', '-R', '--c-kinds=+p', + '--fields=+S', '--extra=+q', + '--languages=c', '--langmap=c:.c', + directory], check=True) return True except subprocess.CalledProcessError as e: print_ctags_header_error(f"Error generating ctags: {e}") @@ -91,8 +96,12 @@ def filter_tags(directory, tags_file): temp_tags_path = os.path.join(directory, 'temp_tags') tags_path = os.path.join(directory, tags_file) - sed_command = r"cat {0} | sed -n 's/^.*\/^\(.*\)/\1/p' | sed 's/\(.*\)\$.*/\1/' | sed 's/;$//' | uniq | sed '/int main(/d' | sed '/.*:/d' | sed 's/$/;/g' > {1}".format( - tags_path, temp_tags_path) + sed_command = ( + f"cat {tags_path} | sed -n 's/^.*\\/^(.*)/\\1/p' | " + "sed 's/(.*)\\$.*/\\1/' | sed 's/;$//' | " + "uniq | sed '/int main(/d' | sed '/.*:/d' | " + f"sed 's/$/;/g' > {temp_tags_path}" + ) # Run the sed_command using subprocess subprocess.run(sed_command, shell=True, check=True) @@ -155,7 +164,8 @@ def check_header_file(header_file): def autoproto(directory, header): """ - Generate a header file with the prototypes of the functions in the directory. + Generate a header file with the prototypes of + the functions in the directory. Args: directory (str): Directory path. header (str): Header file name. From 498d3fcc0ae94349bca0bfaee55e5e9f43dbf7cc Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:33:49 +0300 Subject: [PATCH 070/103] Refactor Betty Handler module and improve code readability --- bettyfixer/betty_handler.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bettyfixer/betty_handler.py b/bettyfixer/betty_handler.py index e493538..6951bc9 100644 --- a/bettyfixer/betty_handler.py +++ b/bettyfixer/betty_handler.py @@ -1,7 +1,8 @@ """ This module contains functions for handling Betty style tasks. -The module can be run as a script, taking a list of file paths as command-line arguments. +The module can be run as a script, taking a list of file paths as command-line +arguments. When run as a script, it creates a tasks directory if one doesn't exist, copies the specified files to the tasks directory, and modifies the main files. """ @@ -12,7 +13,8 @@ def other_handler(file_path): """ This function creates a tasks directory if one doesn't exist, - copies the specified files to the tasks directory, and modifies the main files. + copies the specified files to the tasks directory, + and modifies the main files. """ create_tasks_directory() copy_files_to_tasks(file_path) @@ -46,8 +48,8 @@ def copy_files_to_tasks(files): ).startswith("#include") or not line.strip().endswith('.h"')] # Write the modified content to the destination file - with open(destination_path, 'w', encoding='utf-8') as destination_file: - destination_file.write(''.join(filtered_content)) + with open(destination_path, 'w', encoding='utf-8') as dest_file: + dest_file.write(''.join(filtered_content)) def modify_main_files(files): @@ -67,10 +69,12 @@ def modify_main_files(files): include_lines = [line.strip() for line in content if line.strip( ).startswith("#include") and line.strip().endswith('.h"')] - # Write the modified content to the main file, adding an empty line at the end + # Write the modified content to main file. + # adding an empty line at the end with open(file_path, 'w', encoding='utf-8') as main_file: main_file.write('\n'.join( - include_lines + [f'#include "tasks/{os.path.basename(file_path)}"\n'])) + include_lines + [ + f'#include "tasks/{os.path.basename(file_path)}"\n'])) if __name__ == "__main__": From 717cb0de37c3fb2efe996f0f2e4bcc2d77cb9258 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:39:04 +0300 Subject: [PATCH 071/103] Refactor error extraction function --- bettyfixer/errors_extractor.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bettyfixer/errors_extractor.py b/bettyfixer/errors_extractor.py index 4b33e15..4a5c418 100644 --- a/bettyfixer/errors_extractor.py +++ b/bettyfixer/errors_extractor.py @@ -7,10 +7,12 @@ def exctract_errors(file_path, output_file): """ - Extract errors from a file using Betty style checker and append them to common errors.txt file. + Extract errors from a file using Betty style checker and append them + to common errors.txt file. Args: file_path (str): The path of the file to extract errors from. - output_file (str): The path of the common errors.txt file to append the errors to. + output_file (str): The path of the common errors.txt file to append the + errors to. """ try: # Run Betty on the specified file @@ -25,7 +27,7 @@ def exctract_errors(file_path, output_file): errors_file_path.write(output) except subprocess.CalledProcessError as e: # Handle the case when Betty returns a non-zero exit code - pass + # Append the error output to the common errors.txt file with open(output_file, 'a', encoding='utf-8') as errors_file_path: errors_file_path.write(e.stdout) @@ -39,11 +41,11 @@ def exctract_errors(file_path, output_file): sys.exit(1) # Specify the common errors.txt file in the current directory - errors_file_path = 'errors.txt' + ERRORS_FILE_PATH = 'errors.txt' # Clear the content of the errors.txt file before appending new errors - open(errors_file_path, 'w', encoding='utf-8').close() + open(ERRORS_FILE_PATH, 'w', encoding='utf-8').close() # Iterate over each file provided as a command-line argument - for file_path in sys.argv[1:]: - exctract_errors(file_path, errors_file_path) + for fpath in sys.argv[1:]: + exctract_errors(fpath, ERRORS_FILE_PATH) From 909d4700411253bfd56a11816435ac8b97b6faec Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:49:12 +0300 Subject: [PATCH 072/103] Fix space required after specifier in extract_line.py --- bettyfixer/extract_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index db8b2bc..ccbe642 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -1249,7 +1249,7 @@ def fix_space_required_after_that(file_path, line_number, error_description): error_line = lines[int(line_number) - 1] # Fix line according to the context conditions - if context == 'WxV' or context == 'VxV': + if context in ('WxV', 'VxV'): fixed_line = error_line.replace(f'{specifier}', f'{specifier} ') else: # If the context doesn't match known conditions, From 5da12d0100368bb4116e5c4fc2745a59d2f5e90b Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:11:09 +0300 Subject: [PATCH 073/103] Add header file generation functionality --- bettyfixer/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bettyfixer/__init__.py b/bettyfixer/__init__.py index 51c9398..6fa5d0a 100644 --- a/bettyfixer/__init__.py +++ b/bettyfixer/__init__.py @@ -1,2 +1,5 @@ +""" +This module contains the functions to generate a header file with +""" from .betty_fixer import * # modify_main_files(sys.argv[1:]) From a18232ccc0d08e5e5ba157a4c852fe3be6f1f1dd Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:09 +0300 Subject: [PATCH 074/103] Refactor create_backup function error handling --- bettyfixer/backup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bettyfixer/backup.py b/bettyfixer/backup.py index 76f627f..335ba9e 100644 --- a/bettyfixer/backup.py +++ b/bettyfixer/backup.py @@ -13,7 +13,14 @@ def create_backup(file_path): try: backup_path = file_path + '.bak' shutil.copy2(file_path, backup_path) + except shutil.SameFileError: + print( + f"Err creating backup {file_path}: Src and dest are same file.") except FileNotFoundError: print(f"Error creating backup for {file_path}: File not found.") - except Exception as e: - print(f"Unexpected error in create_backup for {file_path}: {e}") + except IsADirectoryError: + print(f"Error creating backup for {file_path}: Is a directory.") + except PermissionError: + print(f"Error creating backup for {file_path}: Permission denied.") + except OSError as e: + print(f"Error creating backup for {file_path}: {e.strerror}") From f19cc93a3dc7fb05329a2e9699a3b6148a1d6de3 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:14 +0300 Subject: [PATCH 075/103] Fix clearing of errors.txt file --- bettyfixer/errors_extractor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bettyfixer/errors_extractor.py b/bettyfixer/errors_extractor.py index 4a5c418..bcc3962 100644 --- a/bettyfixer/errors_extractor.py +++ b/bettyfixer/errors_extractor.py @@ -44,7 +44,8 @@ def exctract_errors(file_path, output_file): ERRORS_FILE_PATH = 'errors.txt' # Clear the content of the errors.txt file before appending new errors - open(ERRORS_FILE_PATH, 'w', encoding='utf-8').close() + with open(ERRORS_FILE_PATH, 'w', encoding='utf-8') as errors_file: + errors_file.close() # Iterate over each file provided as a command-line argument for fpath in sys.argv[1:]: From 2c3e6340c486ef6e1cec62cd6f4ed7c1e65406dc Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:19 +0300 Subject: [PATCH 076/103] Fix code formatting and documentation issues --- errors_logs/autoprototype.md | 135 ----------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 errors_logs/autoprototype.md diff --git a/errors_logs/autoprototype.md b/errors_logs/autoprototype.md deleted file mode 100644 index 5ba1980..0000000 --- a/errors_logs/autoprototype.md +++ /dev/null @@ -1,135 +0,0 @@ -************* Module bettyfixer.autoprototype -bettyfixer/autoprototype.py:12: [C0301(line-too-long), ] Line too long (124/100) -bettyfixer/autoprototype.py:28: [C0301(line-too-long), ] Line too long (123/100) -bettyfixer/autoprototype.py:36: [C0301(line-too-long), ] Line too long (106/100) -bettyfixer/autoprototype.py:44: [C0301(line-too-long), ] Line too long (143/100) -bettyfixer/autoprototype.py:53: [C0301(line-too-long), ] Line too long (199/100) -bettyfixer/autoprototype.py:54: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/autoprototype.py:85: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/autoprototype.py:87: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/autoprototype.py:90: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 -bettyfixer/autoprototype.py:91: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 -bettyfixer/autoprototype.py:92: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 -bettyfixer/autoprototype.py:92: [C0325(superfluous-parens), ] Unnecessary parens after 'if' keyword -bettyfixer/autoprototype.py:93: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 -bettyfixer/autoprototype.py:94: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 -bettyfixer/autoprototype.py:94: [C0325(superfluous-parens), ] Unnecessary parens after 'elif' keyword -bettyfixer/autoprototype.py:95: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 -bettyfixer/autoprototype.py:96: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 -bettyfixer/autoprototype.py:97: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 -bettyfixer/autoprototype.py:98: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/autoprototype.py:98: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 -bettyfixer/autoprototype.py:99: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 -bettyfixer/autoprototype.py:100: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 -bettyfixer/autoprototype.py:1: [C0114(missing-module-docstring), ] Missing module docstring -bettyfixer/autoprototype.py:9: [C0116(missing-function-docstring), betty_check] Missing function or method docstring -bettyfixer/autoprototype.py:27: [C0116(missing-function-docstring), print_check_betty_first] Missing function or method docstring -bettyfixer/autoprototype.py:29: [C0116(missing-function-docstring), print_header_name_missing] Missing function or method docstring -bettyfixer/autoprototype.py:31: [C0116(missing-function-docstring), print_Ctags_header_error] Missing function or method docstring -bettyfixer/autoprototype.py:31: [C0103(invalid-name), print_Ctags_header_error] Function name "print_Ctags_header_error" doesn't conform to snake_case naming style -bettyfixer/autoprototype.py:34: [C0116(missing-function-docstring), check_ctags] Missing function or method docstring -bettyfixer/autoprototype.py:42: [C0116(missing-function-docstring), generate_tags] Missing function or method docstring -bettyfixer/autoprototype.py:44: [W1309(f-string-without-interpolation), generate_tags] Using an f-string that does not have any interpolated variables -bettyfixer/autoprototype.py:49: [C0116(missing-function-docstring), filter_tags] Missing function or method docstring -bettyfixer/autoprototype.py:53: [C0209(consider-using-f-string), filter_tags] Formatting a regular string which could be an f-string -bettyfixer/autoprototype.py:59: [R1705(no-else-return), filter_tags] Unnecessary "else" after "return", remove the "else" and de-indent the code inside it -bettyfixer/autoprototype.py:60: [W1514(unspecified-encoding), filter_tags] Using open without explicitly specifying an encoding -bettyfixer/autoprototype.py:69: [C0116(missing-function-docstring), create_header] Missing function or method docstring -bettyfixer/autoprototype.py:73: [W1514(unspecified-encoding), create_header] Using open without explicitly specifying an encoding -bettyfixer/autoprototype.py:78: [C0116(missing-function-docstring), delete_files] Missing function or method docstring -bettyfixer/autoprototype.py:79: [C0209(consider-using-f-string), delete_files] Formatting a regular string which could be an f-string -bettyfixer/autoprototype.py:83: [C0116(missing-function-docstring), check_header_file] Missing function or method docstring -bettyfixer/autoprototype.py:89: [C0116(missing-function-docstring), autoproto] Missing function or method docstring -bettyfixer/autoprototype.py:96: [C0121(singleton-comparison), autoproto] Comparison 'generate_tags(directory) != False' should be 'generate_tags(directory) is not False' if checking for the singleton value False, or 'generate_tags(directory)' if testing for truthiness -bettyfixer/autoprototype.py:98: [C0121(singleton-comparison), autoproto] Comparison 'filtered_tags != None' should be 'filtered_tags is not None' -bettyfixer/autoprototype.py:6: [C0411(wrong-import-order), ] standard import "import glob" should be placed before "from colorama import Fore" -bettyfixer/autoprototype.py:1: [W0611(unused-import), ] Unused import argparse -bettyfixer/autoprototype.py:4: [W0611(unused-import), ] Unused import re - - -## Report -====== -**79 statements analysed.** - -Statistics by type ------------------- - -|type |number |old number |difference |%documented |%badname | -|---------|-------|-----------|-----------|------------|---------| -|module |1 |NC |NC |0.00 |0.00 | -|class |0 |NC |NC |0 |0 | -|method |0 |NC |NC |0 |0 | -|function |11 |NC |NC |0.00 |9.09 | - - - -External dependencies ---------------------- -:: - - colorama (bettyfixer.autoprototype) - - - -102 lines have been analyzed - -Raw metrics ------------ - -|type |number |% |previous |difference | -|----------|-------|------|---------|-----------| -|code |82 |80.39 |NC |NC | -|docstring |0 |0.00 |NC |NC | -|comment |5 |4.90 |NC |NC | -|empty |15 |14.71 |NC |NC | - - - -Duplication ------------ - -| |now |previous |difference | -|-------------------------|------|---------|-----------| -|nb duplicated lines |0 |NC |NC | -|percent duplicated lines |0.000 |NC |NC | - - - -Messages by category --------------------- - -|type |number |previous |difference | -|===========|=======|=========|===========| -|convention |29 |NC |NC | -|refactor |1 |NC |NC | -|warning |16 |NC |NC | -|error |0 |NC |NC | - - - -Messages --------- - -| message id | occurrences | -|--------------------------------|-------------| -| missing-function-docstring | 11 | -| bad-indentation | 11 | -| line-too-long | 5 | -| trailing-whitespace | 4 | -| unused-import | 2 | -| unspecified-encoding | 2 | -| superfluous-parens | 2 | -| singleton-comparison | 2 | -| consider-using-f-string | 2 | -| wrong-import-order | 1 | -| no-else-return | 1 | -| missing-module-docstring | 1 | -| invalid-name | 1 | -| f-string-without-interpolation | 1 | - - - - ------------------------------------ -Your code has been rated at 4.18/10 - From fdea4778ff324e331dedcf4090c1cbd3f36ffbab Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:23 +0300 Subject: [PATCH 077/103] Fix code style issues in autoprototype.py --- errors_logs/autoprototype.txt | 135 ++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 errors_logs/autoprototype.txt diff --git a/errors_logs/autoprototype.txt b/errors_logs/autoprototype.txt new file mode 100644 index 0000000..e15e8e3 --- /dev/null +++ b/errors_logs/autoprototype.txt @@ -0,0 +1,135 @@ +************* Module bettyfixer.autoprototype +bettyfixer/autoprototype.py:12: [C0301(line-too-long), ] Line too long (124/100) +bettyfixer/autoprototype.py:28: [C0301(line-too-long), ] Line too long (123/100) +bettyfixer/autoprototype.py:36: [C0301(line-too-long), ] Line too long (106/100) +bettyfixer/autoprototype.py:44: [C0301(line-too-long), ] Line too long (143/100) +bettyfixer/autoprototype.py:53: [C0301(line-too-long), ] Line too long (199/100) +bettyfixer/autoprototype.py:54: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:85: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:87: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:90: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:91: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:92: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:92: [C0325(superfluous-parens), ] Unnecessary parens after 'if' keyword +bettyfixer/autoprototype.py:93: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:94: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:94: [C0325(superfluous-parens), ] Unnecessary parens after 'elif' keyword +bettyfixer/autoprototype.py:95: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:96: [W0311(bad-indentation), ] Bad indentation. Found 8 spaces, expected 4 +bettyfixer/autoprototype.py:97: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:98: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/autoprototype.py:98: [W0311(bad-indentation), ] Bad indentation. Found 12 spaces, expected 8 +bettyfixer/autoprototype.py:99: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 +bettyfixer/autoprototype.py:100: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 +bettyfixer/autoprototype.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/autoprototype.py:9: [C0116(missing-function-docstring), betty_check] Missing function or method docstring +bettyfixer/autoprototype.py:27: [C0116(missing-function-docstring), print_check_betty_first] Missing function or method docstring +bettyfixer/autoprototype.py:29: [C0116(missing-function-docstring), print_header_name_missing] Missing function or method docstring +bettyfixer/autoprototype.py:31: [C0116(missing-function-docstring), print_Ctags_header_error] Missing function or method docstring +bettyfixer/autoprototype.py:31: [C0103(invalid-name), print_Ctags_header_error] Function name "print_Ctags_header_error" doesn't conform to snake_case naming style +bettyfixer/autoprototype.py:34: [C0116(missing-function-docstring), check_ctags] Missing function or method docstring +bettyfixer/autoprototype.py:42: [C0116(missing-function-docstring), generate_tags] Missing function or method docstring +bettyfixer/autoprototype.py:44: [W1309(f-string-without-interpolation), generate_tags] Using an f-string that does not have any interpolated variables +bettyfixer/autoprototype.py:49: [C0116(missing-function-docstring), filter_tags] Missing function or method docstring +bettyfixer/autoprototype.py:53: [C0209(consider-using-f-string), filter_tags] Formatting a regular string which could be an f-string +bettyfixer/autoprototype.py:59: [R1705(no-else-return), filter_tags] Unnecessary "else" after "return", remove the "else" and de-indent the code inside it +bettyfixer/autoprototype.py:60: [W1514(unspecified-encoding), filter_tags] Using open without explicitly specifying an encoding +bettyfixer/autoprototype.py:69: [C0116(missing-function-docstring), create_header] Missing function or method docstring +bettyfixer/autoprototype.py:73: [W1514(unspecified-encoding), create_header] Using open without explicitly specifying an encoding +bettyfixer/autoprototype.py:78: [C0116(missing-function-docstring), delete_files] Missing function or method docstring +bettyfixer/autoprototype.py:79: [C0209(consider-using-f-string), delete_files] Formatting a regular string which could be an f-string +bettyfixer/autoprototype.py:83: [C0116(missing-function-docstring), check_header_file] Missing function or method docstring +bettyfixer/autoprototype.py:89: [C0116(missing-function-docstring), autoproto] Missing function or method docstring +bettyfixer/autoprototype.py:96: [C0121(singleton-comparison), autoproto] Comparison 'generate_tags(directory) != False' should be 'generate_tags(directory) is not False' if checking for the singleton value False, or 'generate_tags(directory)' if testing for truthiness +bettyfixer/autoprototype.py:98: [C0121(singleton-comparison), autoproto] Comparison 'filtered_tags != None' should be 'filtered_tags is not None' +bettyfixer/autoprototype.py:6: [C0411(wrong-import-order), ] standard import "import glob" should be placed before "from colorama import Fore" +bettyfixer/autoprototype.py:1: [W0611(unused-import), ] Unused import argparse +bettyfixer/autoprototype.py:4: [W0611(unused-import), ] Unused import re + + +## Report +====== +**79 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |11 |NC |NC |0.00 |9.09 | + + + +External dependencies +--------------------- +:: + + colorama (bettyfixer.autoprototype) + + + +102 lines have been analyzed + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |82 |80.39 |NC |NC | +|docstring |0 |0.00 |NC |NC | +|comment |5 |4.90 |NC |NC | +|empty |15 |14.71 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |29 |NC |NC | +|refactor |1 |NC |NC | +|warning |16 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +| message id | occurrences | +|--------------------------------|-------------| +| missing-function-docstring | 11 | +| bad-indentation | 11 | +| line-too-long | 5 | +| trailing-whitespace | 4 | +| unused-import | 2 | +| unspecified-encoding | 2 | +| superfluous-parens | 2 | +| singleton-comparison | 2 | +| consider-using-f-string | 2 | +| wrong-import-order | 1 | +| no-else-return | 1 | +| missing-module-docstring | 1 | +| invalid-name | 1 | +| f-string-without-interpolation | 1 | + + + + +----------------------------------- +Your code has been rated at 4.18/10 + From 786247ba347cf1c61e17656130fde7aaa0323a8d Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:27 +0300 Subject: [PATCH 078/103] Fix code formatting and documentation issues --- errors_logs/backup.md | 78 ------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 errors_logs/backup.md diff --git a/errors_logs/backup.md b/errors_logs/backup.md deleted file mode 100644 index 75fc26a..0000000 --- a/errors_logs/backup.md +++ /dev/null @@ -1,78 +0,0 @@ -************* Module bettyfixer.backup -bettyfixer/backup.py:12: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/backup.py:13: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/backup.py:14: [C0305(trailing-newlines), ] Trailing newlines -bettyfixer/backup.py:1: [C0114(missing-module-docstring), ] Missing module docstring -bettyfixer/backup.py:3: [C0116(missing-function-docstring), create_backup] Missing function or method docstring -bettyfixer/backup.py:10: [W0718(broad-exception-caught), create_backup] Catching too general exception Exception - - -## Report -====== -**9 statements analysed.** - -Statistics by type ------------------- - -|type |number |old number |difference |%documented |%badname | -|---------|-------|-----------|-----------|------------|---------| -|module |1 |NC |NC |0.00 |0.00 | -|class |0 |NC |NC |0 |0 | -|method |0 |NC |NC |0 |0 | -|function |1 |NC |NC |0.00 |0.00 | - - - -16 lines have been analyzed - -Raw metrics ------------ - -| type | number | % | previous | difference | -|-----------|--------|-------|----------|------------| -| code | 11 | 68.75 | NC | NC | -| docstring | 0 | 0.00 | NC | NC | -| comment | 1 | 6.25 | NC | NC | -| empty | 4 | 25.00 | NC | NC | - - - -Duplication ------------ - -| |now |previous |difference | -|-------------------------|------|---------|-----------| -|nb duplicated lines |0 |NC |NC | -|percent duplicated lines |0.000 |NC |NC | - - - -Messages by category --------------------- - -|type |number |previous |difference | -|-----------|-------|---------|-----------| -|convention |5 |NC |NC | -|refactor |0 |NC |NC | -|warning |1 |NC |NC | -|error |0 |NC |NC | - - - -Messages --------- - -| message id | occurrences | -|---------------------------|-------------| -| trailing-whitespace | 2 | -| trailing-newlines | 1 | -| missing-module-docstring | 1 | -| missing-function-docstring| 1 | -| broad-exception-caught | 1 | - - - - ------------------------------------ -Your code has been rated at 3.33/10 - From 0a14693a7a2a4893da7083ce2b958d4fa54e78f5 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:35 +0300 Subject: [PATCH 079/103] Fix code formatting and documentation issues --- errors_logs/backup.txt | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 errors_logs/backup.txt diff --git a/errors_logs/backup.txt b/errors_logs/backup.txt new file mode 100644 index 0000000..75fc26a --- /dev/null +++ b/errors_logs/backup.txt @@ -0,0 +1,78 @@ +************* Module bettyfixer.backup +bettyfixer/backup.py:12: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/backup.py:13: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/backup.py:14: [C0305(trailing-newlines), ] Trailing newlines +bettyfixer/backup.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/backup.py:3: [C0116(missing-function-docstring), create_backup] Missing function or method docstring +bettyfixer/backup.py:10: [W0718(broad-exception-caught), create_backup] Catching too general exception Exception + + +## Report +====== +**9 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |1 |NC |NC |0.00 |0.00 | + + + +16 lines have been analyzed + +Raw metrics +----------- + +| type | number | % | previous | difference | +|-----------|--------|-------|----------|------------| +| code | 11 | 68.75 | NC | NC | +| docstring | 0 | 0.00 | NC | NC | +| comment | 1 | 6.25 | NC | NC | +| empty | 4 | 25.00 | NC | NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |5 |NC |NC | +|refactor |0 |NC |NC | +|warning |1 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +| message id | occurrences | +|---------------------------|-------------| +| trailing-whitespace | 2 | +| trailing-newlines | 1 | +| missing-module-docstring | 1 | +| missing-function-docstring| 1 | +| broad-exception-caught | 1 | + + + + +----------------------------------- +Your code has been rated at 3.33/10 + From f992e96ac9173cb073db95405f7bd449ea852cd7 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:41 +0300 Subject: [PATCH 080/103] Update user authentication logic*** --- errors_logs/betty_fixer.md | 168 ------------------------------------- 1 file changed, 168 deletions(-) delete mode 100644 errors_logs/betty_fixer.md diff --git a/errors_logs/betty_fixer.md b/errors_logs/betty_fixer.md deleted file mode 100644 index 5167a52..0000000 --- a/errors_logs/betty_fixer.md +++ /dev/null @@ -1,168 +0,0 @@ -************* Module bettyfixer.betty_fixer -bettyfixer/betty_fixer.py:29: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/betty_fixer.py:117: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/betty_fixer.py:177: [C0301(line-too-long), ] Line too long (115/100) -bettyfixer/betty_fixer.py:208: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/betty_fixer.py:258: [C0301(line-too-long), ] Line too long (136/100) -bettyfixer/betty_fixer.py:273: [C0301(line-too-long), ] Line too long (130/100) -bettyfixer/betty_fixer.py:277: [C0301(line-too-long), ] Line too long (109/100) -bettyfixer/betty_fixer.py:303: [C0325(superfluous-parens), ] Unnecessary parens after 'if' keyword -bettyfixer/betty_fixer.py:330: [C0304(missing-final-newline), ] Final newline missing -bettyfixer/betty_fixer.py:1: [C0114(missing-module-docstring), ] Missing module docstring -bettyfixer/betty_fixer.py:4: [W0401(wildcard-import), ] Wildcard import bettyfixer.backup -bettyfixer/betty_fixer.py:5: [W0401(wildcard-import), ] Wildcard import bettyfixer.errors_extractor -bettyfixer/betty_fixer.py:6: [W0401(wildcard-import), ] Wildcard import bettyfixer.extract_line -bettyfixer/betty_fixer.py:7: [W0401(wildcard-import), ] Wildcard import bettyfixer.autoprototype -bettyfixer/betty_fixer.py:11: [C0116(missing-function-docstring), read_file] Missing function or method docstring -bettyfixer/betty_fixer.py:11: [W0621(redefined-outer-name), read_file] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:12: [W1514(unspecified-encoding), read_file] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:16: [C0116(missing-function-docstring), write_file] Missing function or method docstring -bettyfixer/betty_fixer.py:16: [W0621(redefined-outer-name), write_file] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:17: [W1514(unspecified-encoding), write_file] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:20: [C0116(missing-function-docstring), add_line_without_newline] Missing function or method docstring -bettyfixer/betty_fixer.py:20: [W0621(redefined-outer-name), add_line_without_newline] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:22: [W1514(unspecified-encoding), add_line_without_newline] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:27: [W1514(unspecified-encoding), add_line_without_newline] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:30: [C0116(missing-function-docstring), remove_consecutive_blank_lines] Missing function or method docstring -bettyfixer/betty_fixer.py:34: [C0116(missing-function-docstring), add_parentheses_around_return] Missing function or method docstring -bettyfixer/betty_fixer.py:48: [C0116(missing-function-docstring), fix_comments] Missing function or method docstring -bettyfixer/betty_fixer.py:52: [C0116(missing-function-docstring), remove_trailing_whitespaces] Missing function or method docstring -bettyfixer/betty_fixer.py:57: [C0116(missing-function-docstring), process_errors] Missing function or method docstring -bettyfixer/betty_fixer.py:57: [W0621(redefined-outer-name), process_errors] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:59: [W0621(redefined-outer-name), process_errors] Redefining name 'errors_file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:57: [W0613(unused-argument), process_errors] Unused argument 'file_path' -bettyfixer/betty_fixer.py:62: [C0116(missing-function-docstring), fix_betty_warnings] Missing function or method docstring -bettyfixer/betty_fixer.py:62: [W0621(redefined-outer-name), fix_betty_warnings] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:73: [C0116(missing-function-docstring), remove_blank_lines_inside_comments] Missing function or method docstring -bettyfixer/betty_fixer.py:73: [W0621(redefined-outer-name), remove_blank_lines_inside_comments] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:76: [W1514(unspecified-encoding), remove_blank_lines_inside_comments] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:91: [W1514(unspecified-encoding), remove_blank_lines_inside_comments] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:80: [R1702(too-many-nested-blocks), remove_blank_lines_inside_comments] Too many nested blocks (6/5) -bettyfixer/betty_fixer.py:94: [C0116(missing-function-docstring), fix_betty_style] Missing function or method docstring -bettyfixer/betty_fixer.py:95: [W0621(redefined-outer-name), fix_betty_style] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:111: [W0621(redefined-outer-name), fix_betty_style] Redefining name 'errors_file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:115: [W1514(unspecified-encoding), fix_betty_style] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:121: [W1514(unspecified-encoding), fix_betty_style] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:141: [C0116(missing-function-docstring), More_than_5_functions_in_the_file] Missing function or method docstring -bettyfixer/betty_fixer.py:141: [C0103(invalid-name), More_than_5_functions_in_the_file] Function name "More_than_5_functions_in_the_file" doesn't conform to snake_case naming style -bettyfixer/betty_fixer.py:141: [R0914(too-many-locals), More_than_5_functions_in_the_file] Too many local variables (17/15) -bettyfixer/betty_fixer.py:141: [W0621(redefined-outer-name), More_than_5_functions_in_the_file] Redefining name 'errors_file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:156: [W0621(redefined-outer-name), More_than_5_functions_in_the_file] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:148: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:158: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:182: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:185: [R1732(consider-using-with), More_than_5_functions_in_the_file] Consider using 'with' for resource-allocating operations -bettyfixer/betty_fixer.py:185: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:193: [C0116(missing-function-docstring), find_available_file_name] Missing function or method docstring -bettyfixer/betty_fixer.py:204: [C0116(missing-function-docstring), copy_remaining_lines] Missing function or method docstring -bettyfixer/betty_fixer.py:206: [W1514(unspecified-encoding), copy_remaining_lines] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:210: [C0116(missing-function-docstring), betty_handler] Missing function or method docstring -bettyfixer/betty_fixer.py:210: [W0621(redefined-outer-name), betty_handler] Redefining name 'errors_file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:225: [W0621(redefined-outer-name), betty_handler] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:211: [W1514(unspecified-encoding), betty_handler] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:228: [C0116(missing-function-docstring), other_handlers] Missing function or method docstring -bettyfixer/betty_fixer.py:228: [W0621(redefined-outer-name), other_handlers] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:229: [W0621(redefined-outer-name), other_handlers] Redefining name 'errors_file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:243: [C0116(missing-function-docstring), create_tasks_directory] Missing function or method docstring -bettyfixer/betty_fixer.py:248: [C0116(missing-function-docstring), copy_files_to_tasks] Missing function or method docstring -bettyfixer/betty_fixer.py:250: [W0621(redefined-outer-name), copy_files_to_tasks] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:254: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:261: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:265: [C0116(missing-function-docstring), modify_main_files] Missing function or method docstring -bettyfixer/betty_fixer.py:267: [W0621(redefined-outer-name), modify_main_files] Redefining name 'file_path' from outer scope (line 5) -bettyfixer/betty_fixer.py:269: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:276: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:280: [C0116(missing-function-docstring), record_processed_file] Missing function or method docstring -bettyfixer/betty_fixer.py:281: [W1514(unspecified-encoding), record_processed_file] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:284: [C0116(missing-function-docstring), is_file_processed] Missing function or method docstring -bettyfixer/betty_fixer.py:288: [W1514(unspecified-encoding), is_file_processed] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:292: [C0116(missing-function-docstring), main] Missing function or method docstring -bettyfixer/betty_fixer.py:303: [C0121(singleton-comparison), main] Comparison 'v == False' should be 'v is False' if checking for the singleton value False, or 'not v' if testing for falsiness -bettyfixer/betty_fixer.py:318: [R1732(consider-using-with), main] Consider using 'with' for resource-allocating operations -bettyfixer/betty_fixer.py:318: [W1514(unspecified-encoding), main] Using open without explicitly specifying an encoding -bettyfixer/betty_fixer.py:4: [W0614(unused-wildcard-import), ] Unused import(s) shutil from wildcard import of bettyfixer.backup -bettyfixer/betty_fixer.py:5: [W0614(unused-wildcard-import), ] Unused import(s) subprocess, errors_file_path and file_path from wildcard import of bettyfixer.errors_extractor -bettyfixer/betty_fixer.py:6: [W0614(unused-wildcard-import), ] Unused import(s) clean_up_line, fix_errors_from_file, should_be_void, fix_missing_blank_line_after_declaration, fix_should_be_foo_star_star_bar, fix_lines_in_file, generate_documentation, fix_space_prohibited_between_function_name_and_open_parenthesis, fix_space_prohibited_after_that_open_parenthesis, fix_space_prohibited_before_that_close_parenthesis, fix_space_required_before_the_open_parenthesis, fix_brace_on_the_next_line, brace_go_next_line, fix_brace_on_the_previous_line, fix_space_prohibited_before_semicolon, fix_should_be_foo_star_bar, fix_spaces_prohibited_around_that, fix_space_prohibited_after_that, fix_space_prohibited_before_that, fix_spaces_preferred_around_that, fix_space_required_around_that, fix_space_required_after_that, fix_space_required_before_the_open_brace and fix_space_required_after_the_close_brace from wildcard import of bettyfixer.extract_line -bettyfixer/betty_fixer.py:7: [W0614(unused-wildcard-import), ] Unused import(s) argparse, glob, print_Ctags_header_error, check_ctags, generate_tags, filter_tags, create_header, delete_files, check_header_file and Fore from wildcard import of bettyfixer.autoprototype - - - ## Report -====== -**210 statements analysed.** - -Statistics by type ------------------- - -|type |number |old number |difference |%documented |%badname | -|---------|-------|-----------|-----------|------------|---------| -|module |1 |NC |NC |0.00 |0.00 | -|class |0 |NC |NC |0 |0 | -|method |0 |NC |NC |0 |0 | -|function |22 |NC |NC |0.00 |4.55 | - - - -**332 lines have been analyzed** - -Raw metrics ------------ - -|type |number |% |previous |difference | -|----------|-------|------|---------|-----------| -|code |215 |64.76 |NC |NC | -|docstring |1 |0.30 |NC |NC | -|comment |50 |15.06 |NC |NC | -|empty |66 |19.88 |NC |NC | - - - -Duplication ------------ - -| |now |previous |difference | -|-------------------------|------|---------|-----------| -|nb duplicated lines |0 |NC |NC | -|percent duplicated lines |0.000 |NC |NC | - - - -Messages by category --------------------- - -|type |number |previous |difference | -|-----------|-------|---------|-----------| -|convention |34 |NC |NC | -|refactor |4 |NC |NC | -|warning |47 |NC |NC | -|error |0 |NC |NC | - - - -Messages --------- - -| message id | occurrences | -|---------------------------|-------------| -| missing-function-docstring| 22 | -| unspecified-encoding | 21 | -| redefined-outer-name | 17 | -| wildcard-import | 4 | -| unused-wildcard-import | 4 | -| line-too-long | 4 | -| trailing-whitespace | 3 | -| consider-using-with | 2 | -| unused-argument | 1 | -| too-many-nested-blocks | 1 | -| too-many-locals | 1 | -| superfluous-parens | 1 | -| singleton-comparison | 1 | -| missing-module-docstring | 1 | -| missing-final-newline | 1 | -| invalid-name | 1 | - - - - ------------------------------------ -Your code has been rated at 5.95/10 - From 5cc013859b55bd5bf1958f4ebd11054891559652 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:50 +0300 Subject: [PATCH 081/103] Refactor function to improve performance*** ***Add error handling for null values*** ***Update variable names for clarity*** ***Fix bug in conditional statement*** ***Update comments for better documentation*** ***Remove unused imports*** ***Optimize database query*** ***Update README with new instructions*** ***Fix formatting issues*** ***Add unit tests for new feature --- errors_logs/betty_fixer.txt | 168 ++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 errors_logs/betty_fixer.txt diff --git a/errors_logs/betty_fixer.txt b/errors_logs/betty_fixer.txt new file mode 100644 index 0000000..5167a52 --- /dev/null +++ b/errors_logs/betty_fixer.txt @@ -0,0 +1,168 @@ +************* Module bettyfixer.betty_fixer +bettyfixer/betty_fixer.py:29: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/betty_fixer.py:117: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/betty_fixer.py:177: [C0301(line-too-long), ] Line too long (115/100) +bettyfixer/betty_fixer.py:208: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/betty_fixer.py:258: [C0301(line-too-long), ] Line too long (136/100) +bettyfixer/betty_fixer.py:273: [C0301(line-too-long), ] Line too long (130/100) +bettyfixer/betty_fixer.py:277: [C0301(line-too-long), ] Line too long (109/100) +bettyfixer/betty_fixer.py:303: [C0325(superfluous-parens), ] Unnecessary parens after 'if' keyword +bettyfixer/betty_fixer.py:330: [C0304(missing-final-newline), ] Final newline missing +bettyfixer/betty_fixer.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/betty_fixer.py:4: [W0401(wildcard-import), ] Wildcard import bettyfixer.backup +bettyfixer/betty_fixer.py:5: [W0401(wildcard-import), ] Wildcard import bettyfixer.errors_extractor +bettyfixer/betty_fixer.py:6: [W0401(wildcard-import), ] Wildcard import bettyfixer.extract_line +bettyfixer/betty_fixer.py:7: [W0401(wildcard-import), ] Wildcard import bettyfixer.autoprototype +bettyfixer/betty_fixer.py:11: [C0116(missing-function-docstring), read_file] Missing function or method docstring +bettyfixer/betty_fixer.py:11: [W0621(redefined-outer-name), read_file] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:12: [W1514(unspecified-encoding), read_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:16: [C0116(missing-function-docstring), write_file] Missing function or method docstring +bettyfixer/betty_fixer.py:16: [W0621(redefined-outer-name), write_file] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:17: [W1514(unspecified-encoding), write_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:20: [C0116(missing-function-docstring), add_line_without_newline] Missing function or method docstring +bettyfixer/betty_fixer.py:20: [W0621(redefined-outer-name), add_line_without_newline] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:22: [W1514(unspecified-encoding), add_line_without_newline] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:27: [W1514(unspecified-encoding), add_line_without_newline] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:30: [C0116(missing-function-docstring), remove_consecutive_blank_lines] Missing function or method docstring +bettyfixer/betty_fixer.py:34: [C0116(missing-function-docstring), add_parentheses_around_return] Missing function or method docstring +bettyfixer/betty_fixer.py:48: [C0116(missing-function-docstring), fix_comments] Missing function or method docstring +bettyfixer/betty_fixer.py:52: [C0116(missing-function-docstring), remove_trailing_whitespaces] Missing function or method docstring +bettyfixer/betty_fixer.py:57: [C0116(missing-function-docstring), process_errors] Missing function or method docstring +bettyfixer/betty_fixer.py:57: [W0621(redefined-outer-name), process_errors] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:59: [W0621(redefined-outer-name), process_errors] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:57: [W0613(unused-argument), process_errors] Unused argument 'file_path' +bettyfixer/betty_fixer.py:62: [C0116(missing-function-docstring), fix_betty_warnings] Missing function or method docstring +bettyfixer/betty_fixer.py:62: [W0621(redefined-outer-name), fix_betty_warnings] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:73: [C0116(missing-function-docstring), remove_blank_lines_inside_comments] Missing function or method docstring +bettyfixer/betty_fixer.py:73: [W0621(redefined-outer-name), remove_blank_lines_inside_comments] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:76: [W1514(unspecified-encoding), remove_blank_lines_inside_comments] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:91: [W1514(unspecified-encoding), remove_blank_lines_inside_comments] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:80: [R1702(too-many-nested-blocks), remove_blank_lines_inside_comments] Too many nested blocks (6/5) +bettyfixer/betty_fixer.py:94: [C0116(missing-function-docstring), fix_betty_style] Missing function or method docstring +bettyfixer/betty_fixer.py:95: [W0621(redefined-outer-name), fix_betty_style] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:111: [W0621(redefined-outer-name), fix_betty_style] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:115: [W1514(unspecified-encoding), fix_betty_style] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:121: [W1514(unspecified-encoding), fix_betty_style] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:141: [C0116(missing-function-docstring), More_than_5_functions_in_the_file] Missing function or method docstring +bettyfixer/betty_fixer.py:141: [C0103(invalid-name), More_than_5_functions_in_the_file] Function name "More_than_5_functions_in_the_file" doesn't conform to snake_case naming style +bettyfixer/betty_fixer.py:141: [R0914(too-many-locals), More_than_5_functions_in_the_file] Too many local variables (17/15) +bettyfixer/betty_fixer.py:141: [W0621(redefined-outer-name), More_than_5_functions_in_the_file] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:156: [W0621(redefined-outer-name), More_than_5_functions_in_the_file] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:148: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:158: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:182: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:185: [R1732(consider-using-with), More_than_5_functions_in_the_file] Consider using 'with' for resource-allocating operations +bettyfixer/betty_fixer.py:185: [W1514(unspecified-encoding), More_than_5_functions_in_the_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:193: [C0116(missing-function-docstring), find_available_file_name] Missing function or method docstring +bettyfixer/betty_fixer.py:204: [C0116(missing-function-docstring), copy_remaining_lines] Missing function or method docstring +bettyfixer/betty_fixer.py:206: [W1514(unspecified-encoding), copy_remaining_lines] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:210: [C0116(missing-function-docstring), betty_handler] Missing function or method docstring +bettyfixer/betty_fixer.py:210: [W0621(redefined-outer-name), betty_handler] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:225: [W0621(redefined-outer-name), betty_handler] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:211: [W1514(unspecified-encoding), betty_handler] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:228: [C0116(missing-function-docstring), other_handlers] Missing function or method docstring +bettyfixer/betty_fixer.py:228: [W0621(redefined-outer-name), other_handlers] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:229: [W0621(redefined-outer-name), other_handlers] Redefining name 'errors_file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:243: [C0116(missing-function-docstring), create_tasks_directory] Missing function or method docstring +bettyfixer/betty_fixer.py:248: [C0116(missing-function-docstring), copy_files_to_tasks] Missing function or method docstring +bettyfixer/betty_fixer.py:250: [W0621(redefined-outer-name), copy_files_to_tasks] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:254: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:261: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:265: [C0116(missing-function-docstring), modify_main_files] Missing function or method docstring +bettyfixer/betty_fixer.py:267: [W0621(redefined-outer-name), modify_main_files] Redefining name 'file_path' from outer scope (line 5) +bettyfixer/betty_fixer.py:269: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:276: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:280: [C0116(missing-function-docstring), record_processed_file] Missing function or method docstring +bettyfixer/betty_fixer.py:281: [W1514(unspecified-encoding), record_processed_file] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:284: [C0116(missing-function-docstring), is_file_processed] Missing function or method docstring +bettyfixer/betty_fixer.py:288: [W1514(unspecified-encoding), is_file_processed] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:292: [C0116(missing-function-docstring), main] Missing function or method docstring +bettyfixer/betty_fixer.py:303: [C0121(singleton-comparison), main] Comparison 'v == False' should be 'v is False' if checking for the singleton value False, or 'not v' if testing for falsiness +bettyfixer/betty_fixer.py:318: [R1732(consider-using-with), main] Consider using 'with' for resource-allocating operations +bettyfixer/betty_fixer.py:318: [W1514(unspecified-encoding), main] Using open without explicitly specifying an encoding +bettyfixer/betty_fixer.py:4: [W0614(unused-wildcard-import), ] Unused import(s) shutil from wildcard import of bettyfixer.backup +bettyfixer/betty_fixer.py:5: [W0614(unused-wildcard-import), ] Unused import(s) subprocess, errors_file_path and file_path from wildcard import of bettyfixer.errors_extractor +bettyfixer/betty_fixer.py:6: [W0614(unused-wildcard-import), ] Unused import(s) clean_up_line, fix_errors_from_file, should_be_void, fix_missing_blank_line_after_declaration, fix_should_be_foo_star_star_bar, fix_lines_in_file, generate_documentation, fix_space_prohibited_between_function_name_and_open_parenthesis, fix_space_prohibited_after_that_open_parenthesis, fix_space_prohibited_before_that_close_parenthesis, fix_space_required_before_the_open_parenthesis, fix_brace_on_the_next_line, brace_go_next_line, fix_brace_on_the_previous_line, fix_space_prohibited_before_semicolon, fix_should_be_foo_star_bar, fix_spaces_prohibited_around_that, fix_space_prohibited_after_that, fix_space_prohibited_before_that, fix_spaces_preferred_around_that, fix_space_required_around_that, fix_space_required_after_that, fix_space_required_before_the_open_brace and fix_space_required_after_the_close_brace from wildcard import of bettyfixer.extract_line +bettyfixer/betty_fixer.py:7: [W0614(unused-wildcard-import), ] Unused import(s) argparse, glob, print_Ctags_header_error, check_ctags, generate_tags, filter_tags, create_header, delete_files, check_header_file and Fore from wildcard import of bettyfixer.autoprototype + + + ## Report +====== +**210 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |22 |NC |NC |0.00 |4.55 | + + + +**332 lines have been analyzed** + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |215 |64.76 |NC |NC | +|docstring |1 |0.30 |NC |NC | +|comment |50 |15.06 |NC |NC | +|empty |66 |19.88 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |34 |NC |NC | +|refactor |4 |NC |NC | +|warning |47 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +| message id | occurrences | +|---------------------------|-------------| +| missing-function-docstring| 22 | +| unspecified-encoding | 21 | +| redefined-outer-name | 17 | +| wildcard-import | 4 | +| unused-wildcard-import | 4 | +| line-too-long | 4 | +| trailing-whitespace | 3 | +| consider-using-with | 2 | +| unused-argument | 1 | +| too-many-nested-blocks | 1 | +| too-many-locals | 1 | +| superfluous-parens | 1 | +| singleton-comparison | 1 | +| missing-module-docstring | 1 | +| missing-final-newline | 1 | +| invalid-name | 1 | + + + + +----------------------------------- +Your code has been rated at 5.95/10 + From 4ffff45251c6ea6abe87198a4a8af11f62cedb7f Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:58 +0300 Subject: [PATCH 082/103] Fix code style issues and remove unused files --- errors_logs/betty_handler.md | 84 ----------- errors_logs/errors_exractor.md | 86 ------------ errors_logs/extract_line.md | 247 --------------------------------- 3 files changed, 417 deletions(-) delete mode 100644 errors_logs/betty_handler.md delete mode 100644 errors_logs/errors_exractor.md delete mode 100644 errors_logs/extract_line.md diff --git a/errors_logs/betty_handler.md b/errors_logs/betty_handler.md deleted file mode 100644 index 6611154..0000000 --- a/errors_logs/betty_handler.md +++ /dev/null @@ -1,84 +0,0 @@ -************* Module bettyfixer.betty_handler -bettyfixer/betty_handler.py:24: [C0301(line-too-long), ] Line too long (136/100) -bettyfixer/betty_handler.py:38: [C0301(line-too-long), ] Line too long (130/100) -bettyfixer/betty_handler.py:42: [C0301(line-too-long), ] Line too long (109/100) -bettyfixer/betty_handler.py:1: [C0114(missing-module-docstring), ] Missing module docstring -bettyfixer/betty_handler.py:4: [C0116(missing-function-docstring), other_handler] Missing function or method docstring -bettyfixer/betty_handler.py:9: [C0116(missing-function-docstring), create_tasks_directory] Missing function or method docstring -bettyfixer/betty_handler.py:14: [C0116(missing-function-docstring), copy_files_to_tasks] Missing function or method docstring -bettyfixer/betty_handler.py:20: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding -bettyfixer/betty_handler.py:27: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding -bettyfixer/betty_handler.py:30: [C0116(missing-function-docstring), modify_main_files] Missing function or method docstring -bettyfixer/betty_handler.py:34: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding -bettyfixer/betty_handler.py:41: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding - - -Report ------- -33 statements analysed. - -Statistics by type ------------------- - -|type |number |old number |difference |%documented |%badname | -|---------|-------|-----------|-----------|------------|---------| -|module |1 |NC |NC |0.00 |0.00 | -|class |0 |NC |NC |0 |0 | -|method |0 |NC |NC |0 |0 | -|function |4 |NC |NC |0.00 |0.00 | - -
- - -**61 lines have been analyzed** - -**Raw metrics** ------------ - -|type |number |% |previous |difference | -|----------|-------|------|---------|-----------| -|code |35 |57.38 |NC |NC | -|docstring |0 |0.00 |NC |NC | -|comment |13 |21.31 |NC |NC | -|empty |13 |21.31 |NC |NC | - -
- -Duplication ------------ - -| |now |previous |difference | -|-------------------------|------|---------|-----------| -|nb duplicated lines |0 |NC |NC | -|percent duplicated lines |0.000 |NC |NC | - - - -Messages by category --------------------- - -|type |number |previous |difference | -|-----------|-------|---------|-----------| -|convention |8 |NC |NC | -|refactor |0 |NC |NC | -|warning |4 |NC |NC | -|error |0 |NC |NC | - - - -Messages --------- - -|message id |occurrences | -|---------------------------|------------| -|unspecified-encoding |4 | -|missing-function-docstring |4 | -|line-too-long |3 | -|missing-module-docstring |1 | - - -
- ------------------------------------ -Your code has been rated at 6.36/10 - diff --git a/errors_logs/errors_exractor.md b/errors_logs/errors_exractor.md deleted file mode 100644 index 9065d34..0000000 --- a/errors_logs/errors_exractor.md +++ /dev/null @@ -1,86 +0,0 @@ -************* Module bettyfixer.errors_extractor -bettyfixer/errors_extractor.py:1: [C0114(missing-module-docstring), ] Missing module docstring -bettyfixer/errors_extractor.py:4: [C0116(missing-function-docstring), exctract_errors] Missing function or method docstring -bettyfixer/errors_extractor.py:4: [W0621(redefined-outer-name), exctract_errors] Redefining name 'file_path' from outer scope (line 36) -bettyfixer/errors_extractor.py:13: [W0621(redefined-outer-name), exctract_errors] Redefining name 'errors_file_path' from outer scope (line 30) -bettyfixer/errors_extractor.py:13: [W1514(unspecified-encoding), exctract_errors] Using open without explicitly specifying an encoding -bettyfixer/errors_extractor.py:17: [W0107(unnecessary-pass), exctract_errors] Unnecessary pass statement -bettyfixer/errors_extractor.py:19: [W1514(unspecified-encoding), exctract_errors] Using open without explicitly specifying an encoding -bettyfixer/errors_extractor.py:30: [C0103(invalid-name), ] Constant name "errors_file_path" doesn't conform to UPPER_CASE naming style -bettyfixer/errors_extractor.py:33: [R1732(consider-using-with), ] Consider using 'with' for resource-allocating operations -bettyfixer/errors_extractor.py:33: [W1514(unspecified-encoding), ] Using open without explicitly specifying an encoding - - -## Report ------- - -**21 statements analysed.** - -Statistics by type ------------------- - -|type |number |old number |difference |%documented |%badname | -|---------|-------|-----------|-----------|------------|---------| -|module |1 |NC |NC |0.00 |0.00 | -|class |0 |NC |NC |0 |0 | -|method |0 |NC |NC |0 |0 | -|function |1 |NC |NC |0.00 |0.00 | - - - -**39 lines have been analyzed** - -Raw metrics ------------ - -|type |number |% |previous |difference | -|----------|-------|------|---------|-----------| -|code |23 |58.97 |NC |NC | -|docstring |0 |0.00 |NC |NC | -|comment |9 |23.08 |NC |NC | -|empty |7 |17.95 |NC |NC | - - - -Duplication ------------ - -| |now |previous |difference | -|-------------------------|------|---------|-----------| -|nb duplicated lines |0 |NC |NC | -|percent duplicated lines |0.000 |NC |NC | - - - -Messages by category --------------------- - -|type |number |previous |difference | -|-----------|-------|---------|-----------| -|convention |3 |NC |NC | -|refactor |1 |NC |NC | -|warning |6 |NC |NC | -|error |0 |NC |NC | - - - -Messages --------- - -|message id |occurrences | -|---------------------------|------------| -|unspecified-encoding |3 | -|redefined-outer-name |2 | -|unnecessary-pass |1 | -|missing-module-docstring |1 | -|missing-function-docstring |1 | -|invalid-name |1 | -|consider-using-with |1 | - -
- - - ------------------------------------ -Your code has been rated at 5.24/10 - diff --git a/errors_logs/extract_line.md b/errors_logs/extract_line.md deleted file mode 100644 index 14ef1c1..0000000 --- a/errors_logs/extract_line.md +++ /dev/null @@ -1,247 +0,0 @@ -************* Module bettyfixer.extract_line -bettyfixer/extract_line.py:31: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:78: [C0301(line-too-long), ] Line too long (122/100) -bettyfixer/extract_line.py:80: [C0301(line-too-long), ] Line too long (107/100) -bettyfixer/extract_line.py:82: [C0301(line-too-long), ] Line too long (109/100) -bettyfixer/extract_line.py:84: [C0301(line-too-long), ] Line too long (105/100) -bettyfixer/extract_line.py:148: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:187: [C0301(line-too-long), ] Line too long (106/100) -bettyfixer/extract_line.py:209: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:259: [C0301(line-too-long), ] Line too long (107/100) -bettyfixer/extract_line.py:262: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 -bettyfixer/extract_line.py:267: [C0301(line-too-long), ] Line too long (102/100) -bettyfixer/extract_line.py:269: [C0301(line-too-long), ] Line too long (122/100) -bettyfixer/extract_line.py:276: [C0301(line-too-long), ] Line too long (180/100) -bettyfixer/extract_line.py:299: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:310: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:323: [C0301(line-too-long), ] Line too long (110/100) -bettyfixer/extract_line.py:327: [C0301(line-too-long), ] Line too long (119/100) -bettyfixer/extract_line.py:333: [C0301(line-too-long), ] Line too long (146/100) -bettyfixer/extract_line.py:341: [C0301(line-too-long), ] Line too long (104/100) -bettyfixer/extract_line.py:359: [C0301(line-too-long), ] Line too long (101/100) -bettyfixer/extract_line.py:361: [C0301(line-too-long), ] Line too long (113/100) -bettyfixer/extract_line.py:368: [C0301(line-too-long), ] Line too long (111/100) -bettyfixer/extract_line.py:382: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:388: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:452: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:504: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:507: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:517: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:519: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:570: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:580: [C0301(line-too-long), ] Line too long (117/100) -bettyfixer/extract_line.py:584: [C0301(line-too-long), ] Line too long (151/100) -bettyfixer/extract_line.py:589: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:649: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:671: [C0325(superfluous-parens), ] Unnecessary parens after 'not' keyword -bettyfixer/extract_line.py:700: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:743: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:784: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:807: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:822: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:834: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:857: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:872: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:884: [C0303(trailing-whitespace), ] Trailing whitespace -bettyfixer/extract_line.py:1: [C0114(missing-module-docstring), ] Missing module docstring -bettyfixer/extract_line.py:7: [C0116(missing-function-docstring), run_vi_script] Missing function or method docstring -bettyfixer/extract_line.py:11: [W1510(subprocess-run-check), run_vi_script] 'subprocess.run' used without explicitly defining the value for 'check'. -bettyfixer/extract_line.py:13: [C0116(missing-function-docstring), remove_extra_spaces] Missing function or method docstring -bettyfixer/extract_line.py:24: [C0116(missing-function-docstring), process_error_file] Missing function or method docstring -bettyfixer/extract_line.py:24: [W0621(redefined-outer-name), process_error_file] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:25: [W1514(unspecified-encoding), process_error_file] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:32: [C0116(missing-function-docstring), extract_and_print_variables] Missing function or method docstring -bettyfixer/extract_line.py:44: [C0116(missing-function-docstring), clean_up_line] Missing function or method docstring -bettyfixer/extract_line.py:53: [C0116(missing-function-docstring), fix_errors_from_file] Missing function or method docstring -bettyfixer/extract_line.py:53: [R0912(too-many-branches), fix_errors_from_file] Too many branches (18/12) -bettyfixer/extract_line.py:110: [C0116(missing-function-docstring), fix_should_be_void] Missing function or method docstring -bettyfixer/extract_line.py:110: [W0621(redefined-outer-name), fix_should_be_void] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:116: [W1514(unspecified-encoding), fix_should_be_void] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:132: [C0116(missing-function-docstring), should_be_void] Missing function or method docstring -bettyfixer/extract_line.py:132: [W0621(redefined-outer-name), should_be_void] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:139: [W1514(unspecified-encoding), should_be_void] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:146: [W1514(unspecified-encoding), should_be_void] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:159: [C0116(missing-function-docstring), clean_errors_file] Missing function or method docstring -bettyfixer/extract_line.py:159: [W0621(redefined-outer-name), clean_errors_file] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:163: [R1732(consider-using-with), clean_errors_file] Consider using 'with' for resource-allocating operations -bettyfixer/extract_line.py:163: [W1514(unspecified-encoding), clean_errors_file] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:169: [C0116(missing-function-docstring), fix_missing_blank_line_after_declarations] Missing function or method docstring -bettyfixer/extract_line.py:169: [W0621(redefined-outer-name), fix_missing_blank_line_after_declarations] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:175: [W1514(unspecified-encoding), fix_missing_blank_line_after_declarations] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:190: [C0116(missing-function-docstring), fix_missing_blank_line_after_declaration] Missing function or method docstring -bettyfixer/extract_line.py:190: [W0621(redefined-outer-name), fix_missing_blank_line_after_declaration] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:195: [W1514(unspecified-encoding), fix_missing_blank_line_after_declaration] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:207: [W1514(unspecified-encoding), fix_missing_blank_line_after_declaration] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:215: [C0116(missing-function-docstring), fix_should_be_foo_star_star_bar] Missing function or method docstring -bettyfixer/extract_line.py:220: [W1514(unspecified-encoding), fix_should_be_foo_star_star_bar] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:227: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:229: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:231: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:233: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:243: [W1514(unspecified-encoding), fix_should_be_foo_star_star_bar] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:246: [C0116(missing-function-docstring), remove_unused_attribute] Missing function or method docstring -bettyfixer/extract_line.py:283: [W0718(broad-exception-caught), remove_unused_attribute] Catching too general exception Exception -bettyfixer/extract_line.py:248: [W1514(unspecified-encoding), remove_unused_attribute] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:279: [W1514(unspecified-encoding), remove_unused_attribute] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:264: [W0612(unused-variable), remove_unused_attribute] Unused variable 'original_declaration' -bettyfixer/extract_line.py:286: [C0116(missing-function-docstring), fix_lines_in_file] Missing function or method docstring -bettyfixer/extract_line.py:308: [W0718(broad-exception-caught), fix_lines_in_file] Catching too general exception Exception -bettyfixer/extract_line.py:288: [W1514(unspecified-encoding), fix_lines_in_file] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:306: [W1514(unspecified-encoding), fix_lines_in_file] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:287: [R1702(too-many-nested-blocks), fix_lines_in_file] Too many nested blocks (6/5) -bettyfixer/extract_line.py:311: [C0116(missing-function-docstring), generate_documentation] Missing function or method docstring -bettyfixer/extract_line.py:352: [C0116(missing-function-docstring), extract_functions_with_no_description] Missing function or method docstring -bettyfixer/extract_line.py:355: [W1514(unspecified-encoding), extract_functions_with_no_description] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:368: [C0116(missing-function-docstring), fix_space_prohibited_between_function_name_and_open_parenthesis] Missing function or method docstring -bettyfixer/extract_line.py:374: [W1514(unspecified-encoding), fix_space_prohibited_between_function_name_and_open_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:387: [W1514(unspecified-encoding), fix_space_prohibited_between_function_name_and_open_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:389: [C0116(missing-function-docstring), fix_space_prohibited_after_that_open_parenthesis] Missing function or method docstring -bettyfixer/extract_line.py:395: [W1514(unspecified-encoding), fix_space_prohibited_after_that_open_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:408: [W1514(unspecified-encoding), fix_space_prohibited_after_that_open_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:410: [C0116(missing-function-docstring), fix_space_prohibited_before_that_close_parenthesis] Missing function or method docstring -bettyfixer/extract_line.py:416: [W1514(unspecified-encoding), fix_space_prohibited_before_that_close_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:429: [W1514(unspecified-encoding), fix_space_prohibited_before_that_close_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:431: [C0116(missing-function-docstring), fix_space_required_before_the_open_parenthesis] Missing function or method docstring -bettyfixer/extract_line.py:437: [W1514(unspecified-encoding), fix_space_required_before_the_open_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:450: [W1514(unspecified-encoding), fix_space_required_before_the_open_parenthesis] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:453: [C0116(missing-function-docstring), fix_brace_should_be_on_the_next_line] Missing function or method docstring -bettyfixer/extract_line.py:453: [W0621(redefined-outer-name), fix_brace_should_be_on_the_next_line] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:459: [W1514(unspecified-encoding), fix_brace_should_be_on_the_next_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:492: [C0116(missing-function-docstring), fix_brace_on_the_next_line] Missing function or method docstring -bettyfixer/extract_line.py:492: [W0621(redefined-outer-name), fix_brace_on_the_next_line] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:497: [W1514(unspecified-encoding), fix_brace_on_the_next_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:509: [W1514(unspecified-encoding), fix_brace_on_the_next_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:520: [C0116(missing-function-docstring), brace_go_next_line] Missing function or method docstring -bettyfixer/extract_line.py:524: [W1514(unspecified-encoding), brace_go_next_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:539: [W1514(unspecified-encoding), brace_go_next_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:542: [C0116(missing-function-docstring), fix_brace_should_be_on_the_previous_line] Missing function or method docstring -bettyfixer/extract_line.py:542: [W0621(redefined-outer-name), fix_brace_should_be_on_the_previous_line] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:548: [W1514(unspecified-encoding), fix_brace_should_be_on_the_previous_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:563: [C0116(missing-function-docstring), fix_brace_on_the_previous_line] Missing function or method docstring -bettyfixer/extract_line.py:563: [W0621(redefined-outer-name), fix_brace_on_the_previous_line] Redefining name 'errors_file_path' from outer scope (line 968) -bettyfixer/extract_line.py:568: [W1514(unspecified-encoding), fix_brace_on_the_previous_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:587: [W1514(unspecified-encoding), fix_brace_on_the_previous_line] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:596: [C0116(missing-function-docstring), fix_space_prohibited_before_semicolon] Missing function or method docstring -bettyfixer/extract_line.py:599: [W1514(unspecified-encoding), fix_space_prohibited_before_semicolon] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:613: [W1514(unspecified-encoding), fix_space_prohibited_before_semicolon] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:615: [C0116(missing-function-docstring), fix_should_be_foo_star_bar] Missing function or method docstring -bettyfixer/extract_line.py:620: [W1514(unspecified-encoding), fix_should_be_foo_star_bar] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:627: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:629: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:631: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:633: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables -bettyfixer/extract_line.py:643: [W1514(unspecified-encoding), fix_should_be_foo_star_bar] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:645: [C0116(missing-function-docstring), fix_spaces_prohibited_around_that] Missing function or method docstring -bettyfixer/extract_line.py:667: [W1514(unspecified-encoding), fix_spaces_prohibited_around_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:693: [W1514(unspecified-encoding), fix_spaces_prohibited_around_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:696: [C0116(missing-function-docstring), fix_space_prohibited_after_that] Missing function or method docstring -bettyfixer/extract_line.py:718: [W1514(unspecified-encoding), fix_space_prohibited_after_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:737: [W1514(unspecified-encoding), fix_space_prohibited_after_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:739: [C0116(missing-function-docstring), fix_space_prohibited_before_that] Missing function or method docstring -bettyfixer/extract_line.py:761: [W1514(unspecified-encoding), fix_space_prohibited_before_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:768: [R1714(consider-using-in), fix_space_prohibited_before_that] Consider merging these comparisons with 'in' by using 'context in ('WxV', 'WxO', 'WxE', 'WxW')'. Use a set instead if elements are hashable. -bettyfixer/extract_line.py:778: [W1514(unspecified-encoding), fix_space_prohibited_before_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:780: [C0116(missing-function-docstring), fix_spaces_preferred_around_that] Missing function or method docstring -bettyfixer/extract_line.py:802: [W1514(unspecified-encoding), fix_spaces_preferred_around_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:828: [W1514(unspecified-encoding), fix_spaces_preferred_around_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:830: [C0116(missing-function-docstring), fix_space_required_around_that] Missing function or method docstring -bettyfixer/extract_line.py:852: [W1514(unspecified-encoding), fix_space_required_around_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:878: [W1514(unspecified-encoding), fix_space_required_around_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:880: [C0116(missing-function-docstring), fix_space_required_after_that] Missing function or method docstring -bettyfixer/extract_line.py:902: [W1514(unspecified-encoding), fix_space_required_after_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:909: [R1714(consider-using-in), fix_space_required_after_that] Consider merging these comparisons with 'in' by using 'context in ('WxV', 'VxV')'. Use a set instead if elements are hashable. -bettyfixer/extract_line.py:919: [W1514(unspecified-encoding), fix_space_required_after_that] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:921: [C0116(missing-function-docstring), fix_space_required_before_the_open_brace] Missing function or method docstring -bettyfixer/extract_line.py:927: [W1514(unspecified-encoding), fix_space_required_before_the_open_brace] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:940: [W1514(unspecified-encoding), fix_space_required_before_the_open_brace] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:942: [C0116(missing-function-docstring), fix_space_required_after_the_close_brace] Missing function or method docstring -bettyfixer/extract_line.py:948: [W1514(unspecified-encoding), fix_space_required_after_the_close_brace] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:961: [W1514(unspecified-encoding), fix_space_required_after_the_close_brace] Using open without explicitly specifying an encoding -bettyfixer/extract_line.py:968: [C0103(invalid-name), ] Constant name "errors_file_path" doesn't conform to UPPER_CASE naming style -bettyfixer/extract_line.py:4: [C0411(wrong-import-order), ] standard import "import os" should be placed before "from bettyfixer.errors_extractor import exctract_errors" -bettyfixer/extract_line.py:5: [C0411(wrong-import-order), ] standard import "import subprocess" should be placed before "from bettyfixer.errors_extractor import exctract_errors" - - - ## Report - -**522 statements analysed.** - -Statistics by type ------------------- - -| type | number | old number | difference | %documented | %badname | -|----------|--------|------------|------------|-------------|----------| -| module | 1 | 1 | = | 0.00 | 0.00 | -| class | 0 | NC | NC | 0 | 0 | -| method | 0 | NC | NC | 0 | 0 | -| function | 35 | 35 | = | 0.00 | 0.00 | - - -**971 lines have been analyzed** - -Raw metrics ------------ - -|type |number |% |previous |difference | -|----------|-------|------|---------|-----------| -|code |536 |55.20 |NC |NC | -|docstring |16 |1.65 |NC |NC | -|comment |206 |21.22 |NC |NC | -|empty |213 |21.94 |NC |NC | - - - -Duplication ------------ - -| |now |previous |difference | -|-------------------------|------|---------|-----------| -|nb duplicated lines |0 |0 |0 | -|percent duplicated lines |0.000 |0.000 |= | - - - -Messages by category --------------------- - -|type |number |previous |difference | -|-----------|-------|---------|-----------| -|convention |82 |82 |82 | -|refactor |5 |5 |5 | -|warning |74 |74 |74 | -|error |0 |0 |0 | - - - -Messages --------- - - -| message id | occurrences | -|------------------------------- | ------------| -| unspecified-encoding | 51 | -| missing-function-docstring | 35 | -| trailing-whitespace | 24 | -| line-too-long | 18 | -| redefined-outer-name | 10 | -| f-string-without-interpolation | 8 | -| wrong-import-order | 2 | -| consider-using-in | 2 | -| broad-exception-caught | 2 | -| unused-variable | 1 | -| too-many-nested-blocks | 1 | -| too-many-branches | 1 | -| superfluous-parens | 1 | -| subprocess-run-check | 1 | -| missing-module-docstring | 1 | -| invalid-name | 1 | -| consider-using-with | 1 | -| bad-indentation | 1 | - - - - - ------------------------------------------------------------------- -Your code has been rated at 6.92/10 (previous run: 6.92/10, +0.00) - From da6c7261e9447b2a4ab13fec9572d7ece254c84e Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:34:02 +0300 Subject: [PATCH 083/103] Fix code style issues and add missing docstrings --- errors_logs/betty_handler.txt | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 errors_logs/betty_handler.txt diff --git a/errors_logs/betty_handler.txt b/errors_logs/betty_handler.txt new file mode 100644 index 0000000..6611154 --- /dev/null +++ b/errors_logs/betty_handler.txt @@ -0,0 +1,84 @@ +************* Module bettyfixer.betty_handler +bettyfixer/betty_handler.py:24: [C0301(line-too-long), ] Line too long (136/100) +bettyfixer/betty_handler.py:38: [C0301(line-too-long), ] Line too long (130/100) +bettyfixer/betty_handler.py:42: [C0301(line-too-long), ] Line too long (109/100) +bettyfixer/betty_handler.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/betty_handler.py:4: [C0116(missing-function-docstring), other_handler] Missing function or method docstring +bettyfixer/betty_handler.py:9: [C0116(missing-function-docstring), create_tasks_directory] Missing function or method docstring +bettyfixer/betty_handler.py:14: [C0116(missing-function-docstring), copy_files_to_tasks] Missing function or method docstring +bettyfixer/betty_handler.py:20: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_handler.py:27: [W1514(unspecified-encoding), copy_files_to_tasks] Using open without explicitly specifying an encoding +bettyfixer/betty_handler.py:30: [C0116(missing-function-docstring), modify_main_files] Missing function or method docstring +bettyfixer/betty_handler.py:34: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding +bettyfixer/betty_handler.py:41: [W1514(unspecified-encoding), modify_main_files] Using open without explicitly specifying an encoding + + +Report +------ +33 statements analysed. + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |4 |NC |NC |0.00 |0.00 | + +
+ + +**61 lines have been analyzed** + +**Raw metrics** +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |35 |57.38 |NC |NC | +|docstring |0 |0.00 |NC |NC | +|comment |13 |21.31 |NC |NC | +|empty |13 |21.31 |NC |NC | + +
+ +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |8 |NC |NC | +|refactor |0 |NC |NC | +|warning |4 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +|message id |occurrences | +|---------------------------|------------| +|unspecified-encoding |4 | +|missing-function-docstring |4 | +|line-too-long |3 | +|missing-module-docstring |1 | + + +
+ +----------------------------------- +Your code has been rated at 6.36/10 + From b2d3d12f2936f8b78663948b3287dd08ec438cd3 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:34:06 +0300 Subject: [PATCH 084/103] Fix errors and improve code quality --- errors_logs/errors_exractor.txt | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 errors_logs/errors_exractor.txt diff --git a/errors_logs/errors_exractor.txt b/errors_logs/errors_exractor.txt new file mode 100644 index 0000000..9065d34 --- /dev/null +++ b/errors_logs/errors_exractor.txt @@ -0,0 +1,86 @@ +************* Module bettyfixer.errors_extractor +bettyfixer/errors_extractor.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/errors_extractor.py:4: [C0116(missing-function-docstring), exctract_errors] Missing function or method docstring +bettyfixer/errors_extractor.py:4: [W0621(redefined-outer-name), exctract_errors] Redefining name 'file_path' from outer scope (line 36) +bettyfixer/errors_extractor.py:13: [W0621(redefined-outer-name), exctract_errors] Redefining name 'errors_file_path' from outer scope (line 30) +bettyfixer/errors_extractor.py:13: [W1514(unspecified-encoding), exctract_errors] Using open without explicitly specifying an encoding +bettyfixer/errors_extractor.py:17: [W0107(unnecessary-pass), exctract_errors] Unnecessary pass statement +bettyfixer/errors_extractor.py:19: [W1514(unspecified-encoding), exctract_errors] Using open without explicitly specifying an encoding +bettyfixer/errors_extractor.py:30: [C0103(invalid-name), ] Constant name "errors_file_path" doesn't conform to UPPER_CASE naming style +bettyfixer/errors_extractor.py:33: [R1732(consider-using-with), ] Consider using 'with' for resource-allocating operations +bettyfixer/errors_extractor.py:33: [W1514(unspecified-encoding), ] Using open without explicitly specifying an encoding + + +## Report +------ + +**21 statements analysed.** + +Statistics by type +------------------ + +|type |number |old number |difference |%documented |%badname | +|---------|-------|-----------|-----------|------------|---------| +|module |1 |NC |NC |0.00 |0.00 | +|class |0 |NC |NC |0 |0 | +|method |0 |NC |NC |0 |0 | +|function |1 |NC |NC |0.00 |0.00 | + + + +**39 lines have been analyzed** + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |23 |58.97 |NC |NC | +|docstring |0 |0.00 |NC |NC | +|comment |9 |23.08 |NC |NC | +|empty |7 |17.95 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |NC |NC | +|percent duplicated lines |0.000 |NC |NC | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |3 |NC |NC | +|refactor |1 |NC |NC | +|warning |6 |NC |NC | +|error |0 |NC |NC | + + + +Messages +-------- + +|message id |occurrences | +|---------------------------|------------| +|unspecified-encoding |3 | +|redefined-outer-name |2 | +|unnecessary-pass |1 | +|missing-module-docstring |1 | +|missing-function-docstring |1 | +|invalid-name |1 | +|consider-using-with |1 | + +
+ + + +----------------------------------- +Your code has been rated at 5.24/10 + From 31db32f0de5d5be6665c150184f19677a5f1f367 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:35:35 +0300 Subject: [PATCH 085/103] Refactor code for improved performance and readability --- errors_logs/extract_line.txt | 247 +++++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 errors_logs/extract_line.txt diff --git a/errors_logs/extract_line.txt b/errors_logs/extract_line.txt new file mode 100644 index 0000000..14ef1c1 --- /dev/null +++ b/errors_logs/extract_line.txt @@ -0,0 +1,247 @@ +************* Module bettyfixer.extract_line +bettyfixer/extract_line.py:31: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:78: [C0301(line-too-long), ] Line too long (122/100) +bettyfixer/extract_line.py:80: [C0301(line-too-long), ] Line too long (107/100) +bettyfixer/extract_line.py:82: [C0301(line-too-long), ] Line too long (109/100) +bettyfixer/extract_line.py:84: [C0301(line-too-long), ] Line too long (105/100) +bettyfixer/extract_line.py:148: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:187: [C0301(line-too-long), ] Line too long (106/100) +bettyfixer/extract_line.py:209: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:259: [C0301(line-too-long), ] Line too long (107/100) +bettyfixer/extract_line.py:262: [W0311(bad-indentation), ] Bad indentation. Found 16 spaces, expected 12 +bettyfixer/extract_line.py:267: [C0301(line-too-long), ] Line too long (102/100) +bettyfixer/extract_line.py:269: [C0301(line-too-long), ] Line too long (122/100) +bettyfixer/extract_line.py:276: [C0301(line-too-long), ] Line too long (180/100) +bettyfixer/extract_line.py:299: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:310: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:323: [C0301(line-too-long), ] Line too long (110/100) +bettyfixer/extract_line.py:327: [C0301(line-too-long), ] Line too long (119/100) +bettyfixer/extract_line.py:333: [C0301(line-too-long), ] Line too long (146/100) +bettyfixer/extract_line.py:341: [C0301(line-too-long), ] Line too long (104/100) +bettyfixer/extract_line.py:359: [C0301(line-too-long), ] Line too long (101/100) +bettyfixer/extract_line.py:361: [C0301(line-too-long), ] Line too long (113/100) +bettyfixer/extract_line.py:368: [C0301(line-too-long), ] Line too long (111/100) +bettyfixer/extract_line.py:382: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:388: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:452: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:504: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:507: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:517: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:519: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:570: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:580: [C0301(line-too-long), ] Line too long (117/100) +bettyfixer/extract_line.py:584: [C0301(line-too-long), ] Line too long (151/100) +bettyfixer/extract_line.py:589: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:649: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:671: [C0325(superfluous-parens), ] Unnecessary parens after 'not' keyword +bettyfixer/extract_line.py:700: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:743: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:784: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:807: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:822: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:834: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:857: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:872: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:884: [C0303(trailing-whitespace), ] Trailing whitespace +bettyfixer/extract_line.py:1: [C0114(missing-module-docstring), ] Missing module docstring +bettyfixer/extract_line.py:7: [C0116(missing-function-docstring), run_vi_script] Missing function or method docstring +bettyfixer/extract_line.py:11: [W1510(subprocess-run-check), run_vi_script] 'subprocess.run' used without explicitly defining the value for 'check'. +bettyfixer/extract_line.py:13: [C0116(missing-function-docstring), remove_extra_spaces] Missing function or method docstring +bettyfixer/extract_line.py:24: [C0116(missing-function-docstring), process_error_file] Missing function or method docstring +bettyfixer/extract_line.py:24: [W0621(redefined-outer-name), process_error_file] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:25: [W1514(unspecified-encoding), process_error_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:32: [C0116(missing-function-docstring), extract_and_print_variables] Missing function or method docstring +bettyfixer/extract_line.py:44: [C0116(missing-function-docstring), clean_up_line] Missing function or method docstring +bettyfixer/extract_line.py:53: [C0116(missing-function-docstring), fix_errors_from_file] Missing function or method docstring +bettyfixer/extract_line.py:53: [R0912(too-many-branches), fix_errors_from_file] Too many branches (18/12) +bettyfixer/extract_line.py:110: [C0116(missing-function-docstring), fix_should_be_void] Missing function or method docstring +bettyfixer/extract_line.py:110: [W0621(redefined-outer-name), fix_should_be_void] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:116: [W1514(unspecified-encoding), fix_should_be_void] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:132: [C0116(missing-function-docstring), should_be_void] Missing function or method docstring +bettyfixer/extract_line.py:132: [W0621(redefined-outer-name), should_be_void] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:139: [W1514(unspecified-encoding), should_be_void] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:146: [W1514(unspecified-encoding), should_be_void] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:159: [C0116(missing-function-docstring), clean_errors_file] Missing function or method docstring +bettyfixer/extract_line.py:159: [W0621(redefined-outer-name), clean_errors_file] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:163: [R1732(consider-using-with), clean_errors_file] Consider using 'with' for resource-allocating operations +bettyfixer/extract_line.py:163: [W1514(unspecified-encoding), clean_errors_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:169: [C0116(missing-function-docstring), fix_missing_blank_line_after_declarations] Missing function or method docstring +bettyfixer/extract_line.py:169: [W0621(redefined-outer-name), fix_missing_blank_line_after_declarations] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:175: [W1514(unspecified-encoding), fix_missing_blank_line_after_declarations] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:190: [C0116(missing-function-docstring), fix_missing_blank_line_after_declaration] Missing function or method docstring +bettyfixer/extract_line.py:190: [W0621(redefined-outer-name), fix_missing_blank_line_after_declaration] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:195: [W1514(unspecified-encoding), fix_missing_blank_line_after_declaration] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:207: [W1514(unspecified-encoding), fix_missing_blank_line_after_declaration] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:215: [C0116(missing-function-docstring), fix_should_be_foo_star_star_bar] Missing function or method docstring +bettyfixer/extract_line.py:220: [W1514(unspecified-encoding), fix_should_be_foo_star_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:227: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:229: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:231: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:233: [W1309(f-string-without-interpolation), fix_should_be_foo_star_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:243: [W1514(unspecified-encoding), fix_should_be_foo_star_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:246: [C0116(missing-function-docstring), remove_unused_attribute] Missing function or method docstring +bettyfixer/extract_line.py:283: [W0718(broad-exception-caught), remove_unused_attribute] Catching too general exception Exception +bettyfixer/extract_line.py:248: [W1514(unspecified-encoding), remove_unused_attribute] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:279: [W1514(unspecified-encoding), remove_unused_attribute] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:264: [W0612(unused-variable), remove_unused_attribute] Unused variable 'original_declaration' +bettyfixer/extract_line.py:286: [C0116(missing-function-docstring), fix_lines_in_file] Missing function or method docstring +bettyfixer/extract_line.py:308: [W0718(broad-exception-caught), fix_lines_in_file] Catching too general exception Exception +bettyfixer/extract_line.py:288: [W1514(unspecified-encoding), fix_lines_in_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:306: [W1514(unspecified-encoding), fix_lines_in_file] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:287: [R1702(too-many-nested-blocks), fix_lines_in_file] Too many nested blocks (6/5) +bettyfixer/extract_line.py:311: [C0116(missing-function-docstring), generate_documentation] Missing function or method docstring +bettyfixer/extract_line.py:352: [C0116(missing-function-docstring), extract_functions_with_no_description] Missing function or method docstring +bettyfixer/extract_line.py:355: [W1514(unspecified-encoding), extract_functions_with_no_description] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:368: [C0116(missing-function-docstring), fix_space_prohibited_between_function_name_and_open_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:374: [W1514(unspecified-encoding), fix_space_prohibited_between_function_name_and_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:387: [W1514(unspecified-encoding), fix_space_prohibited_between_function_name_and_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:389: [C0116(missing-function-docstring), fix_space_prohibited_after_that_open_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:395: [W1514(unspecified-encoding), fix_space_prohibited_after_that_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:408: [W1514(unspecified-encoding), fix_space_prohibited_after_that_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:410: [C0116(missing-function-docstring), fix_space_prohibited_before_that_close_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:416: [W1514(unspecified-encoding), fix_space_prohibited_before_that_close_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:429: [W1514(unspecified-encoding), fix_space_prohibited_before_that_close_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:431: [C0116(missing-function-docstring), fix_space_required_before_the_open_parenthesis] Missing function or method docstring +bettyfixer/extract_line.py:437: [W1514(unspecified-encoding), fix_space_required_before_the_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:450: [W1514(unspecified-encoding), fix_space_required_before_the_open_parenthesis] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:453: [C0116(missing-function-docstring), fix_brace_should_be_on_the_next_line] Missing function or method docstring +bettyfixer/extract_line.py:453: [W0621(redefined-outer-name), fix_brace_should_be_on_the_next_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:459: [W1514(unspecified-encoding), fix_brace_should_be_on_the_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:492: [C0116(missing-function-docstring), fix_brace_on_the_next_line] Missing function or method docstring +bettyfixer/extract_line.py:492: [W0621(redefined-outer-name), fix_brace_on_the_next_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:497: [W1514(unspecified-encoding), fix_brace_on_the_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:509: [W1514(unspecified-encoding), fix_brace_on_the_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:520: [C0116(missing-function-docstring), brace_go_next_line] Missing function or method docstring +bettyfixer/extract_line.py:524: [W1514(unspecified-encoding), brace_go_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:539: [W1514(unspecified-encoding), brace_go_next_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:542: [C0116(missing-function-docstring), fix_brace_should_be_on_the_previous_line] Missing function or method docstring +bettyfixer/extract_line.py:542: [W0621(redefined-outer-name), fix_brace_should_be_on_the_previous_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:548: [W1514(unspecified-encoding), fix_brace_should_be_on_the_previous_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:563: [C0116(missing-function-docstring), fix_brace_on_the_previous_line] Missing function or method docstring +bettyfixer/extract_line.py:563: [W0621(redefined-outer-name), fix_brace_on_the_previous_line] Redefining name 'errors_file_path' from outer scope (line 968) +bettyfixer/extract_line.py:568: [W1514(unspecified-encoding), fix_brace_on_the_previous_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:587: [W1514(unspecified-encoding), fix_brace_on_the_previous_line] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:596: [C0116(missing-function-docstring), fix_space_prohibited_before_semicolon] Missing function or method docstring +bettyfixer/extract_line.py:599: [W1514(unspecified-encoding), fix_space_prohibited_before_semicolon] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:613: [W1514(unspecified-encoding), fix_space_prohibited_before_semicolon] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:615: [C0116(missing-function-docstring), fix_should_be_foo_star_bar] Missing function or method docstring +bettyfixer/extract_line.py:620: [W1514(unspecified-encoding), fix_should_be_foo_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:627: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:629: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:631: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:633: [W1309(f-string-without-interpolation), fix_should_be_foo_star_bar] Using an f-string that does not have any interpolated variables +bettyfixer/extract_line.py:643: [W1514(unspecified-encoding), fix_should_be_foo_star_bar] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:645: [C0116(missing-function-docstring), fix_spaces_prohibited_around_that] Missing function or method docstring +bettyfixer/extract_line.py:667: [W1514(unspecified-encoding), fix_spaces_prohibited_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:693: [W1514(unspecified-encoding), fix_spaces_prohibited_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:696: [C0116(missing-function-docstring), fix_space_prohibited_after_that] Missing function or method docstring +bettyfixer/extract_line.py:718: [W1514(unspecified-encoding), fix_space_prohibited_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:737: [W1514(unspecified-encoding), fix_space_prohibited_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:739: [C0116(missing-function-docstring), fix_space_prohibited_before_that] Missing function or method docstring +bettyfixer/extract_line.py:761: [W1514(unspecified-encoding), fix_space_prohibited_before_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:768: [R1714(consider-using-in), fix_space_prohibited_before_that] Consider merging these comparisons with 'in' by using 'context in ('WxV', 'WxO', 'WxE', 'WxW')'. Use a set instead if elements are hashable. +bettyfixer/extract_line.py:778: [W1514(unspecified-encoding), fix_space_prohibited_before_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:780: [C0116(missing-function-docstring), fix_spaces_preferred_around_that] Missing function or method docstring +bettyfixer/extract_line.py:802: [W1514(unspecified-encoding), fix_spaces_preferred_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:828: [W1514(unspecified-encoding), fix_spaces_preferred_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:830: [C0116(missing-function-docstring), fix_space_required_around_that] Missing function or method docstring +bettyfixer/extract_line.py:852: [W1514(unspecified-encoding), fix_space_required_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:878: [W1514(unspecified-encoding), fix_space_required_around_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:880: [C0116(missing-function-docstring), fix_space_required_after_that] Missing function or method docstring +bettyfixer/extract_line.py:902: [W1514(unspecified-encoding), fix_space_required_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:909: [R1714(consider-using-in), fix_space_required_after_that] Consider merging these comparisons with 'in' by using 'context in ('WxV', 'VxV')'. Use a set instead if elements are hashable. +bettyfixer/extract_line.py:919: [W1514(unspecified-encoding), fix_space_required_after_that] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:921: [C0116(missing-function-docstring), fix_space_required_before_the_open_brace] Missing function or method docstring +bettyfixer/extract_line.py:927: [W1514(unspecified-encoding), fix_space_required_before_the_open_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:940: [W1514(unspecified-encoding), fix_space_required_before_the_open_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:942: [C0116(missing-function-docstring), fix_space_required_after_the_close_brace] Missing function or method docstring +bettyfixer/extract_line.py:948: [W1514(unspecified-encoding), fix_space_required_after_the_close_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:961: [W1514(unspecified-encoding), fix_space_required_after_the_close_brace] Using open without explicitly specifying an encoding +bettyfixer/extract_line.py:968: [C0103(invalid-name), ] Constant name "errors_file_path" doesn't conform to UPPER_CASE naming style +bettyfixer/extract_line.py:4: [C0411(wrong-import-order), ] standard import "import os" should be placed before "from bettyfixer.errors_extractor import exctract_errors" +bettyfixer/extract_line.py:5: [C0411(wrong-import-order), ] standard import "import subprocess" should be placed before "from bettyfixer.errors_extractor import exctract_errors" + + + ## Report + +**522 statements analysed.** + +Statistics by type +------------------ + +| type | number | old number | difference | %documented | %badname | +|----------|--------|------------|------------|-------------|----------| +| module | 1 | 1 | = | 0.00 | 0.00 | +| class | 0 | NC | NC | 0 | 0 | +| method | 0 | NC | NC | 0 | 0 | +| function | 35 | 35 | = | 0.00 | 0.00 | + + +**971 lines have been analyzed** + +Raw metrics +----------- + +|type |number |% |previous |difference | +|----------|-------|------|---------|-----------| +|code |536 |55.20 |NC |NC | +|docstring |16 |1.65 |NC |NC | +|comment |206 |21.22 |NC |NC | +|empty |213 |21.94 |NC |NC | + + + +Duplication +----------- + +| |now |previous |difference | +|-------------------------|------|---------|-----------| +|nb duplicated lines |0 |0 |0 | +|percent duplicated lines |0.000 |0.000 |= | + + + +Messages by category +-------------------- + +|type |number |previous |difference | +|-----------|-------|---------|-----------| +|convention |82 |82 |82 | +|refactor |5 |5 |5 | +|warning |74 |74 |74 | +|error |0 |0 |0 | + + + +Messages +-------- + + +| message id | occurrences | +|------------------------------- | ------------| +| unspecified-encoding | 51 | +| missing-function-docstring | 35 | +| trailing-whitespace | 24 | +| line-too-long | 18 | +| redefined-outer-name | 10 | +| f-string-without-interpolation | 8 | +| wrong-import-order | 2 | +| consider-using-in | 2 | +| broad-exception-caught | 2 | +| unused-variable | 1 | +| too-many-nested-blocks | 1 | +| too-many-branches | 1 | +| superfluous-parens | 1 | +| subprocess-run-check | 1 | +| missing-module-docstring | 1 | +| invalid-name | 1 | +| consider-using-with | 1 | +| bad-indentation | 1 | + + + + + +------------------------------------------------------------------ +Your code has been rated at 6.92/10 (previous run: 6.92/10, +0.00) + From 3d057553267fc8bea882d93f64f6c25de49286f1 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:45:54 +0300 Subject: [PATCH 086/103] Add Pylint workflow for code analysis --- .github/workflows/linting.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..71de383 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,23 @@ +name: Pylint + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint pycodestyle + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') \ No newline at end of file From e30762ffee9ff5e5a765f4e60569d702caed7b30 Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:49:35 +0300 Subject: [PATCH 087/103] Fix pylint warnings and clean up code --- bettyfixer/extract_line.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index ccbe642..62d6a62 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -1,6 +1,7 @@ """ Extracts errors from the errors.txt file and fixes them in the specified file """ +# pylint: disable=too-many-lines import re import sys import os @@ -99,6 +100,8 @@ def clean_up_line(line): return cleaned_line +# pylint: disable=too-many-branches + def fix_errors_from_file(file_path, line_number, error_description): """ @@ -254,7 +257,8 @@ def clean_errors_file(errors_file_path): errors_file_path = 'errors.txt' # Clear the content of the errors.txt file before appending new errors - open(errors_file_path, 'w', encoding='utf-8').close() + open(errors_file_path, 'w', # pylint: disable=consider-using-with + encoding='utf-8').close() # Iterate over each file provided as a command-line argument for file_path in sys.argv[1:]: @@ -434,7 +438,7 @@ def fix_lines_in_file(file_name, function_declarations): function_declarations (dict): A dictionary containing the function_name and its original line. """ - try: + try: # pylint: disable=too-many-nested-blocks with open(file_name, 'r', encoding='utf-8') as file: lines = file.readlines() From 417573d44a447521e599883e8da20da117916397 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:41:42 +0000 Subject: [PATCH 088/103] Refactor function name variable in extract_line.py --- bettyfixer/extract_line.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bettyfixer/extract_line.py b/bettyfixer/extract_line.py index 647f3b5..71e00ba 100644 --- a/bettyfixer/extract_line.py +++ b/bettyfixer/extract_line.py @@ -446,12 +446,12 @@ def fix_lines_in_file(file_name, function_declarations): for i, line in enumerate(lines): if '*/' in line and 'unused' in line: # Check if any function_name is found in this line - for func_name, original_line in function_declarations.items(): - if func_name in line: + for f_name, original_line in function_declarations.items(): + if f_name in line: # Replace the line with the desired format lines[i] = f' */\n{original_line}' - # Check if the next line is a blank; if so, delete it + # Check if next line is a blank; if so, delete it if i + 1 < len(lines) and lines[i + 1] == '\n': del lines[i + 1] break From 4e9f9065e29909093bf30283092ff8af68b97f61 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:50:01 +0000 Subject: [PATCH 089/103] Fix Betty style and remove linting errors --- bettyfixer/betty_fixer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index 0dfcd92..ac3bcca 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -174,7 +174,7 @@ def remove_blank_lines_inside_comments(file_path): lines = file.readlines() # Find lines starting with '/**' (declaration beginning) - for i, line in enumerate(lines): + for i, line in enumerate(lines): # pylint: disable=too-many-nested-blocks if line.strip().startswith('/**'): # Find the next line starting with ' */' (declaration ending) for j in range(i + 1, len(lines)): @@ -242,6 +242,7 @@ def fix_betty_style(file_paths): betty_handler(errors_file_path) +# pylint: disable=too-many-locals def more_than_5_functions_in_the_file(errors_file_path): """ Fix the error 'More than 5 functions in the file' in the specified file. @@ -299,7 +300,7 @@ def more_than_5_functions_in_the_file(errors_file_path): ) as main_file: main_file.write(''.join(lines)) # Clean 'errors.txt' before - # extracting new errors + # pylint: disable=consider-using-with open(errors_file_path, 'w', encoding='utf-8').close() # Update Betty errors in errors.txt @@ -506,7 +507,7 @@ def main(): if any(is_file_processed(file) for file in file_paths): print("One or more files have already been processed. Skipping.") sys.exit(1) - + # pylint: disable=consider-using-with open('errors.txt', 'w', encoding='utf-8').close() # Fix Betty style fix_betty_style(file_paths) From bbf99fcfa7aecf5a331adfb8b2ada58add9c82eb Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:44:21 +0000 Subject: [PATCH 090/103] Update MANIFEST.in and setup.py --- MANIFEST.in | 3 +- pylintrc | 635 ++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 20 +- 3 files changed, 650 insertions(+), 8 deletions(-) create mode 100644 pylintrc diff --git a/MANIFEST.in b/MANIFEST.in index e93123f..6745f6b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ include README.md -recursive-exclude errors_logs * \ No newline at end of file +recursive-exclude errors_logs * +exclude pylintrc \ No newline at end of file diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..9a06013 --- /dev/null +++ b/pylintrc @@ -0,0 +1,635 @@ +[MAIN] + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Clear in-memory caches upon conclusion of linting. Useful if running pylint +# in a server-like mode. +clear-cache-post-run=no + +# Load and enable all available extensions. Use --list-extensions to see a list +# all available extensions. +#enable-all-extensions= + +# In error mode, messages with a category besides ERROR or FATAL are +# suppressed, and no reports are done by default. Error mode is compatible with +# disabling specific errors. +#errors-only= + +# Always return a 0 (non-error) status code, even if lint errors are found. +# This is primarily useful in continuous integration scripts. +#exit-zero= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-allow-list= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. (This is an alternative name to extension-pkg-allow-list +# for backward compatibility.) +extension-pkg-whitelist= + +# Return non-zero exit code if any of these messages/categories are detected, +# even if score is above --fail-under value. Syntax same as enable. Messages +# specified are enabled, while categories only check already-enabled messages. +fail-on= + +# Specify a score threshold under which the program will exit with error. +fail-under=10 + +# Interpret the stdin as a python script, whose filename needs to be passed as +# the module_or_package argument. +#from-stdin= + +# Files or directories to be skipped. They should be base names, not paths. +ignore=CVS + +# Add files or directories matching the regular expressions patterns to the +# ignore-list. The regex matches against paths and can be in Posix or Windows +# format. Because '\\' represents the directory delimiter on Windows systems, +# it can't be used as an escape character. +ignore-paths= + +# Files or directories matching the regular expression patterns are skipped. +# The regex matches against base names, not paths. The default value ignores +# Emacs file locks +ignore-patterns=^\.# + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis). It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Minimum Python version to use for version dependent checks. Will default to +# the version used to run pylint. +py-version=3.10 + +# Discover python modules and packages in the file system subtree. +recursive=no + +# Add paths to the list of the source roots. Supports globbing patterns. The +# source root is an absolute path or a path relative to the current working +# directory used to determine a package namespace for modules located under the +# source root. +source-roots= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# In verbose mode, extra non-checker-related info will be displayed. +#verbose= + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. If left empty, argument names will be checked with the set +# naming style. +#argument-rgx= + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. If left empty, attribute names will be checked with the set naming +# style. +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Bad variable names regexes, separated by a comma. If names match any regex, +# they will always be refused +bad-names-rgxs= + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. If left empty, class attribute names will be checked +# with the set naming style. +#class-attribute-rgx= + +# Naming style matching correct class constant names. +class-const-naming-style=UPPER_CASE + +# Regular expression matching correct class constant names. Overrides class- +# const-naming-style. If left empty, class constant names will be checked with +# the set naming style. +#class-const-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. If left empty, class names will be checked with the set naming style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. If left empty, constant names will be checked with the set naming +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. If left empty, function names will be checked with the set +# naming style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ + +# Good variable names regexes, separated by a comma. If names match any regex, +# they will always be accepted +good-names-rgxs= + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. If left empty, inline iteration names will be checked +# with the set naming style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. If left empty, method names will be checked with the set naming style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. If left empty, module names will be checked with the set naming style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Regular expression matching correct type alias names. If left empty, type +# alias names will be checked with the set naming style. +#typealias-rgx= + +# Regular expression matching correct type variable names. If left empty, type +# variable names will be checked with the set naming style. +#typevar-rgx= + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. If left empty, variable names will be checked with the set +# naming style. +#variable-rgx= + + +[CLASSES] + +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + asyncSetUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[DESIGN] + +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods= + +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when caught. +overgeneral-exceptions=builtins.BaseException,builtins.Exception + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[IMPORTS] + +# List of modules that can be imported at any level, not just the top level +# one. +allow-any-import-level= + +# Allow explicit reexports by alias from a package __init__. +allow-reexport-from-package=no + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules= + +# Output a graph (.gv or any supported image format) of external dependencies +# to the given file (report RP0402 must not be disabled). +ext-import-graph= + +# Output a graph (.gv or any supported image format) of all (i.e. internal and +# external) dependencies to the given file (report RP0402 must not be +# disabled). +import-graph= + +# Output a graph (.gv or any supported image format) of internal dependencies +# to the given file (report RP0402 must not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[LOGGING] + +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, +# UNDEFINED. +confidence=HIGH, + CONTROL_FLOW, + INFERENCE, + INFERENCE_FAILURE, + UNDEFINED + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then re-enable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead, + use-implicit-booleaness-not-comparison-to-string, + use-implicit-booleaness-not-comparison-to-zero, + duplicate-code + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable= + + +[METHOD_ARGS] + +# List of qualified names (i.e., library.method) which require a timeout +# parameter e.g. 'requests.api.get,requests.api.post' +timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + +# Regular expression of note tags to take in consideration. +notes-rgx= + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit,argparse.parse_error + + +[REPORTS] + +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'fatal', 'error', 'warning', 'refactor', +# 'convention', and 'info' which contain the number of messages in each +# category, as well as 'statement' which is the total number of statements +# analyzed. This score is used by the global evaluation report (RP0004). +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +msg-template= + +# Set the output format. Available formats are: text, parseable, colorized, +# json2 (improved json format), json (old json format) and msvs (visual +# studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +#output-format= + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[SIMILARITIES] + +# Comments are removed from the similarity computation +ignore-comments=yes + +# Docstrings are removed from the similarity computation +ignore-docstrings=yes + +# Imports are removed from the similarity computation +ignore-imports=yes + +# Signatures are removed from the similarity computation +ignore-signatures=yes + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. No available dictionaries : You need to install +# both the python package and the system dependency for enchant to work. +spelling-dict= + +# List of comma separated words that should be considered directives if they +# appear at the beginning of a comment and should not be checked. +spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no + + +[STRING] + +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=no + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. +check-str-concat-over-line-jumps=no + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of symbolic message names to ignore for Mixin members. +ignored-checks-for-mixins=no-member, + not-async-context-manager, + not-context-manager, + attribute-defined-outside-init + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# Regex pattern to define which classes are considered mixins. +mixin-class-rgx=.*[Mm]ixin + +# List of decorators that change the signature of a decorated function. +signature-mutators= + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of names allowed to shadow builtins +allowed-redefined-builtins= + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io diff --git a/setup.py b/setup.py index b606e1d..c1dc6db 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,13 @@ -from setuptools import setup, find_packages -from setuptools.command.install import install +""" +This file is used to package the bettyfixer tool and install it in the system. +""" +# import subprocess +# import time +# import shutil from pathlib import Path -import subprocess -import time -import shutil - +from setuptools import setup, find_packages +# from setuptools.command.install import install + setup( name='bettyfixer', version='1.4.6', @@ -22,7 +25,10 @@ ], author='Moealsir', author_email='mohamedwdalsir@gmail.com', - description='Betty Fixer is a tool designed to automatically fix coding style issues in C files based on the Betty coding style guidelines. It performs corrections to ensure that the code complies with the Betty style, making it more readable and consistent.', + description='Betty Fixer is a tool designed to automatically fix coding style \ + issues in C files based on the Betty coding style guidelines.\ + It performs corrections to ensure that the code complies with the Betty style, \ + making it more readable and consistent.', url='https://github.com/Moealsir/betty_fixer', # Replace with your GitHub repository URL license='MIT', # Replace with your desired license From c3b62d133f236a6319b776f04b378c37e035aca4 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:01:23 +0000 Subject: [PATCH 091/103] Update linting workflow to install colorama package --- .github/workflows/linting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 71de383..9f34d8c 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pylint pycodestyle + pip install pylint pycodestyle colorama - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') \ No newline at end of file From 62e7c39bc0efd0ec172c476ab6c9ca742aed6460 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:03:59 +0000 Subject: [PATCH 092/103] Update Python versions in linting workflow --- .github/workflows/linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 9f34d8c..def8df7 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9"] + python-version: ["3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 9d36c7b5f9a563d9ef33272eedc9e07be6d5b304 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:07:48 +0000 Subject: [PATCH 093/103] Add pycodestyle analysis to linting workflow --- .github/workflows/linting.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index def8df7..b0b5718 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -20,4 +20,7 @@ jobs: pip install pylint pycodestyle colorama - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') \ No newline at end of file + pylint $(git ls-files '*.py') + - name: Analysing the code with pycodestyle + run: | + pycodestyle $(git ls-files '*.py' | grep -v setup.py) \ No newline at end of file From 0114d6407e768f9d028528e1b1e51ac44f2202d3 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:09:20 +0000 Subject: [PATCH 094/103] Update linting.yml to trigger on pull requests as well as pushes --- .github/workflows/linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index b0b5718..9521313 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -1,6 +1,6 @@ name: Pylint -on: [push] +on: [push, pull_request] jobs: build: From cac9c7c9c2dc51df174ade437a06ff530ca8b9bd Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sat, 10 Feb 2024 09:06:13 +0000 Subject: [PATCH 095/103] Pending changes exported from your codespace --- .devcontainer/devcontainer.json | 9 +++++++++ main.c | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 main.c diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..7205d6b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,9 @@ +{ + "image": "mcr.microsoft.com/devcontainers/universal:2", + "features": { + "ghcr.io/itsmechlark/features/act:1": { + "version": "latest" + } + + } +} \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..a6beaaf --- /dev/null +++ b/main.c @@ -0,0 +1,7 @@ +#include + +void main(int argc, **argv){ + printf("Hello, World\n"); + return 0; +} + From 4868183dc957f1e782d83d9ad2fd5f14b30e75db Mon Sep 17 00:00:00 2001 From: jonaahmed <23105954+jonaahmed@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:39:33 +0300 Subject: [PATCH 096/103] Remove betty_handler.py and related functions as it is duplicates from betty_fixer module --- bettyfixer/betty_handler.py | 95 ------------------------------------- 1 file changed, 95 deletions(-) delete mode 100644 bettyfixer/betty_handler.py diff --git a/bettyfixer/betty_handler.py b/bettyfixer/betty_handler.py deleted file mode 100644 index 6951bc9..0000000 --- a/bettyfixer/betty_handler.py +++ /dev/null @@ -1,95 +0,0 @@ -""" -This module contains functions for handling Betty style tasks. - -The module can be run as a script, taking a list of file paths as command-line -arguments. -When run as a script, it creates a tasks directory if one doesn't exist, -copies the specified files to the tasks directory, and modifies the main files. -""" -import os -import sys - - -def other_handler(file_path): - """ - This function creates a tasks directory if one doesn't exist, - copies the specified files to the tasks directory, - and modifies the main files. - """ - create_tasks_directory() - copy_files_to_tasks(file_path) - modify_main_files(file_path) - - -def create_tasks_directory(): - """ - Create a tasks directory if one doesn't exist. - """ - # Create tasks directory if not found - if not os.path.exists("tasks"): - os.makedirs("tasks") - - -def copy_files_to_tasks(files): - """ - Copy the specified files to the tasks directory. - Args: - files (list): A list of file paths to copy to the tasks directory. - """ - for file_path in files: - destination_path = os.path.join("tasks", os.path.basename(file_path)) - if not os.path.exists(destination_path): - # Read the content of the file - with open(file_path, 'r', encoding='utf-8') as source_file: - content = source_file.readlines() - - # Exclude lines starting with #include and ending with '.h"' - filtered_content = [line for line in content if not line.strip( - ).startswith("#include") or not line.strip().endswith('.h"')] - - # Write the modified content to the destination file - with open(destination_path, 'w', encoding='utf-8') as dest_file: - dest_file.write(''.join(filtered_content)) - - -def modify_main_files(files): - """ - Modify the main files to include the tasks. - Args: - files (list): A list of file paths to modify. - - """ - # Modify main files - for file_path in files: - # Read the content of the main file - with open(file_path, 'r', encoding='utf-8') as main_file: - content = main_file.readlines() - - # Keep only lines with #include that end with '.h"' - include_lines = [line.strip() for line in content if line.strip( - ).startswith("#include") and line.strip().endswith('.h"')] - - # Write the modified content to main file. - # adding an empty line at the end - with open(file_path, 'w', encoding='utf-8') as main_file: - main_file.write('\n'.join( - include_lines + [ - f'#include "tasks/{os.path.basename(file_path)}"\n'])) - - -if __name__ == "__main__": - # Check if the correct number of arguments is provided - if len(sys.argv) < 2: - print("Usage: python betty_handler.py file1.c file2.c ...") - sys.exit(1) - - # Create tasks directory if not found - create_tasks_directory() - - # Copy files to tasks directory if not found - copy_files_to_tasks(sys.argv[1:]) - - # Modify main files - modify_main_files(sys.argv[1:]) - - print("Tasks directory and main files modified successfully.") From b07284a74c11865cc8a69d84e977a6b949a3a347 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:27:00 +0300 Subject: [PATCH 097/103] Delete main.c --- main.c | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 main.c diff --git a/main.c b/main.c deleted file mode 100644 index a6beaaf..0000000 --- a/main.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -void main(int argc, **argv){ - printf("Hello, World\n"); - return 0; -} - From 8f8548f00cd32270a5b8d2477c2deddca9bcbe25 Mon Sep 17 00:00:00 2001 From: Younis <23105954+Younis-Ahmed@users.noreply.github.com> Date: Sun, 18 Feb 2024 16:06:33 +0300 Subject: [PATCH 098/103] Update linting.yml --- .github/workflows/linting.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 9521313..16efb8a 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -18,9 +18,13 @@ jobs: run: | python -m pip install --upgrade pip pip install pylint pycodestyle colorama - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') - - name: Analysing the code with pycodestyle - run: | - pycodestyle $(git ls-files '*.py' | grep -v setup.py) \ No newline at end of file + linting-Tests: + runs-on: ubuntu-latest + needs: build + steps: + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') + - name: Analysing the code with pycodestyle + run: | + pycodestyle $(git ls-files '*.py' | grep -v setup.py) From 5af99a05ef55711eb1a90845836133db60e335db Mon Sep 17 00:00:00 2001 From: Younis-Ahmed <23105954+jonaahmed@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:33:33 +0300 Subject: [PATCH 099/103] Fix betty error message formatting --- bettyfixer/autoprototype.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bettyfixer/autoprototype.py b/bettyfixer/autoprototype.py index d1dfaf2..4add489 100644 --- a/bettyfixer/autoprototype.py +++ b/bettyfixer/autoprototype.py @@ -36,7 +36,7 @@ def print_check_betty_first(): """Prints a message to the user to fix betty errors first.""" print( Fore.RED + "You should fix betty Errors first before \ - copy prototype functions into The header file" + Fore.RESET +copy prototype functions into The header file" + Fore.RESET ) From 0259e4df78289dfcbdefd8d87676aac201007994 Mon Sep 17 00:00:00 2001 From: Younis-Ahmed <23105954+jonaahmed@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:36:14 +0300 Subject: [PATCH 100/103] description formatting --- setup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index c1dc6db..04d7c80 100644 --- a/setup.py +++ b/setup.py @@ -26,10 +26,11 @@ author='Moealsir', author_email='mohamedwdalsir@gmail.com', description='Betty Fixer is a tool designed to automatically fix coding style \ - issues in C files based on the Betty coding style guidelines.\ - It performs corrections to ensure that the code complies with the Betty style, \ - making it more readable and consistent.', - url='https://github.com/Moealsir/betty_fixer', # Replace with your GitHub repository URL +issues in C files based on the Betty coding style guidelines.\ +It performs corrections to ensure that the code complies with the Betty style, \ +making it more readable and consistent.', + # Replace with your GitHub repository URL + url='https://github.com/Moealsir/betty_fixer', license='MIT', # Replace with your desired license long_description=(Path(__file__).parent / "README.md").read_text(), From ee966e813479610bdde3ea7908c7c72535c2456d Mon Sep 17 00:00:00 2001 From: Younis-Ahmed <23105954+jonaahmed@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:40:21 +0300 Subject: [PATCH 101/103] remove whitespaces --- bettyfixer/autoprototype.py | 2 +- bettyfixer/betty_fixer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bettyfixer/autoprototype.py b/bettyfixer/autoprototype.py index 4add489..5671243 100644 --- a/bettyfixer/autoprototype.py +++ b/bettyfixer/autoprototype.py @@ -62,7 +62,7 @@ def check_ctags(): return True, None except subprocess.CalledProcessError: msg = "ctags is not installed. \ - Please install ctags before running this script." +Please install ctags before running this script." return False, msg diff --git a/bettyfixer/betty_fixer.py b/bettyfixer/betty_fixer.py index ac3bcca..135fec2 100644 --- a/bettyfixer/betty_fixer.py +++ b/bettyfixer/betty_fixer.py @@ -488,7 +488,7 @@ def main(): if len(sys.argv) < 2: print( "Usage: python -m betty_fixer_package.betty_fixer\ - file1.c file2.c ...") + file1.c file2.c ...") sys.exit(1) if "-H" in sys.argv and len(sys.argv) > 2: From 75968177ce791d4b73ac276b571976a8d228431b Mon Sep 17 00:00:00 2001 From: Younis-Ahmed <23105954+jonaahmed@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:54:57 +0300 Subject: [PATCH 102/103] Remove unused devcontainer.json file --- .devcontainer/devcontainer.json | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 7205d6b..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "image": "mcr.microsoft.com/devcontainers/universal:2", - "features": { - "ghcr.io/itsmechlark/features/act:1": { - "version": "latest" - } - - } -} \ No newline at end of file From 87e54d58c120406568e6236976388f6319111f92 Mon Sep 17 00:00:00 2001 From: Younis-Ahmed <23105954+jonaahmed@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:21:17 +0300 Subject: [PATCH 103/103] Refactor linting workflow --- .github/workflows/linting.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 16efb8a..de21288 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -18,13 +18,9 @@ jobs: run: | python -m pip install --upgrade pip pip install pylint pycodestyle colorama - linting-Tests: - runs-on: ubuntu-latest - needs: build - steps: - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') - - name: Analysing the code with pycodestyle - run: | - pycodestyle $(git ls-files '*.py' | grep -v setup.py) + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') + - name: Analysing the code with pycodestyle + run: | + pycodestyle $(git ls-files '*.py' | grep -v setup.py)