From aa0ede70b2c1a2bfd88e2239336a83df580095bf Mon Sep 17 00:00:00 2001 From: Samuel Doghor <56834362+samdoghor@users.noreply.github.com> Date: Thu, 23 Nov 2023 03:32:39 +0100 Subject: [PATCH 1/3] bugfix: minor bug fix --- alxcheck/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alxcheck/main.py b/alxcheck/main.py index 8e807fa..ebbe5e5 100644 --- a/alxcheck/main.py +++ b/alxcheck/main.py @@ -23,7 +23,8 @@ def main(): for file in files: file_path = os.path.join(root, file) if file_path.endswith( - (".c", ".py", ".js", ".m", ".h", ".mjs", ".jsx", ".json") + (".c", ".py", ".js", ".m", ".h", + ".mjs", ".jsx", ".json", ".md") ): if not check_file_ends_with_new_line(file_path): if not is_empty_init_py(file_path): From 410d864656ac956f216b7fb5b8990cb0be14a915 Mon Sep 17 00:00:00 2001 From: Samuel Doghor <56834362+samdoghor@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:17:41 +0100 Subject: [PATCH 2/3] bugfix: check on newline --- alxcheck/checks/general.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/alxcheck/checks/general.py b/alxcheck/checks/general.py index b34f145..78d4fca 100644 --- a/alxcheck/checks/general.py +++ b/alxcheck/checks/general.py @@ -18,5 +18,6 @@ def check_file_not_empty(file_path): def check_file_ends_with_new_line(file_path): if not check_file_not_empty(file_path): return False - with open(file_path, "r") as f: - return f.read()[-1] == "\n" + + with open(file_path, "rb") as f: + return f.readlines()[-1] == b"\n" From cddca05148951aacee1a2d16c7e731a520063c77 Mon Sep 17 00:00:00 2001 From: Samuel Doghor <56834362+samdoghor@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:44:44 +0100 Subject: [PATCH 3/3] refac: moved the check for newline in README.md to newlines --- alxcheck/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/alxcheck/main.py b/alxcheck/main.py index ebbe5e5..ac6c0bc 100644 --- a/alxcheck/main.py +++ b/alxcheck/main.py @@ -11,6 +11,8 @@ def main(): sys.exit(1) if not check_file_not_empty("README.md"): print_file_empty("README.md") + if not check_file_ends_with_new_line("README.md"): + print_no_ending_new_line("README.md") for root, dirs, files in os.walk("."): # exclude virtual environment folders for dir in dirs: @@ -24,7 +26,7 @@ def main(): file_path = os.path.join(root, file) if file_path.endswith( (".c", ".py", ".js", ".m", ".h", - ".mjs", ".jsx", ".json", ".md") + ".mjs", ".jsx", ".json") ): if not check_file_ends_with_new_line(file_path): if not is_empty_init_py(file_path):