From a20d8561b867b1083a064faebd0396cc0c2a3064 Mon Sep 17 00:00:00 2001
From: Mathieu Courtois <mathieu.courtois@edf.fr>
Date: Wed, 12 Mar 2025 09:52:38 +0100
Subject: [PATCH] [#34298] utmess and message id must be on the same line to be
 checked

---
 lib/aslint/python/python_checkers.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/lib/aslint/python/python_checkers.py b/lib/aslint/python/python_checkers.py
index 9a90165..7698ece 100644
--- a/lib/aslint/python/python_checkers.py
+++ b/lib/aslint/python/python_checkers.py
@@ -198,12 +198,34 @@ class ObsoleteSdj(FileContentCat, TextMsg):
     apply_ctxt = CheckContext(reponame=["src"], branch="main")
     search = search_msg(r"(?P<main>\w+\.sdj(?:\.\w+)?)", ignore_case=False)
 
+
 class ObsoleteGetvectjev(FileContentCat, TextMsg):
     """Obsolete use of getvectjev or getcolljev"""
 
     id = "C4015"
     search = search_msg(r"(?P<main>(getvectjev|getcolljev))", ignore_case=False)
 
+
+class MultiLinesUtmess(FileContentCat, GenericMsg):
+    """Message id not found on the same line (use a dict for args)"""
+
+    id = "C4501"
+
+    def search(self, txt):
+        """Check for UTMESS without message id"""
+        if "def format_exception" in txt:
+            return []
+        if "class MESSAGE_LOGGER" in txt:
+            return []
+        re_utm = re.compile(r"(?P<line>(?:UTMESS|GetText|message_exception)\s*\(.*)", re.M)
+        re_id = re.compile(r"(UTMESS|GetText|message_exception)\s*\(.*_", re.I)
+        err = []
+        for mat in re_utm.finditer(txt):
+            if not re_id.search(mat.group("line")):
+                err.append(f": {mat.group('line')}")
+        return err
+
+
 class ReformatSource(FilenameCat, COMM.ReformatPy):
     """Reformat Python source"""
 
-- 
GitLab