From e3234767578390172f8e38e10ad8545e97962c06 Mon Sep 17 00:00:00 2001 From: Michael Maltsev <4129781+m417z@users.noreply.github.com> Date: Sat, 17 Aug 2024 23:59:20 +0300 Subject: [PATCH] Improve target module validation --- .github/pr_validation.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/pr_validation.py b/.github/pr_validation.py index 9003a37fd..1f99a461f 100644 --- a/.github/pr_validation.py +++ b/.github/pr_validation.py @@ -254,7 +254,11 @@ def get_target_modules_from_previous_line(previous_line: str): if comment == '': return [] - return [x.strip() for x in comment.split(',')] + names = [x.strip() for x in comment.split(',')] + if not all(x.endswith('.dll') or x.endswith('.exe') for x in names): + return [] + + return names def validate_symbol_hooks(path: Path): @@ -270,21 +274,16 @@ def validate_symbol_hooks(path: Path): line_num = 1 + mod_source[: match.start()].count('\n') target_from_name = get_target_module_from_symbol_block_name(symbol_block_name) - target_from_name_valid = target_from_name and is_existing_windows_file_name( - target_from_name - ) previous_line = mod_source_lines[line_num - 2] targets_from_comment = get_target_modules_from_previous_line(previous_line) - targets_from_comment_valid = targets_from_comment and all( - is_existing_windows_file_name(x) for x in targets_from_comment - ) - if target_from_name_valid and targets_from_comment_valid: - warning_msg = 'Use either a comment or a variable name, not both.' + if target_from_name and targets_from_comment: + warning_msg = ( + 'Use either a comment or a variable name, not both. For example, you' + ' can rename the variable from "user32DllHooks" to "user32Hooks".' + ) warnings += add_warning(path, line_num - 1, warning_msg) - elif target_from_name_valid or targets_from_comment_valid: - continue elif target_from_name or targets_from_comment: if target_from_name and not is_existing_windows_file_name(target_from_name): warning_msg = (