diff --git a/.gitmodules b/.gitmodules index e925535..7cb660c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "build-aux/flatpak/stable"] path = build-aux/flatpak/stable url = git@github.com:flathub/io.github.Rirusha.Cassette.git +[submodule "vala-checkers"] + path = vala-checkers + url = git@ssh.gitlab.gnome.org:Rirusha/vala-checkers.git diff --git a/checkers/empty_lines_checker.py b/checkers/empty_lines_checker.py deleted file mode 100644 index 775da39..0000000 --- a/checkers/empty_lines_checker.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -import sys -import os -import re - -def check_indentation (file_path, root_dir) -> list[str]: - file_err_list = [] - - with open (file_path, 'r') as file: - lines = file.readlines () - - empty_lines_count = 0 - for i, line in enumerate (lines): - if line.strip () == "": - empty_line_count += 1 - else: - empty_line_count = 0 - - if empty_line_count > 1: - file_err_list.append (f"To mant empty lines in file '{file_path.replace (root_dir, "", 1)}' at line {i + 1}: \"{line.rstrip ()}\".") - - return file_err_list - -def scan_directory (directory) -> list[str]: - err_list = [] - - for root, dirs, files in os.walk (directory): - for file in files: - if (file.endswith ('.vala') or file.endswith ('.blp')) and (("/data/ui" in root or "/src" in root or "/tests" in root) and "/.flatpak/" not in root): - file_path = os.path.join (root, file) - - file_err_list = check_indentation (file_path, directory) - - if (file_err_list): - err_list += file_err_list - - return err_list - - -if __name__ == "__main__": - err_list = scan_directory (sys.argv[1]) - - print (*err_list, sep="\n", end="\n\n") - print (f"Total errors: {len (err_list)}") - - if (len (err_list) != 0): - sys.exit (1) diff --git a/checkers/indentation_checker.py b/checkers/indentation_checker.py deleted file mode 100644 index 5a4a28c..0000000 --- a/checkers/indentation_checker.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -import sys -import os -import re - -def check_indentation (file_path, root_dir) -> list[str]: - file_err_list = [] - - with open (file_path, 'r') as file: - lines = file.readlines () - - for i, line in enumerate (lines): - if "ind-check=skip-file" in line: - return - - if re.match (r'^(?!.*(?:new|if|else| => |try|catch|switch|}|get |set |while|namespace|class|foreach|throws|ind-check=ignore| = {))(?=(?:.*?\s+\w+\s+\w+.*?){1}).*{', line): - indentation = len (re.match(r'^(\s*)', line).group(1)) - if indentation != 4: - file_err_list.append (f"Indentation error in file '{file_path.replace (root_dir, "", 1)}' at line {i + 1}: \"{line.rstrip ()}\". {indentation} spaces instead of 4.") - - return file_err_list - -def scan_directory (directory) -> list[str]: - err_list = [] - - for root, dirs, files in os.walk (directory): - for file in files: - if file.endswith ('.vala'): - file_path = os.path.join (root, file) - - file_err_list = check_indentation (file_path, directory) - - if (file_err_list): - err_list += file_err_list - - return err_list - - -if __name__ == "__main__": - err_list = scan_directory (sys.argv[1]) - - print (*err_list, sep="\n", end="\n\n") - print (f"Total errors: {len (err_list)}") - - if (len (err_list) != 0): - sys.exit (1) diff --git a/vala-checkers b/vala-checkers new file mode 160000 index 0000000..421f9c2 --- /dev/null +++ b/vala-checkers @@ -0,0 +1 @@ +Subproject commit 421f9c29a62f970b4dadfcc84831beea3f0efd6a