Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions script_umdp3_checker/umdp3_checker_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -323,26 +326,25 @@ 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."
Expand Down
Loading