From 73723408b7115699adc7f6734ce48fca59a8dbd2 Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Tue, 31 Mar 2026 14:02:11 +0100 Subject: [PATCH 1/8] Fix umdp lower and camel case checking --- script_umdp3_checker/umdp3_checker_rules.py | 23 +++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index a9a56edc..88e3e8c9 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -329,26 +329,23 @@ def lowercase_variable_names(self, lines: List[str]) -> TestResult: failures = 0 error_log = {} count = -1 - for count, line in enumerate(lines, 1): + for count, line in enumerate(lines): clean_line = self.remove_quoted(line) clean_line = re.sub(r"!.*$", "", clean_line) - # Simple check for UPPERCASE variable declarations - if re.search( - r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*[A-Z_]+", + # Check for UPPERCASE variable declarations (but allow CamelCase) + # Use (?i) flag only for the keywords, not for the variable name pattern + if match := re.search( + r"^\s*(?i:INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*([A-Z]\w*)", clean_line, - re.IGNORECASE, ): - clean_line = re.sub( - r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*", - "", - clean_line, - ) - if match := re.search(r"([A-Z]{2,})", clean_line): - self.add_extra_error(f"UPPERCASE variable name : {match[1]}") + var_name = match.group(1) + # Only flag if it's fully UPPERCASE (not mixed case like CamelCase) + if var_name.isupper() or ("_" in var_name and var_name.replace("_", "").isupper()): + self.add_extra_error(f"UPPERCASE variable name : {var_name}") failures += 1 error_log = self.add_error_log( - error_log, f"UPPERCASE variable name {match[1]}", count + error_log, f"UPPERCASE variable name {var_name}", count + 1 ) output = f"Checked {count + 1} lines, found {failures} failures." From 2ef8cb2339f7ebf3d1038bf736e804ae4c138f25 Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Tue, 31 Mar 2026 14:42:55 +0100 Subject: [PATCH 2/8] Add AI statement --- script_umdp3_checker/umdp3_checker_rules.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index 6f2c772d..b298876a 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -4,6 +4,9 @@ # which you should have received as part of this distribution. # *****************************COPYRIGHT******************************* +# Some of the content of this file has been produced with the assistance of +# Claude Sonnet 4.5 + """ Package to contain functions which test for UMDP3 compliance. Python translation of the original Perl UMDP3.pm module. From 5ee1698e6b7e3539ff20fe0a38575cf9558941e7 Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Tue, 31 Mar 2026 14:49:01 +0100 Subject: [PATCH 3/8] apply ruff formatting --- script_umdp3_checker/umdp3_checker_rules.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index b298876a..7271c240 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -338,7 +338,9 @@ def lowercase_variable_names(self, lines: List[str]) -> TestResult: ): var_name = match.group(1) # Only flag if it's fully UPPERCASE (not mixed case like CamelCase) - if var_name.isupper() or ("_" in var_name and var_name.replace("_", "").isupper()): + if var_name.isupper() or ( + "_" in var_name and var_name.replace("_", "").isupper() + ): self.add_extra_error(f"UPPERCASE variable name : {var_name}") failures += 1 error_log = self.add_error_log( From 1b57c1bbfa56b049cbb5b40eaaf9e93b120ecc68 Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Tue, 7 Apr 2026 13:57:26 +0100 Subject: [PATCH 4/8] Revert "Add AI statement" This reverts commit 2ef8cb2339f7ebf3d1038bf736e804ae4c138f25. --- script_umdp3_checker/umdp3_checker_rules.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index 7271c240..9ac8f00f 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -4,9 +4,6 @@ # which you should have received as part of this distribution. # *****************************COPYRIGHT******************************* -# Some of the content of this file has been produced with the assistance of -# Claude Sonnet 4.5 - """ Package to contain functions which test for UMDP3 compliance. Python translation of the original Perl UMDP3.pm module. From aef4c47bf555df11c09ed29bfdaa3a36c6d8070d Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Tue, 7 Apr 2026 14:07:54 +0100 Subject: [PATCH 5/8] Revert "Fix umdp lower and camel case checking" This reverts commit 73723408b7115699adc7f6734ce48fca59a8dbd2. --- script_umdp3_checker/umdp3_checker_rules.py | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index 9ac8f00f..5aea535b 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -323,25 +323,26 @@ def lowercase_variable_names(self, lines: List[str]) -> TestResult: failures = 0 error_log = {} count = -1 - for count, line in enumerate(lines): + for count, line in enumerate(lines, 1): clean_line = self.remove_quoted(line) clean_line = re.sub(r"!.*$", "", clean_line) - # Check for UPPERCASE variable declarations (but allow CamelCase) - # Use (?i) flag only for the keywords, not for the variable name pattern - if match := re.search( - r"^\s*(?i:INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*([A-Z]\w*)", + # Simple check for UPPERCASE variable declarations + if re.search( + r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*[A-Z_]+", clean_line, + re.IGNORECASE, ): - var_name = match.group(1) - # Only flag if it's fully UPPERCASE (not mixed case like CamelCase) - if var_name.isupper() or ( - "_" in var_name and var_name.replace("_", "").isupper() - ): - self.add_extra_error(f"UPPERCASE variable name : {var_name}") + clean_line = re.sub( + r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*", + "", + clean_line, + ) + if match := re.search(r"([A-Z]{2,})", clean_line): + self.add_extra_error(f"UPPERCASE variable name : {match[1]}") failures += 1 error_log = self.add_error_log( - error_log, f"UPPERCASE variable name {var_name}", count + 1 + error_log, f"UPPERCASE variable name {match[1]}", count ) output = f"Checked {count + 1} lines, found {failures} failures." From cfb5408ab6205540d09c9c27bcce5d4dce8d7787 Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Tue, 7 Apr 2026 17:19:22 +0100 Subject: [PATCH 6/8] Precompile regex --- script_umdp3_checker/umdp3_checker_rules.py | 23 ++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index 5aea535b..2ae797b0 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -32,6 +32,12 @@ # Declare version VERSION = "13.5.0" +# Precompile regex statements +_vars_declare = re.compile(r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*[A-Z_]+", re.IGNORECASE) +_vars_cleaner = re.compile(r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*") +_consecutive_upper = re.compile(r"([A-Z]{2,})") +_comment_declare = re.compile(r"!.*$") + @dataclass class TestResult: @@ -325,20 +331,13 @@ def lowercase_variable_names(self, lines: List[str]) -> TestResult: count = -1 for count, line in enumerate(lines, 1): clean_line = self.remove_quoted(line) - clean_line = re.sub(r"!.*$", "", clean_line) + clean_line = _comment_declare.sub("", clean_line) # Simple check for UPPERCASE variable declarations - if re.search( - r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*[A-Z_]+", - clean_line, - re.IGNORECASE, - ): - clean_line = re.sub( - r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*", - "", - clean_line, - ) - if match := re.search(r"([A-Z]{2,})", clean_line): + if _vars_declare.search(clean_line): + clean_line = _vars_cleaner.sub("", clean_line) + + if match := _consecutive_upper.search(clean_line): self.add_extra_error(f"UPPERCASE variable name : {match[1]}") failures += 1 error_log = self.add_error_log( From 80b83584187be2c7136b39df4b0f9697071832c7 Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Tue, 7 Apr 2026 18:39:36 +0100 Subject: [PATCH 7/8] add mutiple variables catching group and checking of each variable name --- script_umdp3_checker/umdp3_checker_rules.py | 28 ++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index 2ae797b0..98b8acc0 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -34,7 +34,7 @@ # Precompile regex statements _vars_declare = re.compile(r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*[A-Z_]+", re.IGNORECASE) -_vars_cleaner = re.compile(r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*") +_vars_cleaner = re.compile(r"^\s*(INTEGER|REAL|LOGICAL|CHARACTER|TYPE)\s*.*::\s*(.+)$", re.IGNORECASE) _consecutive_upper = re.compile(r"([A-Z]{2,})") _comment_declare = re.compile(r"!.*$") @@ -335,14 +335,24 @@ def lowercase_variable_names(self, lines: List[str]) -> TestResult: # Simple check for UPPERCASE variable declarations if _vars_declare.search(clean_line): - clean_line = _vars_cleaner.sub("", clean_line) - - if match := _consecutive_upper.search(clean_line): - self.add_extra_error(f"UPPERCASE variable name : {match[1]}") - failures += 1 - error_log = self.add_error_log( - error_log, f"UPPERCASE variable name {match[1]}", count - ) + # Extract variable names part using capturing group + match_vars = _vars_cleaner.search(clean_line) + if match_vars: + var_declarations = match_vars.group(2).strip() + # Split by comma to get individual variable names + var_names = var_declarations.split(",") + + for var_name in var_names: + # Extract just the variable name (before = or () + #TODO: Check spliting of this var name + var_name = re.split(r'[=(]', var_name)[0].strip() + + if match := _consecutive_upper.search(var_name): + self.add_extra_error(f"UPPERCASE variable name : {match[1]}") + failures += 1 + error_log = self.add_error_log( + error_log, f"UPPERCASE variable name {match[1]}", count + ) output = f"Checked {count + 1} lines, found {failures} failures." return TestResult( From 8e01a3fda2b974a7ff82fc21e99e186c93e38fac Mon Sep 17 00:00:00 2001 From: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Date: Wed, 8 Apr 2026 08:01:55 +0100 Subject: [PATCH 8/8] Refactor to add checking of multiple variable declarations on one line --- script_umdp3_checker/umdp3_checker_rules.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/script_umdp3_checker/umdp3_checker_rules.py b/script_umdp3_checker/umdp3_checker_rules.py index 98b8acc0..964469a6 100644 --- a/script_umdp3_checker/umdp3_checker_rules.py +++ b/script_umdp3_checker/umdp3_checker_rules.py @@ -343,16 +343,17 @@ def lowercase_variable_names(self, lines: List[str]) -> TestResult: var_names = var_declarations.split(",") for var_name in var_names: + index = 1 # Extract just the variable name (before = or () - #TODO: Check spliting of this var name var_name = re.split(r'[=(]', var_name)[0].strip() - if match := _consecutive_upper.search(var_name): - self.add_extra_error(f"UPPERCASE variable name : {match[1]}") + if _consecutive_upper.search(var_name): + self.add_extra_error(f"UPPERCASE variable name : {var_name}") failures += 1 error_log = self.add_error_log( - error_log, f"UPPERCASE variable name {match[1]}", count + error_log, f"UPPERCASE variable name {var_name}", count ) + index += 1 output = f"Checked {count + 1} lines, found {failures} failures." return TestResult(