diff --git a/lib/aslint/test/test_checkers.py b/lib/aslint/test/test_checkers.py index 6040fd91fb1c5bffff945ec05031f83a23756261..f7dbf52a29e63f7db8f824938f8b1fe509a5dad8 100644 --- a/lib/aslint/test/test_checkers.py +++ b/lib/aslint/test/test_checkers.py @@ -45,7 +45,6 @@ REG_EXT = ( class UnsupportedExtension(FilenameCat, GenericMsg): - """Unsupported extension Only these extensions are allowed for testcases: .comm, .com[0-9], .py, .data, .datg, .export, .mail, .mgib, .mmed, .msh, .msup, .[0-9]+""" @@ -62,7 +61,6 @@ class UnsupportedExtension(FilenameCat, GenericMsg): class InvalidFilename(FilenameCat, TextMsgNotFound): - """Invalid filename for a testcase Filenames matching 'aaaaNNNm.\*', 'aaaaNNNm\_\*.comm', 'aaaaNNNm\_\*.py', 'subdir/\*.py' or 'NNN.med' are expected. @@ -96,7 +94,6 @@ class InvalidFilename(FilenameCat, TextMsgNotFound): class FileNotUsed(DirnameCat, GenericMsg): - """File not used by any testcase A file is in the directory of the testcases but it is not used by any testcase.""" @@ -124,7 +121,6 @@ class FileNotUsed(DirnameCat, GenericMsg): class DatafileNotFound(DirnameCat, GenericMsg): - """Data file not found The datafile referenced in the export file does not exist.""" @@ -158,7 +154,6 @@ class DatafileNotFound(DirnameCat, GenericMsg): class DatafileTooBig(FilenameCat, GenericMsg): - """Size of datafiles too big""" apply_to = [".export"] @@ -197,7 +192,6 @@ class DatafileTooBigV(DatafileTooBig): class CommonFilesSrcValidation(DirnameCat, GenericMsg): - """Filename used in src and validation The same filename can not be used in src and validation because the both files are installed into the same destination directory.""" @@ -391,7 +385,6 @@ class InvalidExportValid(FilenameCat, InvalidExport): class ResourcesTooBig(FilenameCat, GenericMsg): - """Testcase resources are too big Time limit must be less than 300 s, memory limit less than 1024 MB in 'src'. This error can be ignored in the 'validation' repository".""" @@ -430,7 +423,6 @@ class ResourcesTooBig(FilenameCat, GenericMsg): class DuplicatedDataFile(DirnameCat, GenericMsg): - """Duplicated data files Datafiles can be shared between testcases through the .export definition. Do not add the same file several times.""" @@ -467,7 +459,6 @@ class DuplicatedDataFile(DirnameCat, GenericMsg): class BaseUnrecommendedKeyword(TextMsg): - """Unrecommended keyword in a command file This keyword should not be used in a testcase: TOLE_MACHINE.""" @@ -477,7 +468,6 @@ class BaseUnrecommendedKeyword(TextMsg): class UnrecommendedKeyword(FileContentCat, BaseUnrecommendedKeyword): - """Unrecommended keyword in a command file This keyword should not be used in a testcase: TOLE_MACHINE.""" @@ -485,7 +475,6 @@ class UnrecommendedKeyword(FileContentCat, BaseUnrecommendedKeyword): class NewUnrecommendedKeyword(DiffCat, BaseUnrecommendedKeyword): - """Unrecommended keyword in a command file This keyword should not be used in a testcase: TOLE_MACHINE.""" @@ -502,7 +491,6 @@ class ObsoleteKeyword(FileContentCat, TextMsg): class InvalidKeywordValue(FileContentCat, GenericMsg): - """Unrecommended value assigned to a keyword in a command file This value should be assigned with care in this repository.""" @@ -542,8 +530,26 @@ class InvalidKeywordValueError(FileContentCat, GenericMsg): return err -class DeprecatedComment(FileContentCat, TextMsg): +class InvalidKeywordError(FileContentCat, GenericMsg): + """Invalid keyword in a command file""" + + id = "C2015" + _invalid = ["identifier"] + _expr = [re.compile(f"(?P<kwd>{kwd}) *=", re.M) for kwd in _invalid] + _recom = re.compile("^ *#.*$", re.M) + def search(self, txt): + """Check a command file for invalid values""" + err = [] + txt = self._recom.sub("", txt) + for expr in self._expr: + mat = expr.search(txt) + if mat: + err.append(": %s" % (mat.group("kwd"),)) + return err + + +class DeprecatedComment(FileContentCat, TextMsg): """Deprecated comment in a command file This comment (TITRE) should not be used in a testcase: the title is stored in the documentation.""" @@ -555,7 +561,6 @@ class DeprecatedComment(FileContentCat, TextMsg): class LicenseNotFound(FileContentCat, COMM.LicenseNotFound): - """Summary with GPL is required The copyright and GPL summary are required. Even if there is an external copyright, it must mention www.code-aster.org""" @@ -565,7 +570,6 @@ class LicenseNotFound(FileContentCat, COMM.LicenseNotFound): class EDFCopyright(FileContentCat, COMM.EDFCopyright): - """EDF R&D Copyright not found Even if there is a copyright to another company than EDF R&D, the source has been changed for Code_Aster conformance and/or version management. @@ -582,6 +586,7 @@ class EDFCopyright(FileContentCat, COMM.EDFCopyright): class InvalidCharacter(FileContentCat, COMM.InvalidCharacter): r"""Invalid character, unexpected tabulation '\t' Tabulation character is not allowed.""" + apply_to = COMM_EXT id = "C2008"