diff --git a/lib/aslint/python/python_checkers.py b/lib/aslint/python/python_checkers.py index 9a901651b8305ff344cc1e526f759b802a3e72ac..7698ece700b661660913185de992bdfb6662b7f1 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""" diff --git a/share/test/test_aslint/test_check_files.py b/share/test/test_aslint/test_check_files.py index b6378805d2f0373a658ef21106ce895241efd3ff..cd7ab9fa21676789e376f77d149b380939261318 100644 --- a/share/test/test_aslint/test_check_files.py +++ b/share/test/test_aslint/test_check_files.py @@ -75,11 +75,11 @@ def test_get_file_type(): ) or path in top or (typ is None and base in ("fermetur", "histor")) - or (typ == "c" and base in ("bibc", "mfront")) + or (typ == "c" and base in ("bibc", "mfront", "libs")) or (typ == "h" and base == "bibc" and path.endswith(".h")) - or (typ == "cxx" and base == "bibcxx") + or (typ == "cxx" and base in ("bibcxx", "libs")) or (typ == "hxx" and base == "bibcxx" and path.endswith(".h")) - or (typ == "for" and base == "bibfor") + or (typ == "for" and base in ("bibfor", "libs")) or (typ == "hf" and base == "bibfor" and path.endswith(".h")) or (typ == "py" and base in ("bibpyt", "code_aster", "run_aster")) or (typ == "cython" and base == "code_aster")