Mon, 24 Feb 2025 15:11:18 +0100
Modified the code style checker such, that the issue category and issue number are separated by a '-' to make up the issue code (e.g E-901).
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -27,36 +27,36 @@ Codes = [ ## Function Annotations - "A001", - "A002", - "A003", + "A-001", + "A-002", + "A-003", ## Method Annotations - "A101", - "A102", + "A-101", + "A-102", ## Return Annotations - "A201", - "A202", - "A203", - "A204", - "A205", - "A206", + "A-201", + "A-202", + "A-203", + "A-204", + "A-205", + "A-206", ## Dynamically typed annotations - "A401", + "A-401", ## Type comments - "A402", + "A-402", ## Annotations Future - "A871", - "A872", - "A873", + "A-871", + "A-872", + "A-873", ## Annotation Coverage - "A881", + "A-881", ## Annotation Complexity - "A891", - "A892", + "A-891", + "A-892", ## use of typing.Union (PEP 604) - "A901", + "A-901", ## deprecated 'typing' symbols (PEP 585) - "A911", + "A-911", ] def __init__(self, source, filename, tree, select, ignore, expected, repeat, args): @@ -99,26 +99,26 @@ ( self.__checkFunctionAnnotations, ( - "A001", - "A002", - "A003", - "A101", - "A102", - "A201", - "A202", - "A203", - "A204", - "A205", - "A206", - "A401", - "A402", + "A-001", + "A-002", + "A-003", + "A-101", + "A-102", + "A-201", + "A-202", + "A-203", + "A-204", + "A-205", + "A-206", + "A-401", + "A-402", ), ), - (self.__checkAnnotationsFuture, ("A871", "A872", "A873")), - (self.__checkAnnotationsCoverage, ("A881",)), - (self.__checkAnnotationComplexity, ("A891", "A892")), - (self.__checkAnnotationPep604, ("A901",)), - (self.__checkDeprecatedTypingSymbols, ("A911",)), + (self.__checkAnnotationsFuture, ("A-871", "A-872", "A-873")), + (self.__checkAnnotationsCoverage, ("A-881",)), + (self.__checkAnnotationComplexity, ("A-891", "A-892")), + (self.__checkAnnotationPep604, ("A-901",)), + (self.__checkDeprecatedTypingSymbols, ("A-911",)), ] self.__checkers = [] @@ -259,7 +259,7 @@ # Iterate over the arguments with missing type hints, by function. for function in visitor.functionDefinitions: if function.hasTypeComment: - self.__error(function.lineno - 1, function.col_offset, "A402") + self.__error(function.lineno - 1, function.col_offset, "A-402") if function.isDynamicallyTyped() and ( allowUntypedDefs or (function.isNested and allowUntypedNested) @@ -284,7 +284,7 @@ }: continue - self.__error(function.lineno - 1, function.col_offset, "A401") + self.__error(function.lineno - 1, function.col_offset, "A-401") # Before we iterate over the function's missing annotations, check # to see if it's the closing function def in a series of @@ -317,7 +317,7 @@ # Check for type comments here since we're not considering them as # typed args if arg.hasTypeComment: - self.__error(arg.lineno - 1, arg.col_offset, "A402") + self.__error(arg.lineno - 1, arg.col_offset, "A-402") if arg.argname == "return": # return annotations have multiple possible short-circuit @@ -383,7 +383,7 @@ arg.annotationType, ) - if errorCode in ("A001", "A002", "A003"): + if errorCode in ("A-001", "A-002", "A-003"): self.__error(arg.lineno - 1, arg.col_offset, errorCode, arg.argname) else: self.__error(arg.lineno - 1, arg.col_offset, errorCode) @@ -406,18 +406,18 @@ # priority than the rest if isClassMethod: if classDecoratorType == ClassDecoratorType.CLASSMETHOD: - return "A206" + return "A-206" elif classDecoratorType == ClassDecoratorType.STATICMETHOD: - return "A205" + return "A-205" if functionType == FunctionType.SPECIAL: - return "A204" + return "A-204" elif functionType == FunctionType.PRIVATE: - return "A203" + return "A-203" elif functionType == FunctionType.PROTECTED: - return "A202" + return "A-202" else: - return "A201" + return "A-201" @lru_cache() # __IGNORE_WARNING_M519__ def __argumentErrorClassifier( @@ -443,19 +443,19 @@ # The first function argument here would be an instance of self or # class if classDecoratorType == ClassDecoratorType.CLASSMETHOD: - return "A102" + return "A-102" elif classDecoratorType != ClassDecoratorType.STATICMETHOD: # Regular class method - return "A101" + return "A-101" # Check for remaining codes if annotationType == AnnotationType.KWARG: - return "A003" + return "A-003" elif annotationType == AnnotationType.VARARG: - return "A002" + return "A-002" else: # Combine PosOnlyArgs, Args, and KwOnlyArgs - return "A001" + return "A-001" ####################################################################### ## Annotations Coverage @@ -495,7 +495,7 @@ * 100 ) if annotationsCoverage < minAnnotationsCoverage: - self.__error(0, 0, "A881", annotationsCoverage) + self.__error(0, 0, "A-881", annotationsCoverage) def __hasTypeAnnotations(self, funcNode): """ @@ -568,7 +568,7 @@ self.__error( annotation.lineno - 1, annotation.col_offset, - "A891", + "A-891", complexity, maxAnnotationComplexity, ) @@ -578,7 +578,7 @@ self.__error( annotation.lineno - 1, annotation.col_offset, - "A892", + "A-892", annotationLength, maxAnnotationLength, ) @@ -680,13 +680,13 @@ if visitor.hasTypingImports(): imports = ", ".join(visitor.getTypingImports()) - self.__error(0, 0, "A871", imports) + self.__error(0, 0, "A-871", imports) elif forceFutureAnnotations: - self.__error(0, 0, "A872") + self.__error(0, 0, "A-872") if checkFutureAnnotations and visitor.hasSimplifiedTypes(): simplifiedTypes = ", ".join(sorted(visitor.getSimplifiedTypes())) - self.__error(0, 0, "A873", simplifiedTypes) + self.__error(0, 0, "A-873", simplifiedTypes) ####################################################################### ## check use of 'typing.Union' (see PEP 604) @@ -708,7 +708,7 @@ visitor.visit(self.__tree) for node in visitor.getIssues(): - self.__error(node.lineno - 1, node.col_offset, "A901") + self.__error(node.lineno - 1, node.col_offset, "A-901") ####################################################################### ## check use of 'typing.Union' (see PEP 604) @@ -741,4 +741,4 @@ visitor.visit(self.__tree) for node, (name, replacement) in visitor.getIssues(): - self.__error(node.lineno - 1, node.col_offset, "A911", name, replacement) + self.__error(node.lineno - 1, node.col_offset, "A-911", name, replacement)
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -12,85 +12,85 @@ from PyQt6.QtCore import QCoreApplication _annotationsMessages = { - "A001": QCoreApplication.translate( + "A-001": QCoreApplication.translate( "AnnotationsChecker", "missing type annotation for function argument '{0}'" ), - "A002": QCoreApplication.translate( + "A-002": QCoreApplication.translate( "AnnotationsChecker", "missing type annotation for '*{0}'" ), - "A003": QCoreApplication.translate( + "A-003": QCoreApplication.translate( "AnnotationsChecker", "missing type annotation for '**{0}'" ), - "A101": QCoreApplication.translate( + "A-101": QCoreApplication.translate( "AnnotationsChecker", "missing type annotation for 'self' in method" ), - "A102": QCoreApplication.translate( + "A-102": QCoreApplication.translate( "AnnotationsChecker", "missing type annotation for 'cls' in classmethod" ), - "A201": QCoreApplication.translate( + "A-201": QCoreApplication.translate( "AnnotationsChecker", "missing return type annotation for public function" ), - "A202": QCoreApplication.translate( + "A-202": QCoreApplication.translate( "AnnotationsChecker", "missing return type annotation for protected function" ), - "A203": QCoreApplication.translate( + "A-203": QCoreApplication.translate( "AnnotationsChecker", "missing return type annotation for private function" ), - "A204": QCoreApplication.translate( + "A-204": QCoreApplication.translate( "AnnotationsChecker", "missing return type annotation for special method" ), - "A205": QCoreApplication.translate( + "A-205": QCoreApplication.translate( "AnnotationsChecker", "missing return type annotation for staticmethod" ), - "A206": QCoreApplication.translate( + "A-206": QCoreApplication.translate( "AnnotationsChecker", "missing return type annotation for classmethod" ), - "A401": QCoreApplication.translate( + "A-401": QCoreApplication.translate( "AnnotationsChecker", "Dynamically typed expressions (typing.Any) are disallowed", ), - "A402": QCoreApplication.translate( + "A-402": QCoreApplication.translate( "AnnotationsChecker", "Type comments are disallowed" ), - "A871": QCoreApplication.translate( + "A-871": QCoreApplication.translate( "AnnotationsChecker", "missing 'from __future__ import annotations' but imports: {0}", ), - "A872": QCoreApplication.translate( + "A-872": QCoreApplication.translate( "AnnotationsChecker", "missing 'from __future__ import annotations'" ), - "A873": QCoreApplication.translate( + "A-873": QCoreApplication.translate( "AnnotationsChecker", "missing 'from __future__ import annotations' but uses simplified type" " annotations: {0}", ), - "A881": QCoreApplication.translate( + "A-881": QCoreApplication.translate( "AnnotationsChecker", "type annotation coverage of {0}% is too low" ), - "A891": QCoreApplication.translate( + "A-891": QCoreApplication.translate( "AnnotationsChecker", "type annotation is too complex ({0} > {1})" ), - "A892": QCoreApplication.translate( + "A-892": QCoreApplication.translate( "AnnotationsChecker", "type annotation is too long ({0} > {1})" ), - "A901": QCoreApplication.translate( + "A-901": QCoreApplication.translate( "AnnotationsChecker", "'typing.Union' is deprecated, use '|' instead (see PEP 604)", ), - "A911": QCoreApplication.translate( + "A-911": QCoreApplication.translate( "AnnotationsChecker", "'typing.{0}' is deprecated, use '{1}' instead (see PEP 585)", ), } _annotationsMessagesSampleArgs = { - "A001": ["arg1"], - "A002": ["args"], - "A003": ["kwargs"], - "A871": ["Dict, List"], - "A873": ["dict, list"], - "A881": [60], - "A891": [5, 3], - "A892": [10, 7], - "A911": ["List", "list"], + "A-001": ["arg1"], + "A-002": ["args"], + "A-003": ["kwargs"], + "A-871": ["Dict, List"], + "A-873": ["dict, list"], + "A-881": [60], + "A-891": [5, 3], + "A-892": [10, 7], + "A-911": ["List", "list"], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -69,7 +69,7 @@ self.__repeat = options.repeat self.errors = [] - def error_args(self, line_number, offset, errorCode, check, *args): + def error_args(self, line_number, offset, text, _check, *args): """ Public method to collect the error messages. @@ -77,16 +77,26 @@ @type int @param offset position within line of the issue @type int - @param errorCode error message code + @param text issue message code or issue text @type str - @param check reference to the checker function + @param _check reference to the checker function @type function @param args arguments for the message @type list @return error code @rtype str """ - errorCode = super().error_args(line_number, offset, errorCode, check, *args) + code = text.split(None, 1)[0] + errorCode = code[0] + "-" + code[1:] + if self._ignore_code(errorCode): + return None + if errorCode in self.counters: + self.counters[errorCode] += 1 + else: + self.counters[errorCode] = 1 + # Don't care about expected errors or warnings + if errorCode in self.expected: + return None if errorCode and (self.counters[errorCode] == 1 or self.__repeat): self.errors.append( { @@ -347,11 +357,11 @@ "file": filename, "line": offset[0], "offset": offset[1], - "code": "E901", + "code": "E-901", "args": [exc_type.__name__, exc.args[0]], }, { - "E901": 1, + "E-901": 1, }, None, )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Mon Feb 24 15:11:18 2025 +0100 @@ -12,6 +12,7 @@ import fnmatch import json import os +import re import time from PyQt6.QtCore import QCoreApplication, Qt, QTimer, pyqtSlot @@ -454,7 +455,7 @@ "MaxDocLineLength": 88, "BlankLines": (2, 1), # top level, method "HangClosing": False, - "NoFixCodes": "E501", + "NoFixCodes": "E-501", "DocstringType": "pep257", "ShowIgnored": False, # Complexity @@ -797,6 +798,8 @@ self.__data["UnusedChecker"]["IgnoreDunderGlobals"] ) + self.__migrateIssueCodes() + def __prepareProgress(self): """ Private method to prepare the progress tab for the next run. @@ -880,6 +883,7 @@ self.__errorItem = None self.__resetStatistics() self.__clearErrors(self.files) + self.__migrateIssueCodes() self.__prepareProgress() # disable updates of the list for speed @@ -1373,6 +1377,8 @@ """ Private slot to start a code style check run. """ + self.__migrateIssueCodes() + if self.__forProject: data = { "EnabledCheckerCategories": self.__getCategories(True), @@ -1599,7 +1605,7 @@ vm.openSourceFile(fn, lineno=lineno, pos=position + 1) editor = vm.getOpenEditor(fn) - if issueCode in ["E901", "E902"]: + if issueCode in ["E-901", "E-902"]: editor.toggleSyntaxError(lineno, 0, True, message, True) else: editor.toggleWarning( @@ -2198,6 +2204,8 @@ ) ) + self.__migrateIssueCodes() + @pyqtSlot() def on_storeDefaultButton_clicked(self): """ @@ -2939,6 +2947,21 @@ else: return "" + def __migrateIssueCodes(self): + """ + Private method to migrate the issue codes to the form 'category'-'number'. + """ + pat = re.compile(r"([A-Z]{1,3}(?!-))(\d{,3}[a-z]*)") + for widget in ( + self.excludeMessagesEdit, + self.includeMessagesEdit, + self.fixIssuesEdit, + self.noFixIssuesEdit, + ): + codes = widget.text() + newCodes = pat.sub(r"\1-\2", codes) + widget.setText(newCodes) + def __initCommentedCodeCheckerWhiteList(self, whitelist): """ Private method to populate the list of commented code whitelist
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py Mon Feb 24 15:11:18 2025 +0100 @@ -22,82 +22,82 @@ import pycodestyle FixableCodeStyleIssues = [ # noqa: U200 - "D111", - "D112", - "D121", - "D131", - "D141", - "D142", - "D143", - "D144", - "D145", - "D221", - "D222", - "D231", - "D242", - "D243", - "D244", - "D245", - "D246", - "D247", - "E101", - "E111", - "E121", - "E122", - "E123", - "E124", - "E125", - "E126", - "E127", - "E128", - "E133", - "E201", - "E202", - "E203", - "E211", - "E221", - "E222", - "E223", - "E224", - "E225", - "E226", - "E227", - "E228", - "E231", - "E241", - "E242", - "E251", - "E261", - "E262", - "E271", - "E272", - "E273", - "E274", - "E301", - "E302", - "E303", - "E304", - "E305", - "E306", - "E307", - "E308", - "E401", - "E501", - "E502", - "E701", - "E702", - "E703", - "E711", - "E712", - "N804", - "N805", - "N806", - "W191", - "W291", - "W292", - "W293", - "W391", - "W603", + "D-111", + "D-112", + "D-121", + "D-131", + "D-141", + "D-142", + "D-143", + "D-144", + "D-145", + "D-221", + "D-222", + "D-231", + "D-242", + "D-243", + "D-244", + "D-245", + "D-246", + "D-247", + "E-101", + "E-111", + "E-121", + "E-122", + "E-123", + "E-124", + "E-125", + "E-126", + "E-127", + "E-128", + "E-133", + "E-201", + "E-202", + "E-203", + "E-211", + "E-221", + "E-222", + "E-223", + "E-224", + "E-225", + "E-226", + "E-227", + "E-228", + "E-231", + "E-241", + "E-242", + "E-251", + "E-261", + "E-262", + "E-271", + "E-272", + "E-273", + "E-274", + "E-301", + "E-302", + "E-303", + "E-304", + "E-305", + "E-306", + "E-307", + "E-308", + "E-401", + "E-501", + "E-502", + "E-701", + "E-702", + "E-703", + "E-711", + "E-712", + "N-804", + "N-805", + "N-806", + "W-191", + "W-291", + "W-292", + "W-293", + "W-391", + "W-603", ] @@ -174,82 +174,82 @@ self.__eol = eol self.__fixes = { - "D111": self.__fixD111, - "D112": self.__fixD112, - "D121": self.__fixD121, - "D131": self.__fixD131, - "D141": self.__fixD141, - "D142": self.__fixD142, - "D143": self.__fixD143, - "D144": self.__fixD144, - "D145": self.__fixD145, - "D221": self.__fixD221, - "D222": self.__fixD221, - "D231": self.__fixD131, - "D242": self.__fixD242, - "D243": self.__fixD243, - "D244": self.__fixD242, - "D245": self.__fixD243, - "D246": self.__fixD144, - "D247": self.__fixD247, - "E101": self.__fixE101, - "E111": self.__fixE101, - "E121": self.__fixE121, - "E122": self.__fixE122, - "E123": self.__fixE123, - "E124": self.__fixE121, - "E125": self.__fixE125, - "E126": self.__fixE126, - "E127": self.__fixE127, - "E128": self.__fixE127, - "E133": self.__fixE126, - "E201": self.__fixE201, - "E202": self.__fixE201, - "E203": self.__fixE201, - "E211": self.__fixE201, - "E221": self.__fixE221, - "E222": self.__fixE221, - "E223": self.__fixE221, - "E224": self.__fixE221, - "E225": self.__fixE225, - "E226": self.__fixE225, - "E227": self.__fixE225, - "E228": self.__fixE225, - "E231": self.__fixE231, - "E241": self.__fixE221, - "E242": self.__fixE221, - "E251": self.__fixE251, - "E261": self.__fixE261, - "E262": self.__fixE261, - "E271": self.__fixE221, - "E272": self.__fixE221, - "E273": self.__fixE221, - "E274": self.__fixE221, - "E301": self.__fixBlankLinesBefore, - "E302": self.__fixBlankLinesBefore, - "E303": self.__fixBlankLinesBefore, - "E304": self.__fixE304, - "E305": self.__fixBlankLinesBefore, - "E306": self.__fixBlankLinesBefore, - "E307": self.__fixBlankLinesBefore, - "E308": self.__fixBlankLinesBefore, - "E401": self.__fixE401, - "E501": self.__fixE501, - "E502": self.__fixE502, - "E701": self.__fixE701, - "E702": self.__fixE702, - "E703": self.__fixE702, - "E711": self.__fixE711, - "E712": self.__fixE711, - "N804": self.__fixN804, - "N805": self.__fixN804, - "N806": self.__fixN806, - "W191": self.__fixE101, - "W291": self.__fixW291, - "W292": self.__fixW292, - "W293": self.__fixW291, - "W391": self.__fixW391, - "W603": self.__fixW603, + "D-111": self.__fixD111, + "D-112": self.__fixD112, + "D-121": self.__fixD121, + "D-131": self.__fixD131, + "D-141": self.__fixD141, + "D-142": self.__fixD142, + "D-143": self.__fixD143, + "D-144": self.__fixD144, + "D-145": self.__fixD145, + "D-221": self.__fixD221, + "D-222": self.__fixD221, + "D-231": self.__fixD131, + "D-242": self.__fixD242, + "D-243": self.__fixD243, + "D-244": self.__fixD242, + "D-245": self.__fixD243, + "D-246": self.__fixD144, + "D-247": self.__fixD247, + "E-101": self.__fixE101, + "E-111": self.__fixE101, + "E-121": self.__fixE121, + "E-122": self.__fixE122, + "E-123": self.__fixE123, + "E-124": self.__fixE121, + "E-125": self.__fixE125, + "E-126": self.__fixE126, + "E-127": self.__fixE127, + "E-128": self.__fixE127, + "E-133": self.__fixE126, + "E-201": self.__fixE201, + "E-202": self.__fixE201, + "E-203": self.__fixE201, + "E-211": self.__fixE201, + "E-221": self.__fixE221, + "E-222": self.__fixE221, + "E-223": self.__fixE221, + "E-224": self.__fixE221, + "E-225": self.__fixE225, + "E-226": self.__fixE225, + "E-227": self.__fixE225, + "E-228": self.__fixE225, + "E-231": self.__fixE231, + "E-241": self.__fixE221, + "E-242": self.__fixE221, + "E-251": self.__fixE251, + "E-261": self.__fixE261, + "E-262": self.__fixE261, + "E-271": self.__fixE221, + "E-272": self.__fixE221, + "E-273": self.__fixE221, + "E-274": self.__fixE221, + "E-301": self.__fixBlankLinesBefore, + "E-302": self.__fixBlankLinesBefore, + "E-303": self.__fixBlankLinesBefore, + "E-304": self.__fixE304, + "E-305": self.__fixBlankLinesBefore, + "E-306": self.__fixBlankLinesBefore, + "E-307": self.__fixBlankLinesBefore, + "E-308": self.__fixBlankLinesBefore, + "E-401": self.__fixE401, + "E-501": self.__fixE501, + "E-502": self.__fixE502, + "E-701": self.__fixE701, + "E-702": self.__fixE702, + "E-703": self.__fixE702, + "E-711": self.__fixE711, + "E-712": self.__fixE711, + "N-804": self.__fixN804, + "N-805": self.__fixN804, + "N-806": self.__fixN806, + "W-191": self.__fixE101, + "W-291": self.__fixW291, + "W-292": self.__fixW292, + "W-293": self.__fixW291, + "W-391": self.__fixW391, + "W-603": self.__fixW603, } self.__modified = False self.__stackLogical = [] @@ -299,7 +299,7 @@ fp.write(txt) except (OSError, UnicodeError) as err: # Could not save the file! Skipping it. Reason: {0} - return ("FIXWRITE_ERROR", [str(err)]) + return ("FIX-WRITE_ERROR", [str(err)]) return None @@ -633,7 +633,7 @@ line += 1 # Triple single quotes converted to triple double quotes. - return (1, "FIXD111", [], 0) + return (1, "FIX-D111", [], 0) def __fixD112(self, code, line, _pos): """ @@ -653,7 +653,7 @@ @rtype tuple of (int, str, list or int, int) """ line -= 1 - if code == "D112": + if code == "D-112": insertChar = "r" else: return (0, "", 0) @@ -665,7 +665,7 @@ ) self.__source[line] = newText # Introductory quotes corrected to be {0}""" - return (1, "FIXD112", [insertChar], 0) + return (1, "FIX-D112", [insertChar], 0) def __fixD121(self, code, line, pos, apply=False): """ @@ -702,7 +702,7 @@ self.__source[line] = docstring self.__source[line + 1] = "" # Single line docstring put on one line. - return (1, "FIXD121", [], 0) + return (1, "FIX-D121", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -752,7 +752,7 @@ if newText: self.__source[line] = newText # Period added to summary line. - return (1, "FIXD131", [], 0) + return (1, "FIX-D131", [], 0) else: return (0, "", [], 0) @@ -780,7 +780,7 @@ line -= 1 self.__source[line - 1] = "" # Blank line before function/method docstring removed. - return (1, "FIXD141", [], 0) + return (1, "FIX-D141", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -810,7 +810,7 @@ line -= 1 self.__source[line] = self.__eol + self.__source[line] # Blank line inserted before class docstring. - return (1, "FIXD142", [], 0) + return (1, "FIX-D142", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -840,7 +840,7 @@ line -= 1 self.__source[line] += self.__eol # Blank line inserted after class docstring. - return (1, "FIXD143", [], 0) + return (1, "FIX-D143", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -874,7 +874,7 @@ self.__source[line] += self.__eol # Blank line inserted after docstring summary. - return (1, "FIXD144", [], 0) + return (1, "FIX-D144", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -904,7 +904,7 @@ line -= 1 self.__source[line] = self.__eol + self.__source[line] # Blank line inserted after last paragraph of docstring. - return (1, "FIXD145", [], 0) + return (1, "FIX-D145", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -934,7 +934,7 @@ line -= 1 indent = self.__getIndent(self.__source[line]) source = self.__source[line].strip() - if code == "D221": + if code == "D-221": # leading if source.startswith(("r", "u")): first, second = source[:4], source[4:].strip() @@ -945,12 +945,12 @@ first, second = source[:-3].strip(), source[-3:] newText = indent + first + self.__eol + indent + second + self.__eol self.__source[line] = newText - if code == "D221": + if code == "D-221": # Leading quotes put on separate line. - msg = "FIXD221" + msg = "FIX-D221" else: # Trailing quotes put on separate line. - msg = "FIXD222" + msg = "FIX-D222" return (1, msg, [], 0) else: fixId = self.__getID() @@ -980,12 +980,12 @@ if apply: line -= 1 self.__source[line - 1] = "" - if code == "D242": + if code == "D-242": # Blank line before class docstring removed. - msg = "FIXD242" + msg = "FIX-D242" else: # Blank line before function/method docstring removed. - msg = "FIXD244" + msg = "FIX-D244" return (1, msg, [], 0) else: fixId = self.__getID() @@ -1015,12 +1015,12 @@ if apply: line -= 1 self.__source[line + 1] = "" - if code == "D243": + if code == "D-243": # Blank line after class docstring removed. - msg = "FIXD243" + msg = "FIX-D243" else: # Blank line after function/method docstring removed. - msg = "FIXD245" + msg = "FIX-D245" return (1, msg, [], 0) else: fixId = self.__getID() @@ -1051,7 +1051,7 @@ line -= 1 self.__source[line - 1] = "" # Blank line after last paragraph removed. - return (1, "FIXD247", [], 0) + return (1, "FIX-D247", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -1080,12 +1080,12 @@ fixedLine = self.__reindenter.fixedLine(line - 1) if fixedLine is not None and fixedLine != self.__source[line - 1]: self.__source[line - 1] = fixedLine - if code in ["E101", "W191"]: + if code in ["E-101", "W-191"]: # Tab converted to 4 spaces. - msg = "FIXE101" + msg = "FIX-E101" else: # Indentation adjusted to be a multiple of four. - msg = "FIXE111" + msg = "FIX-E111" return (1, msg, [], 0) else: return (0, "", [], 0) @@ -1116,12 +1116,12 @@ # Fix by adjusting initial indent level. changed = self.__fixReindent(line, pos, logical) if changed: - if code == "E121": + if code == "E-121": # Indentation of continuation line corrected. - msg = "FIXE121" - elif code == "E124": + msg = "FIX-E121" + elif code == "E-124": # Indentation of closing bracket corrected. - msg = "FIXE124" + msg = "FIX-E124" return (1, msg, [], 0) return (0, "", [], 0) else: @@ -1162,7 +1162,7 @@ indentation + self.__indentWord + text.lstrip() ) # Missing indentation of continuation line corrected. - return (1, "FIXE122", [], 0) + return (1, "FIX-E122", [], 0) return (0, "", [], 0) else: fixId = self.__getID() @@ -1204,7 +1204,7 @@ changed = True if changed: # Closing bracket aligned to opening bracket. - return (1, "FIXE123", [], 0) + return (1, "FIX-E123", [], 0) return (0, "", [], 0) else: fixId = self.__getID() @@ -1243,7 +1243,7 @@ self.__getIndent(text) + self.__indentWord + text.lstrip() ) # Indentation level changed. - return (1, "FIXE125", [], 0) + return (1, "FIX-E125", [], 0) return (0, "", [], 0) else: fixId = self.__getID() @@ -1290,7 +1290,7 @@ changed = True if changed: # Indentation level of hanging indentation changed. - return (1, "FIXE126", [], 0) + return (1, "FIX-E126", [], 0) return (0, "", [], 0) else: fixId = self.__getID() @@ -1352,7 +1352,7 @@ changed = True if changed: # Visual indentation corrected. - return (1, "FIXE127", [], 0) + return (1, "FIX-E127", [], 0) return (0, "", [], 0) else: fixId = self.__getID() @@ -1388,7 +1388,7 @@ self.__source[line] = newText # Extraneous whitespace removed. - return (1, "FIXE201", [], 0) + return (1, "FIX-E201", [], 0) def __fixE221(self, _code, line, pos): """ @@ -1419,7 +1419,7 @@ return (0, "", [], 0) self.__source[line] = newText - return (1, "FIXE221", [], 0) + return (1, "FIX-E221", [], 0) def __fixE225(self, _code, line, pos): """ @@ -1464,7 +1464,7 @@ self.__source[line] = newText # Missing whitespaces added. - return (1, "FIXE225", [], 0) + return (1, "FIX-E225", [], 0) def __fixE231(self, _code, line, pos): """ @@ -1489,7 +1489,7 @@ self.__source[line][:pos] + " " + self.__source[line][pos:] ) # Missing whitespace added. - return (1, "FIXE231", [], 0) + return (1, "FIX-E231", [], 0) def __fixE251(self, _code, line, pos): """ @@ -1527,7 +1527,7 @@ else: self.__source[line] = newText # Extraneous whitespace removed. - return (1, "FIXE251", [], 0) + return (1, "FIX-E251", [], 0) def __fixE261(self, _code, line, pos): """ @@ -1553,7 +1553,7 @@ newText = left + (" # " + right if right.strip() else right) self.__source[line] = newText # Whitespace around comment sign corrected. - return (1, "FIXE261", [], 0) + return (1, "FIX-E261", [], 0) def __fixBlankLinesBefore(self, code, line, pos, apply=False): """ @@ -1576,9 +1576,9 @@ @rtype tuple of (int, str, list or int, int) """ if apply: - if code in ["E301", "E306", "E307"]: + if code in ["E-301", "E-306", "E-307"]: blankLinesBefore = self.__blankLines["method"] - elif code == "E308": + elif code == "E-308": blankLinesBefore = 1 else: blankLinesBefore = self.__blankLines["toplevel"] @@ -1601,7 +1601,7 @@ self.__source.insert(line, self.__eol) delta += 1 # %n blank line(s) inserted. - return (1, "FIXE302+", blankLinesBefore - blanks, 0) + return (1, "FIX-E302+", blankLinesBefore - blanks, 0) elif delta > 0: # delete superfluous blank lines while delta > 0: @@ -1609,7 +1609,7 @@ line -= 1 delta -= 1 # %n superfluous line(s) removed. - return (1, "FIXE302-", blanks - blankLinesBefore, 0) + return (1, "FIX-E302-", blanks - blankLinesBefore, 0) else: return (0, "", [], 0) else: @@ -1646,7 +1646,7 @@ else: break # Superfluous blank lines after function decorator removed. - return (1, "FIXE304", [], 0) + return (1, "FIX-E304", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -1692,7 +1692,7 @@ ) self.__source[line] = newText # Imports were put on separate lines. - return (1, "FIXE401", [], 0) + return (1, "FIX-E401", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -1748,7 +1748,7 @@ newNextText = "" self.__source[line + 1] = newNextText # Long lines have been shortened. - return (1, "FIXE501", [], 0) + return (1, "FIX-E501", [], 0) else: return (0, "", [], 0) else: @@ -1777,7 +1777,7 @@ self.__source[line - 1].rstrip("\n\r \t\\") + self.__eol ) # Redundant backslash in brackets removed. - return (1, "FIXE502", [], 0) + return (1, "FIX-E502", [], 0) def __fixE701(self, code, line, pos, apply=False): """ @@ -1813,7 +1813,7 @@ ) self.__source[line] = newText # Compound statement corrected. - return (1, "FIXE701", [], 0) + return (1, "FIX-E701", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -1853,7 +1853,7 @@ second = text[pos:].lstrip("\n\r \t;") self.__source[line] = first + self.__getIndent(text) + second # Compound statement corrected. - return (1, "FIXE702", [], 0) + return (1, "FIX-E702", [], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -1899,7 +1899,7 @@ self.__source[line] = " ".join([left, center, right]) # Comparison to None/True/False corrected. - return (1, "FIXE711", [], 0) + return (1, "FIX-E711", [], 0) def __fixN804(self, code, line, pos, apply=False): """ @@ -1924,7 +1924,7 @@ if apply: line -= 1 text = self.__source[line] - if code == "N804": + if code == "N-804": arg = "cls" else: arg = "self" @@ -1949,7 +1949,7 @@ newText = left + center + right self.__source[line] = newText # '{0}' argument added. - return (1, "FIXN804", [arg], 0) + return (1, "FIX-N804", [arg], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -2013,7 +2013,7 @@ self.__source[line] = indent + right # '{0}' argument removed. - return (1, "FIXN806", [arg], 0) + return (1, "FIX-N806", [arg], 0) else: fixId = self.__getID() self.__stack.append((fixId, code, line, pos)) @@ -2040,7 +2040,7 @@ r"[\t ]+(\r?)$", r"\1", self.__source[line - 1] ) # Whitespace stripped from end of line. - return (1, "FIXW291", [], 0) + return (1, "FIX-W291", [], 0) def __fixW292(self, _code, line, _pos): """ @@ -2061,7 +2061,7 @@ """ self.__source[line - 1] += self.__eol # newline added to end of file. - return (1, "FIXW292", [], 0) + return (1, "FIX-W292", [], 0) def __fixW391(self, _code, line, _pos): """ @@ -2088,7 +2088,7 @@ else: break # Superfluous trailing blank lines removed from end of file. - return (1, "FIXW391", [], 0) + return (1, "FIX-W391", [], 0) def __fixW603(self, _code, line, _pos): """ @@ -2109,7 +2109,7 @@ """ self.__source[line - 1] = self.__source[line - 1].replace("<>", "!=") # '<>' replaced by '!='. - return (1, "FIXW603", [], 0) + return (1, "FIX-W603", [], 0) class Reindenter:
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Complexity/ComplexityChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Complexity/ComplexityChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -19,9 +19,9 @@ """ Codes = [ - "C101", - "C111", - "C112", + "C-101", + "C-111", + "C-112", ] def __init__(self, source, filename, tree, select, ignore, args): @@ -61,8 +61,8 @@ self.errors = [] checkersWithCodes = [ - (self.__checkMcCabeComplexity, ("C101",)), - (self.__checkLineComplexity, ("C111", "C112")), + (self.__checkMcCabeComplexity, ("C-101",)), + (self.__checkLineComplexity, ("C-111", "C-112")), ] self.__checkers = [] @@ -152,7 +152,7 @@ visitor.preorder(tree, visitor) for graph in visitor.graphs.values(): if graph.complexity() > maxComplexity: - self.__error(graph.lineno, 0, "C101", graph.entity, graph.complexity()) + self.__error(graph.lineno, 0, "C-101", graph.entity, graph.complexity()) def __checkLineComplexity(self): """ @@ -177,10 +177,10 @@ for line, complexity in sortedItems: if complexity > maxLineComplexity: - self.__error(line, 0, "C111", complexity) + self.__error(line, 0, "C-111", complexity) if score > maxLineComplexityScore: - self.__error(0, 0, "C112", score) + self.__error(0, 0, "C-112", score) class LineComplexityVisitor(ast.NodeVisitor):
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Complexity/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Complexity/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -12,19 +12,19 @@ from PyQt6.QtCore import QCoreApplication _complexityMessages = { - "C101": QCoreApplication.translate( + "C-101": QCoreApplication.translate( "ComplexityChecker", "'{0}' is too complex ({1})" ), - "C111": QCoreApplication.translate( + "C-111": QCoreApplication.translate( "ComplexityChecker", "source code line is too complex ({0})" ), - "C112": QCoreApplication.translate( + "C-112": QCoreApplication.translate( "ComplexityChecker", "overall source code line complexity is too high ({0})" ), } _complexityMessagesSampleArgs = { - "C101": ["foo.bar", "42"], - "C111": [42], - "C112": [12.0], + "C-101": ["foo.bar", "42"], + "C-111": [42], + "C-112": [12.0], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -133,61 +133,61 @@ """ Codes = [ - "D101", - "D102", - "D103", - "D104", - "D105", - "D111", - "D112", - "D121", - "D122", - "D130", - "D131", - "D132", - "D133", - "D134", - "D141", - "D142", - "D143", - "D144", - "D145", - "D201", - "D202.1", - "D202.2", - "D203", - "D205", - "D206", - "D221", - "D222", - "D231", - "D232", - "D234r", - "D234y", - "D235r", - "D235y", - "D236", - "D237", - "D238", - "D239", - "D242", - "D243", - "D244", - "D245", - "D246", - "D247", - "D250", - "D251", - "D252", - "D253", - "D260", - "D261", - "D262", - "D263", - "D270", - "D271", - "D272", - "D273", + "D-101", + "D-102", + "D-103", + "D-104", + "D-105", + "D-111", + "D-112", + "D-121", + "D-122", + "D-130", + "D-131", + "D-132", + "D-133", + "D-134", + "D-141", + "D-142", + "D-143", + "D-144", + "D-145", + "D-201", + "D-202.1", + "D-202.2", + "D-203", + "D-205", + "D-206", + "D-221", + "D-222", + "D-231", + "D-232", + "D-234r", + "D-234y", + "D-235r", + "D-235y", + "D-236", + "D-237", + "D-238", + "D-239", + "D-242", + "D-243", + "D-244", + "D-245", + "D-246", + "D-247", + "D-250", + "D-251", + "D-252", + "D-253", + "D-260", + "D-261", + "D-262", + "D-263", + "D-270", + "D-271", + "D-272", + "D-273", ] def __init__( @@ -254,80 +254,80 @@ if self.__docType == "pep257": checkersWithCodes = { "moduleDocstring": [ - (self.__checkModulesDocstrings, ("D101",)), + (self.__checkModulesDocstrings, ("D-101",)), ], "functionDocstring": [], "classDocstring": [ - (self.__checkClassDocstring, ("D104", "D105")), - (self.__checkBlankBeforeAndAfterClass, ("D142", "D143")), + (self.__checkClassDocstring, ("D-104", "D-105")), + (self.__checkBlankBeforeAndAfterClass, ("D-142", "D-143")), ], "methodDocstring": [], "defDocstring": [ - (self.__checkFunctionDocstring, ("D102", "D103")), - (self.__checkImperativeMood, ("D132",)), - (self.__checkNoSignature, ("D133",)), - (self.__checkReturnType, ("D134",)), - (self.__checkNoBlankLineBefore, ("D141",)), + (self.__checkFunctionDocstring, ("D-102", "D-103")), + (self.__checkImperativeMood, ("D-132",)), + (self.__checkNoSignature, ("D-133",)), + (self.__checkReturnType, ("D-134",)), + (self.__checkNoBlankLineBefore, ("D-141",)), ], "docstring": [ - (self.__checkTripleDoubleQuotes, ("D111",)), - (self.__checkBackslashes, ("D112",)), - (self.__checkOneLiner, ("D121",)), - (self.__checkIndent, ("D122",)), - (self.__checkSummary, ("D130",)), - (self.__checkEndsWithPeriod, ("D131",)), - (self.__checkBlankAfterSummary, ("D144",)), - (self.__checkBlankAfterLastParagraph, ("D145",)), + (self.__checkTripleDoubleQuotes, ("D-111",)), + (self.__checkBackslashes, ("D-112",)), + (self.__checkOneLiner, ("D-121",)), + (self.__checkIndent, ("D-122",)), + (self.__checkSummary, ("D-130",)), + (self.__checkEndsWithPeriod, ("D-131",)), + (self.__checkBlankAfterSummary, ("D-144",)), + (self.__checkBlankAfterLastParagraph, ("D-145",)), ], } elif self.__docType in ("eric", "eric_black"): checkersWithCodes = { "moduleDocstring": [ - (self.__checkModulesDocstrings, ("D101", "D201")), + (self.__checkModulesDocstrings, ("D-101", "D-201")), ], "functionDocstring": [], "classDocstring": [ - (self.__checkClassDocstring, ("D104", "D205", "D206")), + (self.__checkClassDocstring, ("D-104", "D-205", "D-206")), ( self.__checkEricNoBlankBeforeAndAfterClassOrFunction, - ("D242", "D243"), + ("D-242", "D-243"), ), - (self.__checkEricSignal, ("D260", "D261", "D262", "D263")), + (self.__checkEricSignal, ("D-260", "D-261", "D-262", "D-263")), ], "methodDocstring": [ - (self.__checkEricSummary, ("D232")), + (self.__checkEricSummary, ("D-232")), ], "defDocstring": [ ( self.__checkFunctionDocstring, - ("D102", "D202.1", "D202.2", "D203"), + ("D-102", "D-202.1", "D-202.2", "D-203"), ), - (self.__checkImperativeMood, ("D132",)), - (self.__checkNoSignature, ("D133",)), - (self.__checkEricReturn, ("D234r", "D235r")), - (self.__checkEricYield, ("D234y", "D235y")), + (self.__checkImperativeMood, ("D-132",)), + (self.__checkNoSignature, ("D-133",)), + (self.__checkEricReturn, ("D-234r", "D-235r")), + (self.__checkEricYield, ("D-234y", "D-235y")), ( self.__checkEricFunctionArguments, - ("D236", "D237", "D238", "D239"), + ("D-236", "D-237", "D-238", "D-239"), ), ( self.__checkEricNoBlankBeforeAndAfterClassOrFunction, - ("D244", "D245"), + ("D-244", "D-245"), ), - (self.__checkEricException, ("D250", "D251", "D252", "D253")), - (self.__checkEricDocumentationSequence, ("D270", "D271")), - (self.__checkEricDocumentationDeprecatedTags, ("D272",)), - (self.__checkEricDocumentationIndent, ("D273",)), + (self.__checkEricException, ("D-250", "D-251", "D-252", "D-253")), + (self.__checkEricDocumentationSequence, ("D-270", "D-271")), + (self.__checkEricDocumentationDeprecatedTags, ("D-272",)), + (self.__checkEricDocumentationIndent, ("D-273",)), ], "docstring": [ - (self.__checkTripleDoubleQuotes, ("D111",)), - (self.__checkBackslashes, ("D112",)), - (self.__checkIndent, ("D122",)), - (self.__checkSummary, ("D130",)), - (self.__checkEricEndsWithPeriod, ("D231",)), - (self.__checkEricBlankAfterSummary, ("D246",)), - (self.__checkEricNBlankAfterLastParagraph, ("D247",)), - (self.__checkEricQuotesOnSeparateLines, ("D222", "D223")), + (self.__checkTripleDoubleQuotes, ("D-111",)), + (self.__checkBackslashes, ("D-112",)), + (self.__checkIndent, ("D-122",)), + (self.__checkSummary, ("D-130",)), + (self.__checkEricEndsWithPeriod, ("D-231",)), + (self.__checkEricBlankAfterSummary, ("D-246",)), + (self.__checkEricNBlankAfterLastParagraph, ("D-247",)), + (self.__checkEricQuotesOnSeparateLines, ("D-222", "D-223")), ], } @@ -730,18 +730,18 @@ @type DocStyleContext """ if docstringContext is None: - self.__error(context.start(), 0, "D101") + self.__error(context.start(), 0, "D-101") return docstring = docstringContext.ssource() if not docstring or not docstring.strip() or not docstring.strip("'\""): - self.__error(context.start(), 0, "D101") + self.__error(context.start(), 0, "D-101") if ( self.__docType == "eric" and docstring.strip("'\"").strip() == "Module documentation goes here." ): - self.__error(docstringContext.end(), 0, "D201") + self.__error(docstringContext.end(), 0, "D-201") return def __checkFunctionDocstring(self, docstringContext, context): @@ -757,11 +757,11 @@ functionName = context.source()[0].lstrip().split()[1].split("(")[0] if functionName.startswith("_") and not functionName.endswith("__"): if self.__docType == "eric": - code = "D203" + code = "D-203" else: - code = "D103" + code = "D-103" else: - code = "D102" + code = "D-102" if docstringContext is None: self.__error(context.start(), 0, code) @@ -773,11 +773,11 @@ if self.__docType == "eric": if docstring.strip("'\"").strip() == "Function documentation goes here.": - self.__error(docstringContext.end(), 0, "D202.1") + self.__error(docstringContext.end(), 0, "D-202.1") return if "DESCRIPTION" in docstring or "TYPE" in docstring: - self.__error(docstringContext.end(), 0, "D202.2") + self.__error(docstringContext.end(), 0, "D-202.2") return def __checkClassDocstring(self, docstringContext, context): @@ -793,11 +793,11 @@ className = context.source()[0].lstrip().split()[1].split("(")[0] if className.startswith("_"): if self.__docType == "eric": - code = "D205" + code = "D-205" else: - code = "D105" + code = "D-105" else: - code = "D104" + code = "D-104" if docstringContext is None: self.__error(context.start(), 0, code) @@ -812,7 +812,7 @@ self.__docType == "eric" and docstring.strip("'\"").strip() == "Class documentation goes here." ): - self.__error(docstringContext.end(), 0, "D206") + self.__error(docstringContext.end(), 0, "D-206") return def __checkTripleDoubleQuotes(self, docstringContext, _context): @@ -830,7 +830,7 @@ docstring = docstringContext.ssource().strip() if not docstring.startswith(('"""', 'r"""', 'u"""')): - self.__error(docstringContext.start(), 0, "D111") + self.__error(docstringContext.start(), 0, "D-111") def __checkBackslashes(self, docstringContext, _context): """ @@ -847,7 +847,7 @@ docstring = docstringContext.ssource().strip() if "\\" in docstring and not docstring.startswith('r"""'): - self.__error(docstringContext.start(), 0, "D112") + self.__error(docstringContext.start(), 0, "D-112") def __checkOneLiner(self, docstringContext, context): """ @@ -875,7 +875,7 @@ # account for a trailing dot modLen += 1 if modLen <= self.__maxLineLength: - self.__error(docstringContext.start(), 0, "D121") + self.__error(docstringContext.start(), 0, "D-121") def __checkIndent(self, docstringContext, context): """ @@ -902,7 +902,7 @@ 0 if context.contextType() == "module" else len(context.indent()) + 4 ) if indent != expectedIndent: - self.__error(docstringContext.start(), 0, "D122") + self.__error(docstringContext.start(), 0, "D-122") def __checkSummary(self, docstringContext, _context): """ @@ -918,7 +918,7 @@ summary, lineNumber = self.__getSummaryLine(docstringContext) if summary == "": - self.__error(docstringContext.start() + lineNumber, 0, "D130") + self.__error(docstringContext.start() + lineNumber, 0, "D-130") def __checkEndsWithPeriod(self, docstringContext, _context): """ @@ -934,7 +934,7 @@ summary, lineNumber = self.__getSummaryLine(docstringContext) if not summary.endswith("."): - self.__error(docstringContext.start() + lineNumber, 0, "D131") + self.__error(docstringContext.start() + lineNumber, 0, "D-131") def __checkImperativeMood(self, docstringContext, _context): """ @@ -953,7 +953,7 @@ if summary: firstWord = summary.strip().split()[0] if firstWord.endswith("s") and not firstWord.endswith("ss"): - self.__error(docstringContext.start() + lineNumber, 0, "D132") + self.__error(docstringContext.start() + lineNumber, 0, "D-132") def __checkNoSignature(self, docstringContext, context): """ @@ -974,7 +974,7 @@ " ", "" ) and functionName + "()" not in summary.replace(" ", ""): # report only, if it is not an abbreviated form (i.e. function() ) - self.__error(docstringContext.start() + lineNumber, 0, "D133") + self.__error(docstringContext.start() + lineNumber, 0, "D-133") def __checkReturnType(self, docstringContext, context): """ @@ -1001,7 +1001,7 @@ set(return_) - {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} != set() ): - self.__error(docstringContext.end(), 0, "D134") + self.__error(docstringContext.end(), 0, "D-134") def __checkNoBlankLineBefore(self, docstringContext, context): """ @@ -1026,7 +1026,7 @@ return if not contextLines[cti - 1].strip(): - self.__error(docstringContext.start(), 0, "D141") + self.__error(docstringContext.start(), 0, "D-141") def __checkBlankBeforeAndAfterClass(self, docstringContext, context): """ @@ -1064,9 +1064,9 @@ return if contextLines[start - 1].strip(): - self.__error(docstringContext.start(), 0, "D142") + self.__error(docstringContext.start(), 0, "D-142") if contextLines[end + 1].strip(): - self.__error(docstringContext.end(), 0, "D143") + self.__error(docstringContext.end(), 0, "D-143") def __checkBlankAfterSummary(self, docstringContext, _context): """ @@ -1088,7 +1088,7 @@ summary, lineNumber = self.__getSummaryLine(docstringContext) if len(docstrings) > 2 and docstrings[lineNumber + 1].strip(): - self.__error(docstringContext.start() + lineNumber, 0, "D144") + self.__error(docstringContext.start() + lineNumber, 0, "D-144") def __checkBlankAfterLastParagraph(self, docstringContext, _context): """ @@ -1109,7 +1109,7 @@ return if docstrings[-2].strip(): - self.__error(docstringContext.end(), 0, "D145") + self.__error(docstringContext.end(), 0, "D-145") ################################################################## ## Checking functionality below (eric specific ones) @@ -1130,9 +1130,9 @@ lines = docstringContext.source() if lines[0].strip().strip("ru\"'"): - self.__error(docstringContext.start(), 0, "D221") + self.__error(docstringContext.start(), 0, "D-221") if lines[-1].strip().strip("\"'"): - self.__error(docstringContext.end(), 0, "D222") + self.__error(docstringContext.end(), 0, "D-222") def __checkEricEndsWithPeriod(self, docstringContext, _context): """ @@ -1159,7 +1159,7 @@ self.__error( docstringContext.start() + lineNumber + len(summaryLines) - 1, 0, - "D231", + "D-231", ) def __checkEricReturn(self, docstringContext, context): @@ -1184,13 +1184,13 @@ set(return_) - {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} != set() ): - self.__error(docstringContext.end(), 0, "D234r") + self.__error(docstringContext.end(), 0, "D-234r") else: if ( set(return_) - {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} == set() ): - self.__error(docstringContext.end(), 0, "D235r") + self.__error(docstringContext.end(), 0, "D-235r") def __checkEricYield(self, docstringContext, context): """ @@ -1211,10 +1211,10 @@ ] if "@yield" not in docstringContext.ssource(): if set(yield_) - {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} != set(): - self.__error(docstringContext.end(), 0, "D234y") + self.__error(docstringContext.end(), 0, "D-234y") else: if set(yield_) - {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} == set(): - self.__error(docstringContext.end(), 0, "D235y") + self.__error(docstringContext.end(), 0, "D-235y") def __checkEricFunctionArguments(self, docstringContext, context): """ @@ -1253,11 +1253,11 @@ if tagstring.count("@param") + tagstring.count("@keyparam") < len( argNames + kwNames ): - self.__error(docstringContext.end(), 0, "D236") + self.__error(docstringContext.end(), 0, "D-236") elif tagstring.count("@param") + tagstring.count("@keyparam") > len( argNames + kwNames ): - self.__error(docstringContext.end(), 0, "D237") + self.__error(docstringContext.end(), 0, "D-237") else: # extract @param and @keyparam from docstring args = [] @@ -1274,10 +1274,10 @@ # do the checks for name in kwNames: if name not in kwargs: - self.__error(docstringContext.end(), 0, "D238") + self.__error(docstringContext.end(), 0, "D-238") return if argNames + kwNames != args: - self.__error(docstringContext.end(), 0, "D239") + self.__error(docstringContext.end(), 0, "D-239") def __checkEricException(self, docstringContext, context): """ @@ -1317,10 +1317,10 @@ and "@raise" not in docstringContext.ssource() ): if exceptions - {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} != set(): - self.__error(docstringContext.end(), 0, "D250") + self.__error(docstringContext.end(), 0, "D-250") else: if exceptions - {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} == set(): - self.__error(docstringContext.end(), 0, "D251") + self.__error(docstringContext.end(), 0, "D-251") else: # step 1: extract documented exceptions documentedExceptions = set() @@ -1334,12 +1334,12 @@ # step 2: report undocumented exceptions for exception in raisedExceptions: if exception not in documentedExceptions: - self.__error(docstringContext.end(), 0, "D252", exception) + self.__error(docstringContext.end(), 0, "D-252", exception) # step 3: report undefined signals for exception in documentedExceptions: if exception not in raisedExceptions: - self.__error(docstringContext.end(), 0, "D253", exception) + self.__error(docstringContext.end(), 0, "D-253", exception) def __checkEricSignal(self, docstringContext, context): """ @@ -1368,10 +1368,10 @@ definedSignals.add(tokens[i - 2][1]) if "@signal" not in docstringContext.ssource() and definedSignals: - self.__error(docstringContext.end(), 0, "D260") + self.__error(docstringContext.end(), 0, "D-260") elif "@signal" in docstringContext.ssource(): if not definedSignals: - self.__error(docstringContext.end(), 0, "D261") + self.__error(docstringContext.end(), 0, "D-261") else: # step 1: extract documented signals documentedSignals = set() @@ -1388,12 +1388,12 @@ # step 2: report undocumented signals for signal in definedSignals: if signal not in documentedSignals: - self.__error(docstringContext.end(), 0, "D262", signal) + self.__error(docstringContext.end(), 0, "D-262", signal) # step 3: report undefined signals for signal in documentedSignals: if signal not in definedSignals: - self.__error(docstringContext.end(), 0, "D263", signal) + self.__error(docstringContext.end(), 0, "D-263", signal) def __checkEricBlankAfterSummary(self, docstringContext, _context): """ @@ -1418,7 +1418,7 @@ len(docstrings) - 2 > lineNumber + len(summaryLines) - 1 and docstrings[lineNumber + len(summaryLines)].strip() ): - self.__error(docstringContext.start() + lineNumber, 0, "D246") + self.__error(docstringContext.start() + lineNumber, 0, "D-246") def __checkEricNoBlankBeforeAndAfterClassOrFunction( self, docstringContext, context @@ -1460,14 +1460,14 @@ if isClassContext: if not contextLines[start - 1].strip(): - self.__error(docstringContext.start(), 0, "D242") + self.__error(docstringContext.start(), 0, "D-242") if not contextLines[end + 1].strip() and self.__docType == "eric": - self.__error(docstringContext.end(), 0, "D243") + self.__error(docstringContext.end(), 0, "D-243") elif contextLines[end + 1].strip() and self.__docType == "eric_black": - self.__error(docstringContext.end(), 0, "D143") + self.__error(docstringContext.end(), 0, "D-143") else: if not contextLines[start - 1].strip(): - self.__error(docstringContext.start(), 0, "D244") + self.__error(docstringContext.start(), 0, "D-244") if not contextLines[end + 1].strip(): if ( self.__docType == "eric_black" @@ -1476,7 +1476,7 @@ ): return - self.__error(docstringContext.end(), 0, "D245") + self.__error(docstringContext.end(), 0, "D-245") def __checkEricNBlankAfterLastParagraph(self, docstringContext, _context): """ @@ -1497,7 +1497,7 @@ return if not docstrings[-2].strip(): - self.__error(docstringContext.end(), 0, "D247") + self.__error(docstringContext.end(), 0, "D-247") def __checkEricSummary(self, docstringContext, context): """ @@ -1523,18 +1523,18 @@ if functionName == "__init__": if firstWord != "constructor": self.__error( - docstringContext.start() + lineNumber, 0, "D232", "constructor" + docstringContext.start() + lineNumber, 0, "D-232", "constructor" ) elif functionName.startswith("__") and functionName.endswith("__"): if firstWord != "special": self.__error( - docstringContext.start() + lineNumber, 0, "D232", "special" + docstringContext.start() + lineNumber, 0, "D-232", "special" ) elif context.special() == "staticmethod": secondWord = summary.strip().split(None, 2)[1].lower() if firstWord != "static" and secondWord != "static": self.__error( - docstringContext.start() + lineNumber, 0, "D232", "static" + docstringContext.start() + lineNumber, 0, "D-232", "static" ) elif secondWord == "static": if functionName.startswith(("__", "on_")): @@ -1542,7 +1542,7 @@ self.__error( docstringContext.start() + lineNumber, 0, - "D232", + "D-232", "private static", ) elif functionName.startswith("_") or functionName.endswith("Event"): @@ -1550,7 +1550,7 @@ self.__error( docstringContext.start() + lineNumber, 0, - "D232", + "D-232", "protected static", ) else: @@ -1558,7 +1558,7 @@ self.__error( docstringContext.start() + lineNumber, 0, - "D232", + "D-232", "public static", ) elif ( @@ -1568,7 +1568,7 @@ secondWord = summary.strip().split(None, 2)[1].lower() if firstWord != "class" and secondWord != "class": self.__error( - docstringContext.start() + lineNumber, 0, "D232", "class" + docstringContext.start() + lineNumber, 0, "D-232", "class" ) elif secondWord == "class": if functionName.startswith(("__", "on_")): @@ -1576,7 +1576,7 @@ self.__error( docstringContext.start() + lineNumber, 0, - "D232", + "D-232", "private class", ) elif functionName.startswith("_") or functionName.endswith("Event"): @@ -1584,7 +1584,7 @@ self.__error( docstringContext.start() + lineNumber, 0, - "D232", + "D-232", "protected class", ) else: @@ -1592,23 +1592,23 @@ self.__error( docstringContext.start() + lineNumber, 0, - "D232", + "D-232", "public class", ) elif functionName.startswith(("__", "on_")): if firstWord != "private": self.__error( - docstringContext.start() + lineNumber, 0, "D232", "private" + docstringContext.start() + lineNumber, 0, "D-232", "private" ) elif functionName.startswith("_") or functionName.endswith("Event"): if firstWord != "protected": self.__error( - docstringContext.start() + lineNumber, 0, "D232", "protected" + docstringContext.start() + lineNumber, 0, "D-232", "protected" ) else: if firstWord != "public": self.__error( - docstringContext.start() + lineNumber, 0, "D232", "public" + docstringContext.start() + lineNumber, 0, "D-232", "public" ) def __checkEricDocumentationSequence( @@ -1642,7 +1642,7 @@ and lineno > 0 and lines[lineno - 1].strip() == "" ): - self.__error(docstringContext.start() + lineno, 0, "D271", docToken) + self.__error(docstringContext.start() + lineno, 0, "D-271", docToken) # check the correct sequence of @param/@return/@yield and their accompanying # type tag @@ -1655,15 +1655,15 @@ if docToken in ("@param", "@keyparam") and docToken2 != "@type": self.__error( - docstringContext.start() + lineno, 0, "D270", docToken, "@type" + docstringContext.start() + lineno, 0, "D-270", docToken, "@type" ) elif docToken == "@return" and docToken2 != "@rtype": self.__error( - docstringContext.start() + lineno, 0, "D270", docToken, "@rtype" + docstringContext.start() + lineno, 0, "D-270", docToken, "@rtype" ) elif docToken == "@yield" and docToken2 != "@ytype": self.__error( - docstringContext.start() + lineno, 0, "D270", docToken, "@ytype" + docstringContext.start() + lineno, 0, "D-270", docToken, "@ytype" ) def __checkEricDocumentationDeprecatedTags( @@ -1699,7 +1699,7 @@ self.__error( docstringContext.start() + lineno, 0, - "D272", + "D-272", tag, deprecationsList[tag], ) @@ -1735,4 +1735,4 @@ tag = strippedLine.split(None, 1)[0] currentIndentation = len(line) - len(strippedLine) if currentIndentation != indentationLength: - self.__error(docstringContext.start() + lineno, 0, "D273", tag) + self.__error(docstringContext.start() + lineno, 0, "D-273", tag)
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -12,200 +12,200 @@ from PyQt6.QtCore import QCoreApplication _docStyleMessages = { - "D101": QCoreApplication.translate( + "D-101": QCoreApplication.translate( "DocStyleChecker", "module is missing a docstring" ), - "D102": QCoreApplication.translate( + "D-102": QCoreApplication.translate( "DocStyleChecker", "public function/method is missing a docstring" ), - "D103": QCoreApplication.translate( + "D-103": QCoreApplication.translate( "DocStyleChecker", "private function/method may be missing a docstring" ), - "D104": QCoreApplication.translate( + "D-104": QCoreApplication.translate( "DocStyleChecker", "public class is missing a docstring" ), - "D105": QCoreApplication.translate( + "D-105": QCoreApplication.translate( "DocStyleChecker", "private class may be missing a docstring" ), - "D111": QCoreApplication.translate( + "D-111": QCoreApplication.translate( "DocStyleChecker", 'docstring not surrounded by """' ), - "D112": QCoreApplication.translate( + "D-112": QCoreApplication.translate( "DocStyleChecker", 'docstring containing \\ not surrounded by r"""' ), - "D121": QCoreApplication.translate( + "D-121": QCoreApplication.translate( "DocStyleChecker", "one-liner docstring on multiple lines" ), - "D122": QCoreApplication.translate( + "D-122": QCoreApplication.translate( "DocStyleChecker", "docstring has wrong indentation" ), - "D130": QCoreApplication.translate( + "D-130": QCoreApplication.translate( "DocStyleChecker", "docstring does not contain a summary" ), - "D131": QCoreApplication.translate( + "D-131": QCoreApplication.translate( "DocStyleChecker", "docstring summary does not end with a period" ), - "D132": QCoreApplication.translate( + "D-132": QCoreApplication.translate( "DocStyleChecker", "docstring summary is not in imperative mood (Does instead of Do)", ), - "D133": QCoreApplication.translate( + "D-133": QCoreApplication.translate( "DocStyleChecker", "docstring summary looks like a function's/method's signature", ), - "D134": QCoreApplication.translate( + "D-134": QCoreApplication.translate( "DocStyleChecker", "docstring does not mention the return value type" ), - "D141": QCoreApplication.translate( + "D-141": QCoreApplication.translate( "DocStyleChecker", "function/method docstring is separated by a blank line" ), - "D142": QCoreApplication.translate( + "D-142": QCoreApplication.translate( "DocStyleChecker", "class docstring is not preceded by a blank line" ), - "D143": QCoreApplication.translate( + "D-143": QCoreApplication.translate( "DocStyleChecker", "class docstring is not followed by a blank line" ), - "D144": QCoreApplication.translate( + "D-144": QCoreApplication.translate( "DocStyleChecker", "docstring summary is not followed by a blank line" ), - "D145": QCoreApplication.translate( + "D-145": QCoreApplication.translate( "DocStyleChecker", "last paragraph of docstring is not followed by a blank line" ), - "D201": QCoreApplication.translate( + "D-201": QCoreApplication.translate( "DocStyleChecker", "module docstring is still a default string" ), - "D202.1": QCoreApplication.translate( + "D-202.1": QCoreApplication.translate( "DocStyleChecker", "function docstring is still a default string" ), - "D202.2": QCoreApplication.translate( + "D-202.2": QCoreApplication.translate( "DocStyleChecker", "function docstring still contains some placeholders" ), - "D203": QCoreApplication.translate( + "D-203": QCoreApplication.translate( "DocStyleChecker", "private function/method is missing a docstring" ), - "D205": QCoreApplication.translate( + "D-205": QCoreApplication.translate( "DocStyleChecker", "private class is missing a docstring" ), - "D206": QCoreApplication.translate( + "D-206": QCoreApplication.translate( "DocStyleChecker", "class docstring is still a default string" ), - "D221": QCoreApplication.translate( + "D-221": QCoreApplication.translate( "DocStyleChecker", "leading quotes of docstring not on separate line" ), - "D222": QCoreApplication.translate( + "D-222": QCoreApplication.translate( "DocStyleChecker", "trailing quotes of docstring not on separate line" ), - "D231": QCoreApplication.translate( + "D-231": QCoreApplication.translate( "DocStyleChecker", "docstring summary does not end with a period" ), - "D232": QCoreApplication.translate( + "D-232": QCoreApplication.translate( "DocStyleChecker", "docstring summary does not start with '{0}'" ), - "D234r": QCoreApplication.translate( + "D-234r": QCoreApplication.translate( "DocStyleChecker", "docstring does not contain a @return line but function/method" " returns something", ), - "D235r": QCoreApplication.translate( + "D-235r": QCoreApplication.translate( "DocStyleChecker", "docstring contains a @return line but function/method doesn't" " return anything", ), - "D234y": QCoreApplication.translate( + "D-234y": QCoreApplication.translate( "DocStyleChecker", "docstring does not contain a @yield line but function/method" " yields something", ), - "D235y": QCoreApplication.translate( + "D-235y": QCoreApplication.translate( "DocStyleChecker", "docstring contains a @yield line but function/method doesn't" " yield anything", ), - "D236": QCoreApplication.translate( + "D-236": QCoreApplication.translate( "DocStyleChecker", "docstring does not contain enough @param/@keyparam lines" ), - "D237": QCoreApplication.translate( + "D-237": QCoreApplication.translate( "DocStyleChecker", "docstring contains too many @param/@keyparam lines" ), - "D238": QCoreApplication.translate( + "D-238": QCoreApplication.translate( "DocStyleChecker", "keyword only arguments must be documented with @keyparam lines", ), - "D239": QCoreApplication.translate( + "D-239": QCoreApplication.translate( "DocStyleChecker", "order of @param/@keyparam lines does" " not match the function/method signature", ), - "D242": QCoreApplication.translate( + "D-242": QCoreApplication.translate( "DocStyleChecker", "class docstring is preceded by a blank line" ), - "D243": QCoreApplication.translate( + "D-243": QCoreApplication.translate( "DocStyleChecker", "class docstring is followed by a blank line" ), - "D244": QCoreApplication.translate( + "D-244": QCoreApplication.translate( "DocStyleChecker", "function/method docstring is preceded by a blank line" ), - "D245": QCoreApplication.translate( + "D-245": QCoreApplication.translate( "DocStyleChecker", "function/method docstring is followed by a blank line" ), - "D246": QCoreApplication.translate( + "D-246": QCoreApplication.translate( "DocStyleChecker", "docstring summary is not followed by a blank line" ), - "D247": QCoreApplication.translate( + "D-247": QCoreApplication.translate( "DocStyleChecker", "last paragraph of docstring is followed by a blank line" ), - "D250": QCoreApplication.translate( + "D-250": QCoreApplication.translate( "DocStyleChecker", "docstring does not contain a @exception line but function/method" " raises an exception", ), - "D251": QCoreApplication.translate( + "D-251": QCoreApplication.translate( "DocStyleChecker", "docstring contains a @exception line but function/method doesn't" " raise an exception", ), - "D252": QCoreApplication.translate( + "D-252": QCoreApplication.translate( "DocStyleChecker", "raised exception '{0}' is not documented in docstring" ), - "D253": QCoreApplication.translate( + "D-253": QCoreApplication.translate( "DocStyleChecker", "documented exception '{0}' is not raised" ), - "D260": QCoreApplication.translate( + "D-260": QCoreApplication.translate( "DocStyleChecker", "docstring does not contain a @signal line but class defines signals", ), - "D261": QCoreApplication.translate( + "D-261": QCoreApplication.translate( "DocStyleChecker", "docstring contains a @signal line but class doesn't define signals", ), - "D262": QCoreApplication.translate( + "D-262": QCoreApplication.translate( "DocStyleChecker", "defined signal '{0}' is not documented in docstring" ), - "D263": QCoreApplication.translate( + "D-263": QCoreApplication.translate( "DocStyleChecker", "documented signal '{0}' is not defined" ), - "D270": QCoreApplication.translate( + "D-270": QCoreApplication.translate( "DocStyleChecker", "'{0}' line should be followed by an '{1}' line" ), - "D271": QCoreApplication.translate( + "D-271": QCoreApplication.translate( "DocStyleChecker", "'{0}' line should not be preceded by an empty line" ), - "D272": QCoreApplication.translate( + "D-272": QCoreApplication.translate( "DocStyleChecker", "don't use '{0}' but '{1}' instead" ), - "D273": QCoreApplication.translate( + "D-273": QCoreApplication.translate( "DocStyleChecker", "'{0}' line has wrong indentation" ), } _docStyleMessagesSampleArgs = { - "D232": ["public"], - "D252": ["RuntimeError"], - "D253": ["RuntimeError"], - "D262": ["buttonClicked"], - "D263": ["buttonClicked"], - "D270": ["@param", "@type"], - "D271": ["@type"], - "D272": ["@ptype", "@type"], - "D273": ["@type"], + "D-232": ["public"], + "D-252": ["RuntimeError"], + "D-253": ["RuntimeError"], + "D-262": ["buttonClicked"], + "D-263": ["buttonClicked"], + "D-270": ["@param", "@type"], + "D-271": ["@type"], + "D-272": ["@ptype", "@type"], + "D-273": ["@type"], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/ImportsChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/ImportsChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -19,14 +19,14 @@ Codes = [ ## Local imports - "I101", - "I102", - "I103", + "I-101", + "I-102", + "I-103", ## Various other import related - "I901", - "I902", - "I903", - "I904", + "I-901", + "I-902", + "I-903", + "I-904", ] def __init__(self, source, filename, tree, select, ignore, expected, repeat, args): @@ -66,8 +66,8 @@ self.errors = [] checkersWithCodes = [ - (self.__checkLocalImports, ("I101", "I102", "I103")), - (self.__tidyImports, ("I901", "I902", "I903", "I904")), + (self.__checkLocalImports, ("I-101", "I-102", "I-103")), + (self.__tidyImports, ("I-901", "I-902", "I-903", "I-904")), ] self.__checkers = [] @@ -197,13 +197,13 @@ self.__bannedStructuredPatterns.sort(key=lambda x: len(x[0]), reverse=True) ruleMethods = [] - if not self.__ignoreCode("I901"): + if not self.__ignoreCode("I-901"): ruleMethods.append(self.__checkUnnecessaryAlias) - if not self.__ignoreCode("I902") and bool(self.__bannedModules): + if not self.__ignoreCode("I-902") and bool(self.__bannedModules): ruleMethods.append(self.__checkBannedImport) if ( - not self.__ignoreCode("I903") and self.__banRelativeImports == "parents" - ) or (not self.__ignoreCode("I904") and self.__banRelativeImports == "true"): + not self.__ignoreCode("I-903") and self.__banRelativeImports == "parents" + ) or (not self.__ignoreCode("I-904") and self.__banRelativeImports == "true"): ruleMethods.append(self.__checkBannedRelativeImports) for node in ast.walk(self.__tree): @@ -251,14 +251,14 @@ else: rewritten = f"import {importedName}" - self.__error(node.lineno - 1, node.col_offset, "I901", rewritten) + self.__error(node.lineno - 1, node.col_offset, "I-901", rewritten) elif isinstance(node, ast.ImportFrom): for alias in node.names: if alias.name == alias.asname: rewritten = f"from {node.module} import {alias.name}" - self.__error(node.lineno - 1, node.col_offset, "I901", rewritten) + self.__error(node.lineno - 1, node.col_offset, "I-901", rewritten) def __isModuleBanned(self, moduleName): """ @@ -326,7 +326,7 @@ continue else: warned.add(moduleName) - self.__error(node.lineno - 1, node.col_offset, "I902", moduleName) + self.__error(node.lineno - 1, node.col_offset, "I-902", moduleName) def __checkBannedRelativeImports(self, node): """ @@ -341,10 +341,10 @@ elif self.__banRelativeImports == "parents": minNodeLevel = 1 - msgCode = "I903" + msgCode = "I-903" else: minNodeLevel = 0 - msgCode = "I904" + msgCode = "I-904" if isinstance(node, ast.ImportFrom) and node.level > minNodeLevel: self.__error(node.lineno - 1, node.col_offset, msgCode)
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/LocalImportVisitor.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/LocalImportVisitor.py Mon Feb 24 15:11:18 2025 +0100 @@ -118,7 +118,7 @@ ) or isinstance(previous, (ast.Import, ast.ImportFrom, ast.arguments)) if not isinstance(parent, ast.FunctionDef) or not isAllowedPrevious: - self.violations.append((node, "I101")) + self.violations.append((node, "I-101")) self.generic_visit(node) @@ -146,6 +146,6 @@ return if module.split(".")[0] not in SysUtilities.getStandardModules(): - self.violations.append((node, "I102")) + self.violations.append((node, "I-102")) else: - self.violations.append((node, "I103")) + self.violations.append((node, "I-103"))
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -11,28 +11,28 @@ from PyQt6.QtCore import QCoreApplication _importsMessages = { - "I101": QCoreApplication.translate( + "I-101": QCoreApplication.translate( "ImportsChecker", "local import must be at the beginning of the method body" ), - "I102": QCoreApplication.translate( + "I-102": QCoreApplication.translate( "ImportsChecker", "packages from external modules should not be imported locally", ), - "I103": QCoreApplication.translate( + "I-103": QCoreApplication.translate( "ImportsChecker", "packages from standard modules should not be imported locally", ), - "I901": QCoreApplication.translate( + "I-901": QCoreApplication.translate( "ImportsChecker", "unnecessary import alias - rewrite as '{0}'" ), - "I902": QCoreApplication.translate("ImportsChecker", "banned import '{0}' used"), - "I903": QCoreApplication.translate( + "I-902": QCoreApplication.translate("ImportsChecker", "banned import '{0}' used"), + "I-903": QCoreApplication.translate( "ImportsChecker", "relative imports from parent modules are banned" ), - "I904": QCoreApplication.translate("ImportsChecker", "relative imports are banned"), + "I-904": QCoreApplication.translate("ImportsChecker", "relative imports are banned"), } _importsMessagesSampleArgs = { - "I901": ["from foo import bar"], - "I902": ["foo"], + "I-901": ["from foo import bar"], + "I-902": ["foo"], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/LoggingChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/LoggingChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -17,21 +17,21 @@ Codes = [ ## Logging - "L101", - "L102", - "L103", - "L104", - "L105", - "L106", - "L107", - "L108", - "L109", - "L110", - "L111", - "L112", - "L113", - "L114", - "L115", + "L-101", + "L-102", + "L-103", + "L-104", + "L-105", + "L-106", + "L-107", + "L-108", + "L-109", + "L-110", + "L-111", + "L-112", + "L-113", + "L-114", + "L-115", ] def __init__(self, source, filename, tree, select, ignore, expected, repeat, args): @@ -74,21 +74,21 @@ ( self.__checkLogging, ( - "L101", - "L102", - "L103", - "L104", - "L105", - "L106", - "L107", - "L108", - "L109", - "L110", - "L111", - "L112", - "L113", - "L114", - "L115", + "L-101", + "L-102", + "L-103", + "L-104", + "L-105", + "L-106", + "L-107", + "L-108", + "L-109", + "L-110", + "L-111", + "L-112", + "L-113", + "L-114", + "L-115", ), ), ]
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/LoggingVisitor.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/LoggingVisitor.py Mon Feb 24 15:11:18 2025 +0100 @@ -179,7 +179,7 @@ else: lineno = node.lineno colOffset = node.col_offset - self.__error(lineno - 1, colOffset, "L109") + self.__error(lineno - 1, colOffset, "L-109") if not alias.asname: self.__fromImports[alias.name] = node.module @@ -198,7 +198,7 @@ and node.value.id == self.__loggingName and node.attr == "WARN" ): - self.__error(node.lineno - 1, node.col_offset, "L109") + self.__error(node.lineno - 1, node.col_offset, "L-109") self.generic_visit(node) @@ -223,7 +223,7 @@ and self.__fromImports.get("Logger") == "logging" ) ) and not self.__atModuleLevel(): - self.__error(node.lineno - 1, node.col_offset, "L101") + self.__error(node.lineno - 1, node.col_offset, "L-101") if ( isinstance(node.func, ast.Attribute) @@ -236,7 +236,7 @@ and node.func.id in _LoggerMethods and self.__fromImports.get(node.func.id) == "logging" ): - self.__error(node.lineno - 1, node.col_offset, "L115") + self.__error(node.lineno - 1, node.col_offset, "L-115") if ( self.__loggingName @@ -263,7 +263,7 @@ and isinstance(node.args[0], ast.Name) and node.args[0].id in self.GetLoggerNames ): - self.__error(node.args[0].lineno - 1, node.args[0].col_offset, "L102") + self.__error(node.args[0].lineno - 1, node.args[0].col_offset, "L-102") if ( isinstance(node.func, ast.Attribute) @@ -277,7 +277,7 @@ # L108 if node.func.attr == "warn": - self.__error(node.lineno - 1, node.col_offset, "L108") + self.__error(node.lineno - 1, node.col_offset, "L-108") # L103 extraKeys = [] @@ -302,13 +302,13 @@ for key, keyNode in extraKeys: if key in _LogrecordAttributes: self.__error( - keyNode.lineno - 1, keyNode.col_offset, "L103", repr(key) + keyNode.lineno - 1, keyNode.col_offset, "L-103", repr(key) ) if node.func.attr == "exception": # L104 if not excHandler: - self.__error(node.lineno - 1, node.col_offset, "L104") + self.__error(node.lineno - 1, node.col_offset, "L-104") if any((excInfo := kw).arg == "exc_info" for kw in node.keywords): # L106 @@ -319,14 +319,14 @@ and isinstance(excInfo.value, ast.Name) and excInfo.value.id == excHandler.name ): - self.__error(excInfo.lineno - 1, excInfo.col_offset, "L106") + self.__error(excInfo.lineno - 1, excInfo.col_offset, "L-106") # L107 elif ( isinstance(excInfo.value, ast.Constant) and not excInfo.value.value ): - self.__error(excInfo.lineno - 1, excInfo.col_offset, "L107") + self.__error(excInfo.lineno - 1, excInfo.col_offset, "L-107") # L105 elif node.func.attr == "error" and excHandler is not None: @@ -343,7 +343,7 @@ rewritable = True if rewritable: - self.__error(node.lineno - 1, node.col_offset, "L105") + self.__error(node.lineno - 1, node.col_offset, "L-105") # L114 elif ( @@ -352,7 +352,7 @@ and isinstance(excInfo.value, ast.Constant) and excInfo.value.value ): - self.__error(excInfo.lineno - 1, excInfo.col_offset, "L114") + self.__error(excInfo.lineno - 1, excInfo.col_offset, "L-114") # L110 if ( @@ -362,7 +362,7 @@ and excHandler is not None and node.args[0].id == excHandler.name ): - self.__error(node.args[0].lineno - 1, node.args[0].col_offset, "L110") + self.__error(node.args[0].lineno - 1, node.args[0].col_offset, "L-110") msgArgKwarg = False if node.func.attr == "log" and len(node.args) >= 2: @@ -378,7 +378,7 @@ # L111 if isinstance(msgArg, ast.JoinedStr): - self.__error(msgArg.lineno - 1, msgArg.col_offset, "L111a") + self.__error(msgArg.lineno - 1, msgArg.col_offset, "L-111a") elif ( isinstance(msgArg, ast.Call) and isinstance(msgArg.func, ast.Attribute) @@ -386,16 +386,16 @@ and isinstance(msgArg.func.value.value, str) and msgArg.func.attr == "format" ): - self.__error(msgArg.lineno - 1, msgArg.col_offset, "L111b") + self.__error(msgArg.lineno - 1, msgArg.col_offset, "L-111b") elif ( isinstance(msgArg, ast.BinOp) and isinstance(msgArg.op, ast.Mod) and isinstance(msgArg.left, ast.Constant) and isinstance(msgArg.left.value, str) ): - self.__error(msgArg.lineno - 1, msgArg.col_offset, "L111c") + self.__error(msgArg.lineno - 1, msgArg.col_offset, "L-111c") elif isinstance(msgArg, ast.BinOp) and self.__isAddChainWithNonStr(msgArg): - self.__error(msgArg.lineno - 1, msgArg.col_offset, "L111d") + self.__error(msgArg.lineno - 1, msgArg.col_offset, "L-111d") # L112 if ( @@ -444,7 +444,7 @@ self.__error( msgArg.lineno - 1, msgArg.col_offset, - "L113a", # missing keys + "L-113a", # missing keys ", ".join([repr(k) for k in missing]), ) @@ -452,7 +452,7 @@ self.__error( msgArg.lineno - 1, msgArg.col_offset, - "L113b", # unreferenced keys + "L-113b", # unreferenced keys ", ".join([repr(k) for k in missing]), ) @@ -470,7 +470,7 @@ self.__error( msgArg.lineno - 1, msgArg.col_offset, - "L112", + "L-112", modposCount, "'%'", # noqa: M601 argCount,
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -13,79 +13,79 @@ _loggingMessages = { ## Logging - "L101": QCoreApplication.translate( + "L-101": QCoreApplication.translate( "LoggingChecker", "use logging.getLogger() to instantiate loggers", ), - "L102": QCoreApplication.translate( + "L-102": QCoreApplication.translate( "LoggingChecker", "use '__name__' with getLogger()", ), - "L103": QCoreApplication.translate( + "L-103": QCoreApplication.translate( "LoggingChecker", "extra key {0} clashes with LogRecord attribute", ), - "L104": QCoreApplication.translate( + "L-104": QCoreApplication.translate( "LoggingChecker", "avoid exception() outside of exception handlers", ), - "L105": QCoreApplication.translate( + "L-105": QCoreApplication.translate( "LoggingChecker", ".exception(...) should be used instead of .error(..., exc_info=True)", ), - "L106": QCoreApplication.translate( + "L-106": QCoreApplication.translate( "LoggingChecker", "redundant exc_info argument for exception() should be removed", ), - "L107": QCoreApplication.translate( + "L-107": QCoreApplication.translate( "LoggingChecker", "use error() instead of exception() with exc_info=False", ), - "L108": QCoreApplication.translate( + "L-108": QCoreApplication.translate( "LoggingChecker", "warn() is deprecated, use warning() instead", ), - "L109": QCoreApplication.translate( + "L-109": QCoreApplication.translate( "LoggingChecker", "WARN is undocumented, use WARNING instead", ), - "L110": QCoreApplication.translate( + "L-110": QCoreApplication.translate( "LoggingChecker", "exception() does not take an exception", ), - "L111a": QCoreApplication.translate( + "L-111a": QCoreApplication.translate( "LoggingChecker", "avoid pre-formatting log messages using f-string", ), - "L111b": QCoreApplication.translate( + "L-111b": QCoreApplication.translate( "LoggingChecker", "avoid pre-formatting log messages using string.format()", ), - "L111c": QCoreApplication.translate( + "L-111c": QCoreApplication.translate( "LoggingChecker", "avoid pre-formatting log messages using '%'", # noqa: M601 ), - "L111d": QCoreApplication.translate( + "L-111d": QCoreApplication.translate( "LoggingChecker", "avoid pre-formatting log messages using '+'", ), - "L112": QCoreApplication.translate( + "L-112": QCoreApplication.translate( "LoggingChecker", "formatting error: {0} {1} placeholder(s) but {2} argument(s)", ), - "L113a": QCoreApplication.translate( + "L-113a": QCoreApplication.translate( "LoggingChecker", "formatting error: missing key(s): {0}", ), - "L113b": QCoreApplication.translate( + "L-113b": QCoreApplication.translate( "LoggingChecker", "formatting error: unreferenced key(s): {0}", ), - "L114": QCoreApplication.translate( + "L-114": QCoreApplication.translate( "LoggingChecker", "avoid exc_info=True outside of exception handlers", ), - "L115": QCoreApplication.translate( + "L-115": QCoreApplication.translate( "LoggingChecker", "avoid logging calls on the root logger", ), @@ -93,8 +93,8 @@ _loggingMessagesSampleArgs = { ## Logging - "L103": ["'pathname'"], - "L112": [3, "'%'", 2], # noqa: M601 - "L113a": ["'foo', 'bar'"], - "L113b": ["'foo', 'bar'"], + "L-103": ["'pathname'"], + "L-112": [3, "'%'", 2], # noqa: M601 + "L-113a": ["'foo', 'bar'"], + "L-113b": ["'foo', 'bar'"], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -95,161 +95,161 @@ Codes = [ ## Coding line - "M101", - "M102", + "M-101", + "M-102", ## Copyright - "M111", - "M112", + "M-111", + "M-112", ## Shadowed Builtins - "M131", - "M132", + "M-131", + "M-132", ## Comprehensions - "M180", - "M181", - "M182", - "M183", - "M184", - "M185", - "M186", - "M188", - "M189", - "M189a", - "M189b", - "M190", - "M190a", - "M190b", - "M191", - "M193", - "M193a", - "M193b", - "M193c", - "M194", - "M195", - "M196", - "M197", - "M198", - "M199", - "M200", + "M-180", + "M-181", + "M-182", + "M-183", + "M-184", + "M-185", + "M-186", + "M-188", + "M-189", + "M-189a", + "M-189b", + "M-190", + "M-190a", + "M-190b", + "M-191", + "M-193", + "M-193a", + "M-193b", + "M-193c", + "M-194", + "M-195", + "M-196", + "M-197", + "M-198", + "M-199", + "M-200", ## Dictionaries with sorted keys - "M251", + "M-251", ## Property - "M260", - "M261", - "M262", - "M263", - "M264", - "M265", - "M266", - "M267", + "M-260", + "M-261", + "M-262", + "M-263", + "M-264", + "M-265", + "M-266", + "M-267", ## Naive datetime usage - "M301", - "M302", - "M303", - "M304", - "M305", - "M306", - "M307", - "M308", - "M311", - "M312", - "M313", - "M314", - "M315", - "M321", + "M-301", + "M-302", + "M-303", + "M-304", + "M-305", + "M-306", + "M-307", + "M-308", + "M-311", + "M-312", + "M-313", + "M-314", + "M-315", + "M-321", ## sys.version and sys.version_info usage - "M401", - "M402", - "M403", - "M411", - "M412", - "M413", - "M414", - "M421", - "M422", - "M423", + "M-401", + "M-402", + "M-403", + "M-411", + "M-412", + "M-413", + "M-414", + "M-421", + "M-422", + "M-423", ## Bugbear - "M501", - "M502", - "M503", - "M504", - "M505", - "M506", - "M507", - "M508", - "M509", - "M510", - "M511", - "M512", - "M513", - "M514", - "M515", - "M516", - "M517", - "M518", - "M519", - "M520", - "M521", - "M522", - "M523", - "M524", - "M525", - "M526", - "M527", - "M528", - "M529", - "M530", - "M531", - "M532", - "M533", - "M534", - "M535", - "M536", - "M537", - "M539", - "M540", - "M541", + "M-501", + "M-502", + "M-503", + "M-504", + "M-505", + "M-506", + "M-507", + "M-508", + "M-509", + "M-510", + "M-511", + "M-512", + "M-513", + "M-514", + "M-515", + "M-516", + "M-517", + "M-518", + "M-519", + "M-520", + "M-521", + "M-522", + "M-523", + "M-524", + "M-525", + "M-526", + "M-527", + "M-528", + "M-529", + "M-530", + "M-531", + "M-532", + "M-533", + "M-534", + "M-535", + "M-536", + "M-537", + "M-539", + "M-540", + "M-541", ## Bugbear, opininonated - "M569", + "M-569", ## Bugbear++ - "M581", - "M582", + "M-581", + "M-582", ## Format Strings - "M601", - "M611", - "M612", - "M613", - "M621", - "M622", - "M623", - "M624", - "M625", - "M631", - "M632", + "M-601", + "M-611", + "M-612", + "M-613", + "M-621", + "M-622", + "M-623", + "M-624", + "M-625", + "M-631", + "M-632", ## Future statements - "M701", - "M702", + "M-701", + "M-702", ## Gettext - "M711", + "M-711", ## print() statements - "M801", + "M-801", ## one element tuple - "M811", + "M-811", ## return statements - "M831", - "M832", - "M833", - "M834", + "M-831", + "M-832", + "M-833", + "M-834", ## line continuation - "M841", + "M-841", ## implicitly concatenated strings - "M851", - "M852", - "M853", + "M-851", + "M-852", + "M-853", ## commented code - "M891", + "M-891", ## structural pattern matching - "M901", - "M902", + "M-901", + "M-902", ] Formatter = Formatter() @@ -309,153 +309,153 @@ self.errors = [] checkersWithCodes = [ - (self.__checkCoding, ("M101", "M102")), - (self.__checkCopyright, ("M111", "M112")), - (self.__checkBuiltins, ("M131", "M132")), + (self.__checkCoding, ("M-101", "M-102")), + (self.__checkCopyright, ("M-111", "M-112")), + (self.__checkBuiltins, ("M-131", "M-132")), ( self.__checkComprehensions, ( - "M180", - "M181", - "M182", - "M183", - "M184", - "M185", - "M186", - "M188", - "M189", - "M189a", - "M189b", - "M190", - "M190a", - "M190b", - "M191", - "M193", - "M193a", - "M193b", - "M193c", - "M194", - "M195", - "M196", - "M197", - "M198", - "M199", - "M200", + "M-180", + "M-181", + "M-182", + "M-183", + "M-184", + "M-185", + "M-186", + "M-188", + "M-189", + "M-189a", + "M-189b", + "M-190", + "M-190a", + "M-190b", + "M-191", + "M-193", + "M-193a", + "M-193b", + "M-193c", + "M-194", + "M-195", + "M-196", + "M-197", + "M-198", + "M-199", + "M-200", ), ), - (self.__checkDictWithSortedKeys, ("M251",)), + (self.__checkDictWithSortedKeys, ("M-251",)), ( self.__checkProperties, - ("M260", "M261", "M262", "M263", "M264", "M265", "M266", "M267"), + ("M-260", "M-261", "M-262", "M-263", "M-264", "M-265", "M-266", "M-267"), ), ( self.__checkDateTime, ( - "M301", - "M302", - "M303", - "M304", - "M305", - "M306", - "M307", - "M308", - "M311", - "M312", - "M313", - "M314", - "M315", - "M321", + "M-301", + "M-302", + "M-303", + "M-304", + "M-305", + "M-306", + "M-307", + "M-308", + "M-311", + "M-312", + "M-313", + "M-314", + "M-315", + "M-321", ), ), ( self.__checkSysVersion, ( - "M401", - "M402", - "M403", - "M411", - "M412", - "M413", - "M414", - "M421", - "M422", - "M423", + "M-401", + "M-402", + "M-403", + "M-411", + "M-412", + "M-413", + "M-414", + "M-421", + "M-422", + "M-423", ), ), ( self.__checkBugBear, ( - "M501", - "M502", - "M503", - "M504", - "M505", - "M506", - "M507", - "M508", - "M509", - "M510", - "M511", - "M512", - "M513", - "M514", - "M515", - "M516", - "M517", - "M518", - "M519", - "M520", - "M521", - "M522", - "M523", - "M524", - "M525", - "M526", - "M527", - "M528", - "M529", - "M530", - "M531", - "M532", - "M533", - "M534", - "M535", - "M536", - "M537", - "M539", - "M540", - "M541", - "M569", - "M581", - "M582", + "M-501", + "M-502", + "M-503", + "M-504", + "M-505", + "M-506", + "M-507", + "M-508", + "M-509", + "M-510", + "M-511", + "M-512", + "M-513", + "M-514", + "M-515", + "M-516", + "M-517", + "M-518", + "M-519", + "M-520", + "M-521", + "M-522", + "M-523", + "M-524", + "M-525", + "M-526", + "M-527", + "M-528", + "M-529", + "M-530", + "M-531", + "M-532", + "M-533", + "M-534", + "M-535", + "M-536", + "M-537", + "M-539", + "M-540", + "M-541", + "M-569", + "M-581", + "M-582", ), ), - (self.__checkPep3101, ("M601",)), + (self.__checkPep3101, ("M-601",)), ( self.__checkFormatString, ( - "M611", - "M612", - "M613", - "M621", - "M622", - "M623", - "M624", - "M625", - "M631", - "M632", + "M-611", + "M-612", + "M-613", + "M-621", + "M-622", + "M-623", + "M-624", + "M-625", + "M-631", + "M-632", ), ), - (self.__checkFuture, ("M701", "M702")), - (self.__checkGettext, ("M711",)), - (self.__checkPrintStatements, ("M801",)), - (self.__checkTuple, ("M811",)), - (self.__checkReturn, ("M831", "M832", "M833", "M834")), - (self.__checkLineContinuation, ("M841",)), - (self.__checkImplicitStringConcat, ("M851", "M852")), - (self.__checkExplicitStringConcat, ("M853",)), - (self.__checkCommentedCode, ("M891",)), - (self.__checkDefaultMatchCase, ("M901", "M902")), + (self.__checkFuture, ("M-701", "M-702")), + (self.__checkGettext, ("M-711",)), + (self.__checkPrintStatements, ("M-801",)), + (self.__checkTuple, ("M-811",)), + (self.__checkReturn, ("M-831", "M-832", "M-833", "M-834")), + (self.__checkLineContinuation, ("M-841",)), + (self.__checkImplicitStringConcat, ("M-851", "M-852")), + (self.__checkExplicitStringConcat, ("M-853",)), + (self.__checkCommentedCode, ("M-891",)), + (self.__checkDefaultMatchCase, ("M-901", "M-902")), ] # the eradicate whitelist @@ -573,9 +573,9 @@ lineno, coding = self.__getCoding() if coding: if coding.lower() not in encodings: - self.__error(lineno, 0, "M102", coding) + self.__error(lineno, 0, "M-102", coding) else: - self.__error(0, 0, "M101") + self.__error(0, 0, "M-101") def __checkCopyright(self): """ @@ -603,7 +603,7 @@ copyrightRe = re.compile(copyrightRegexStr.format(author=r".*"), re.IGNORECASE) if not copyrightRe.search(topOfSource): - self.__error(0, 0, "M111") + self.__error(0, 0, "M-111") return if copyrightAuthor: @@ -611,7 +611,7 @@ copyrightRegexStr.format(author=copyrightAuthor), re.IGNORECASE ) if not copyrightAuthorRe.search(topOfSource): - self.__error(0, 0, "M112") + self.__error(0, 0, "M-112") def __checkCommentedCode(self): """ @@ -629,7 +629,7 @@ for markedLine in self.__eradicator.commented_out_code_line_numbers( source, aggressive=aggressive ): - self.__error(markedLine - 1, 0, "M891") + self.__error(markedLine - 1, 0, "M-891") def __checkLineContinuation(self): """ @@ -652,7 +652,7 @@ if strippedLine.endswith("\\") and not strippedLine.startswith( ("assert", "with") ): - self.__error(lineIndex, len(line), "M841") + self.__error(lineIndex, len(line), "M-841") def __checkPrintStatements(self): """ @@ -662,7 +662,7 @@ if ( isinstance(node, ast.Call) and getattr(node.func, "id", None) == "print" ) or (hasattr(ast, "Print") and isinstance(node, ast.Print)): - self.__error(node.lineno - 1, node.col_offset, "M801") + self.__error(node.lineno - 1, node.col_offset, "M-801") def __checkTuple(self): """ @@ -670,7 +670,7 @@ """ for node in ast.walk(self.__tree): if isinstance(node, ast.Tuple) and len(node.elts) == 1: - self.__error(node.lineno - 1, node.col_offset, "M811") + self.__error(node.lineno - 1, node.col_offset, "M-811") def __checkFuture(self): """ @@ -708,13 +708,13 @@ self.__error( node.lineno - 1, node.col_offset, - "M701", + "M-701", ", ".join(expectedImports), ", ".join(imports), ) else: self.__error( - node.lineno - 1, node.col_offset, "M702", ", ".join(expectedImports) + node.lineno - 1, node.col_offset, "M-702", ", ".join(expectedImports) ) def __checkPep3101(self): @@ -738,7 +738,7 @@ c = line[pos] if c in "diouxXeEfFgGcrs": formatter += c - self.__error(lineno, formatPos, "M601", formatter) + self.__error(lineno, formatPos, "M-601", formatter) def __checkFormatString(self): """ @@ -761,12 +761,12 @@ fields, implicit, explicit = self.__getFields(text) if implicit: if node in visitor.calls: - self.__error(node.lineno - 1, node.col_offset, "M611") + self.__error(node.lineno - 1, node.col_offset, "M-611") else: if node.is_docstring: - self.__error(node.lineno - 1, node.col_offset, "M612") + self.__error(node.lineno - 1, node.col_offset, "M-612") else: - self.__error(node.lineno - 1, node.col_offset, "M613") + self.__error(node.lineno - 1, node.col_offset, "M-613") if node in visitor.calls: call, strArgs = visitor.calls[node] @@ -804,33 +804,33 @@ # parameters but at least check if the args are used if hasKwArgs and not names: # No names but kwargs - self.__error(call.lineno - 1, call.col_offset, "M623") + self.__error(call.lineno - 1, call.col_offset, "M-623") if hasStarArgs and not numbers: # No numbers but args - self.__error(call.lineno - 1, call.col_offset, "M624") + self.__error(call.lineno - 1, call.col_offset, "M-624") if not hasKwArgs and not hasStarArgs: # can actually verify numbers and names for number in sorted(numbers): if number >= numArgs: self.__error( - call.lineno - 1, call.col_offset, "M621", number + call.lineno - 1, call.col_offset, "M-621", number ) for name in sorted(names): if name not in keywords: - self.__error(call.lineno - 1, call.col_offset, "M622", name) + self.__error(call.lineno - 1, call.col_offset, "M-622", name) for arg in range(numArgs): if arg not in numbers: - self.__error(call.lineno - 1, call.col_offset, "M631", arg) + self.__error(call.lineno - 1, call.col_offset, "M-631", arg) for keyword in keywords: if keyword not in names: - self.__error(call.lineno - 1, call.col_offset, "M632", keyword) + self.__error(call.lineno - 1, call.col_offset, "M-632", keyword) if implicit and explicit: - self.__error(call.lineno - 1, call.col_offset, "M625") + self.__error(call.lineno - 1, call.col_offset, "M-625") def __getFields(self, string): """ @@ -891,7 +891,7 @@ # ignore compatibility assignments continue self.__error( - element.lineno - 1, element.col_offset, "M131", element.id + element.lineno - 1, element.col_offset, "M-131", element.id ) elif isinstance(element, (ast.Tuple, ast.List)): for tupleElement in element.elts: @@ -902,7 +902,7 @@ self.__error( tupleElement.lineno - 1, tupleElement.col_offset, - "M131", + "M-131", tupleElement.id, ) elif isinstance(node, ast.For): @@ -910,7 +910,7 @@ target = node.target if isinstance(target, ast.Name) and target.id in self.__builtins: self.__error( - target.lineno - 1, target.col_offset, "M131", target.id + target.lineno - 1, target.col_offset, "M-131", target.id ) elif isinstance(target, (ast.Tuple, ast.List)): for element in target.elts: @@ -921,14 +921,14 @@ self.__error( element.lineno - 1, element.col_offset, - "M131", + "M-131", element.id, ) elif any(isinstance(node, functionDef) for functionDef in functionDefs): # (asynchronous) function definition for arg in node.args.args: if isinstance(arg, ast.arg) and arg.arg in self.__builtins: - self.__error(arg.lineno - 1, arg.col_offset, "M132", arg.arg) + self.__error(arg.lineno - 1, arg.col_offset, "M-132", arg.arg) def __checkComprehensions(self): """ @@ -956,8 +956,8 @@ and node.func.id in ("list", "set") ): errorCode = { - "list": "M180", - "set": "M181", + "list": "M-180", + "set": "M-181", }[node.func.id] self.__error(node.lineno - 1, node.col_offset, errorCode) @@ -970,9 +970,9 @@ and len(node.args[0].elt.elts) == 2 ): if isinstance(node.args[0], ast.GeneratorExp): - errorCode = "M182" + errorCode = "M-182" else: - errorCode = "M184" + errorCode = "M-184" self.__error(node.lineno - 1, node.col_offset, errorCode) elif ( @@ -981,10 +981,10 @@ and node.func.id in ("list", "set", "any", "all") ): errorCode = { - "list": "M191", - "set": "M183", - "any": "M199", - "all": "M199", + "list": "M-191", + "set": "M-183", + "any": "M-199", + "all": "M-199", }[node.func.id] self.__error( node.lineno - 1, node.col_offset, errorCode, node.func.id @@ -997,8 +997,8 @@ and node.func.id == "list" ): errorCode = { - "tuple": "M189a", - "list": "M190a", + "tuple": "M-189a", + "list": "M-190a", }[node.func.id] self.__error( node.lineno - 1, @@ -1021,7 +1021,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M198", + "M-198", type_, ) @@ -1040,10 +1040,10 @@ ) ): errorCode = { - "tuple": "M189b", - "list": "M190b", - "set": "M185", - "dict": "M186", + "tuple": "M-189b", + "list": "M-190b", + "set": "M-185", + "dict": "M-186", }[node.func.id] self.__error( node.lineno - 1, @@ -1063,7 +1063,7 @@ and numKeywordArgs == 0 and node.func.id in ("tuple", "list") ): - self.__error(node.lineno - 1, node.col_offset, "M188", node.func.id) + self.__error(node.lineno - 1, node.col_offset, "M-188", node.func.id) elif ( node.func.id in {"list", "reversed"} @@ -1087,7 +1087,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M193a", + "M-193a", node.func.id, node.args[0].func.id, ) @@ -1095,7 +1095,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M193b", + "M-193b", node.func.id, node.args[0].func.id, not reverseFlagValue, @@ -1105,7 +1105,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M193c", + "M-193c", node.func.id, node.args[0].func.id, ) @@ -1130,7 +1130,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M194", + "M-194", node.args[0].func.id, node.func.id, ) @@ -1147,7 +1147,7 @@ and isinstance(node.args[0].slice.step.operand, ast.Constant) and node.args[0].slice.step.operand.n == 1 ): - self.__error(node.lineno - 1, node.col_offset, "M195", node.func.id) + self.__error(node.lineno - 1, node.col_offset, "M-195", node.func.id) elif ( node.func.id == "map" @@ -1156,7 +1156,7 @@ and isinstance(node.args[0], ast.Lambda) ): self.__error( - node.lineno - 1, node.col_offset, "M197", "generator expression" + node.lineno - 1, node.col_offset, "M-197", "generator expression" ) elif ( @@ -1186,7 +1186,7 @@ if rewriteable: comprehensionType = f"{node.func.id} comprehension" self.__error( - node.lineno - 1, node.col_offset, "M197", comprehensionType + node.lineno - 1, node.col_offset, "M-197", comprehensionType ) elif isinstance(node, (ast.DictComp, ast.ListComp, ast.SetComp)) and ( @@ -1213,7 +1213,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M196", + "M-196", compType[node.__class__], ) @@ -1227,7 +1227,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M200", + "M-200", compType[node.__class__], ) @@ -1263,7 +1263,7 @@ self.__error( key2.lineno - 1, key2.col_offset, - "M251", + "M-251", key2.value, key1.value, ) @@ -1277,7 +1277,7 @@ name.asname == "_" for name in node.names ): self.__error( - node.lineno - 1, node.col_offset, "M711", node.names[0].name + node.lineno - 1, node.col_offset, "M-711", node.names[0].name ) def __checkBugBear(self): @@ -1353,7 +1353,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M260", + "M-260", len(node.args.args), ) @@ -1366,7 +1366,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M265", + "M-265", node.name, decorator.value.id, ) @@ -1374,7 +1374,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M263", + "M-263", decorator.value.id, node.name, ) @@ -1382,7 +1382,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M261", + "M-261", len(node.args.args), ) @@ -1394,7 +1394,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M266", + "M-266", node.name, decorator.value.id, ) @@ -1402,7 +1402,7 @@ self.__error( node.lineno - 1, node.col_offset, - "M264", + "M-264", decorator.value.id, node.name, ) @@ -1410,12 +1410,12 @@ self.__error( node.lineno - 1, node.col_offset, - "M262", + "M-262", len(node.args.args), ) if propertyCount > 1: - self.__error(node.lineno - 1, node.col_offset, "M267", node.name) + self.__error(node.lineno - 1, node.col_offset, "M-267", node.name) ####################################################################### ## The following methods check for implicitly concatenated strings. @@ -1489,7 +1489,7 @@ for a, b in pairwise(tokensWithoutWhitespace): if self.__isImplicitStringConcat(a, b): self.__error( - a.end[0] - 1, a.end[1], "M851" if a.end[0] == b.start[0] else "M852" + a.end[0] - 1, a.end[1], "M-851" if a.end[0] == b.start[0] else "M-852" ) def __checkExplicitStringConcat(self): @@ -1506,7 +1506,7 @@ for operand in (node.left, node.right) ) ): - self.__error(node.lineno - 1, node.col_offset, "M853") + self.__error(node.lineno - 1, node.col_offset, "M-853") ################################################################################# ## The following method checks default match cases. @@ -1946,7 +1946,7 @@ if good != names: desc = good[0] if len(good) == 1 else "({0})".format(", ".join(good)) as_ = " as " + node.name if node.name is not None else "" - return (node, "M514", ", ".join(names), as_, desc, inTryStar) + return (node, "M-514", ", ".join(names), as_, desc, inTryStar) return None @@ -2019,7 +2019,7 @@ @type ast.Return """ if self.__inClassInit() and node.value is not None: - self.violations.append((node, "M537")) + self.violations.append((node, "M-537")) self.generic_visit(node) @@ -2031,7 +2031,7 @@ @type ast.Yield """ if self.__inClassInit(): - self.violations.append((node, "M537")) + self.violations.append((node, "M-537")) self.generic_visit(node) @@ -2043,7 +2043,7 @@ @type ast.YieldFrom """ if self.__inClassInit(): - self.violations.append((node, "M537")) + self.violations.append((node, "M-537")) self.generic_visit(node) @@ -2094,7 +2094,7 @@ names = self.__checkForM513_M514_M529_M530(node) if "BaseException" in names and not ExceptBaseExceptionVisitor(node).reRaised(): - self.violations.append((node, "M536")) + self.violations.append((node, "M-536")) self.generic_visit(node) @@ -2102,7 +2102,7 @@ self.__M540CaughtException is not None and self.__M540CaughtException.hasNote ): - self.violations.append((node, "M540")) + self.violations.append((node, "M-540")) self.__M540CaughtException = oldM540CaughtException def visit_UAdd(self, node): @@ -2115,7 +2115,7 @@ trailingNodes = list(map(type, self.nodeWindow[-4:])) if trailingNodes == [ast.UnaryOp, ast.UAdd, ast.UnaryOp, ast.UAdd]: originator = self.nodeWindow[-4] - self.violations.append((originator, "M502")) + self.violations.append((originator, "M-502")) self.generic_visit(node) @@ -2143,28 +2143,28 @@ and args[0].value.id == "self" and args[0].attr == "__class__" ): - self.violations.append((node, "M582")) + self.violations.append((node, "M-582")) # bad getattr and setattr if ( node.func.id in ("getattr", "hasattr") and node.args[1].value == "__call__" ): - self.violations.append((node, "M504")) + self.violations.append((node, "M-504")) if ( node.func.id == "getattr" and len(node.args) == 2 and self.__isIdentifier(node.args[1]) and iskeyword(AstUtilities.getValue(node.args[1])) ): - self.violations.append((node, "M509")) + self.violations.append((node, "M-509")) elif ( node.func.id == "setattr" and len(node.args) == 3 and self.__isIdentifier(node.args[1]) and iskeyword(AstUtilities.getValue(node.args[1])) ): - self.violations.append((node, "M510")) + self.violations.append((node, "M-510")) self.__checkForM526(node) @@ -2209,7 +2209,7 @@ and isinstance(target.value, ast.Name) and (target.value.id, target.attr) == ("os", "environ") ): - self.violations.append((node, "M503")) + self.violations.append((node, "M-503")) self.generic_visit(node) @@ -2309,7 +2309,7 @@ AstUtilities.isNameConstant(node.test) and AstUtilities.getValue(node.test) is False ): - self.violations.append((node, "M511")) + self.violations.append((node, "M-511")) self.generic_visit(node) @@ -2423,7 +2423,7 @@ if isinstance(value, ast.FormattedValue): return - self.violations.append((node, "M581")) + self.violations.append((node, "M-581")) def visit_AnnAssign(self, node): """ @@ -2512,7 +2512,7 @@ if len(value) == len(set(value)): return # no characters appear more than once - self.violations.append((node, "M505")) + self.violations.append((node, "M-505")) def __checkForM506_M508(self, node): """ @@ -2521,7 +2521,7 @@ @param node reference to the node to be processed @type ast.AsyncFunctionDef or ast.FunctionDef """ - visitor = FunctionDefDefaultsVisitor("M506", "M508") + visitor = FunctionDefDefaultsVisitor("M-506", "M-508") visitor.visit(node.args.defaults + node.args.kw_defaults) self.violations.extend(visitor.errors) @@ -2541,7 +2541,7 @@ usedNames = set(body.getNames()) for name in sorted(ctrlNames - usedNames): n = targets.getNames()[name][0] - self.violations.append((n, "M507", name)) + self.violations.append((n, "M-507", name)) def __checkForM512(self, node): """ @@ -2559,7 +2559,7 @@ badNodeTypes = (ast.Return,) elif isinstance(node, badNodeTypes): - self.violations.append((node, "M512", self.__inTryStar)) + self.violations.append((node, "M-512", self.__inTryStar)) for child in ast.iter_child_nodes(node): _loop(child, badNodeTypes) @@ -2593,16 +2593,16 @@ else: badHandlers.append(handler) if badHandlers: - self.violations.append((node, "M530")) + self.violations.append((node, "M-530")) if len(names) == 0 and not badHandlers and not ignoredHandlers: - self.violations.append((node, "M529", self.__inTryStar)) + self.violations.append((node, "M-529", self.__inTryStar)) elif ( len(names) == 1 and not badHandlers and not ignoredHandlers and isinstance(node.type, ast.Tuple) ): - self.violations.append((node, "M513", *names, self.__inTryStar)) + self.violations.append((node, "M-513", *names, self.__inTryStar)) else: maybeError = self.__checkRedundantExcepthandlers( names, node, self.__inTryStar @@ -2619,7 +2619,7 @@ @type ast.Compare """ if isinstance(self.nodeStack[-2], ast.Expr): - self.violations.append((node, "M515")) + self.violations.append((node, "M-515")) def __checkForM516(self, node): """ @@ -2633,7 +2633,7 @@ or AstUtilities.isNumber(node.exc) or AstUtilities.isString(node.exc) ): - self.violations.append((node, "M516")) + self.violations.append((node, "M-516")) def __checkForM517(self, node): """ @@ -2673,7 +2673,7 @@ and itemContext.args[0].id in ("Exception", "BaseException") and not item.optional_vars ): - self.violations.append((node, "M517")) + self.violations.append((node, "M-517")) def __checkForM518(self, node): """ @@ -2698,7 +2698,7 @@ or node.value.value is None ) ): - self.violations.append((node, "M518", node.value.__class__.__name__)) + self.violations.append((node, "M-518", node.value.__class__.__name__)) def __checkForM519(self, node): """ @@ -2731,7 +2731,7 @@ return if decorator in caches: - self.violations.append((node.decorator_list[idx], "M519")) + self.violations.append((node.decorator_list[idx], "M-519")) return def __checkForM520(self, node): @@ -2752,7 +2752,7 @@ for name in sorted(ctrlNames): if name in itersetNames: n = targets.getNames()[name][0] - self.violations.append((n, "M520")) + self.violations.append((n, "M-520")) def __checkForM521(self, node): """ @@ -2766,7 +2766,7 @@ and isinstance(node.body[0], ast.Expr) and isinstance(node.body[0].value, ast.JoinedStr) ): - self.violations.append((node.body[0].value, "M521")) + self.violations.append((node.body[0].value, "M-521")) def __checkForM522(self, node): """ @@ -2786,7 +2786,7 @@ and itemContext.func.attr == "suppress" and len(itemContext.args) == 0 ): - self.violations.append((node, "M522")) + self.violations.append((node, "M-522")) def __checkForM523(self, loopNode): """ @@ -2860,7 +2860,7 @@ for err in sorted(suspiciousVariables): if reassignedInLoop.issuperset(err[2]): - self.violations.append((err[3], "M523", err[2])) + self.violations.append((err[3], "M-523", err[2])) def __checkForM524_M527(self, node): """ @@ -2941,10 +2941,10 @@ and emptyBody(stmt.body) and not any(map(isOverload, stmt.decorator_list)) ): - self.violations.append((stmt, "M527", stmt.name)) + self.violations.append((stmt, "M-527", stmt.name)) if hasMethod and not hasAbstractMethod: - self.violations.append((node, "M524", node.name)) + self.violations.append((node, "M-524", node.name)) def __checkForM525(self, node): """ @@ -2970,7 +2970,7 @@ # sort to have a deterministic output duplicates = sorted({x for x in seen if seen.count(x) > 1}) for duplicate in duplicates: - self.violations.append((node, "M525", duplicate, self.__inTryStar)) + self.violations.append((node, "M-525", duplicate, self.__inTryStar)) def __checkForM526(self, node): """ @@ -2992,7 +2992,7 @@ firstKeyword.lineno, firstKeyword.col_offset, ): - self.violations.append((node, "M526")) + self.violations.append((node, "M-526")) def __checkForM528(self, node): """ @@ -3011,7 +3011,7 @@ and not any(isinstance(a, ast.Starred) for a in node.args) and not any(kw.arg is None for kw in node.keywords) ): - self.violations.append((node, "M528")) + self.violations.append((node, "M-528")) def __checkForM531(self, loopNode): """ @@ -3051,13 +3051,13 @@ isinstance(nestedNode, ast.Name) and nestedNode.id == groupName ): - self.violations.append((nestedNode, "M531")) + self.violations.append((nestedNode, "M-531")) # Handle multiple uses if isinstance(node, ast.Name) and node.id == groupName: numUsages += 1 if numUsages > 1: - self.violations.append((nestedNode, "M531")) + self.violations.append((nestedNode, "M-531")) def __checkForM532(self, node): """ @@ -3078,7 +3078,7 @@ ) ) ): - self.violations.append((node, "M532")) + self.violations.append((node, "M-532")) def __checkForM533(self, node): """ @@ -3092,7 +3092,7 @@ if not isinstance(elt, ast.Constant): continue if elt.value in seen: - self.violations.append((node, "M533", repr(elt.value))) + self.violations.append((node, "M-533", repr(elt.value))) else: seen.add(elt.value) @@ -3113,7 +3113,7 @@ def check(numArgs, paramName): if len(node.args) > numArgs: arg = node.args[numArgs] - self.violations.append((arg, "M534", func.attr, paramName)) + self.violations.append((arg, "M-534", func.attr, paramName)) if func.attr in ("sub", "subn"): check(3, "count") @@ -3131,11 +3131,11 @@ @type ast.DictComp """ if isinstance(node.key, ast.Constant): - self.violations.append((node, "M535", node.key.value)) + self.violations.append((node, "M-535", node.key.value)) elif isinstance( node.key, ast.Name ) and node.key.id not in self.__getDictCompLoopAndNamedExprVarNames(node): - self.violations.append((node, "M535", node.key.id)) + self.violations.append((node, "M-535", node.key.id)) def __checkForM539(self, node): """ @@ -3162,7 +3162,7 @@ else: return - visitor = FunctionDefDefaultsVisitor("M539", "M539") + visitor = FunctionDefDefaultsVisitor("M-539", "M-539") visitor.visit(kw.value) self.violations.extend(visitor.errors) @@ -3253,7 +3253,7 @@ value = convertToValue(node.values[index]) if value in seen: keyNode = node.keys[index] - self.violations.append((keyNode, "M541")) + self.violations.append((keyNode, "M-541")) seen.add(value) def __checkForM569(self, node): @@ -3272,7 +3272,7 @@ checker = M569Checker(name, self) checker.visit(node.body) for mutation in checker.mutations: - self.violations.append((mutation, "M569")) + self.violations.append((mutation, "M-569")) class M569Checker(ast.NodeVisitor): @@ -3945,7 +3945,7 @@ """ for node in self.returns: if not node.value: - self.violations.append((node, "M832")) + self.violations.append((node, "M-832")) def __checkUnnecessaryReturnNone(self): """ @@ -3953,7 +3953,7 @@ """ for node in self.returns: if self.__isNone(node.value): - self.violations.append((node, "M831")) + self.violations.append((node, "M-831")) def __checkImplicitReturn(self, node): """ @@ -3964,7 +3964,7 @@ """ if isinstance(node, ast.If): if not node.body or not node.orelse: - self.violations.append((node, "M833")) + self.violations.append((node, "M-833")) return self.__checkImplicitReturn(node.body[-1]) @@ -3987,7 +3987,7 @@ except AttributeError: okNodes = (ast.Return, ast.Raise, ast.While) if not isinstance(node, okNodes): - self.violations.append((node, "M833")) + self.violations.append((node, "M-833")) def __checkUnnecessaryAssign(self, node): """ @@ -4006,13 +4006,13 @@ return if varname not in self.refs: - self.violations.append((node, "M834")) + self.violations.append((node, "M-834")) return if self.__hasRefsBeforeNextAssign(varname, returnLineno): return - self.violations.append((node, "M834")) + self.violations.append((node, "M-834")) def __hasRefsBeforeNextAssign(self, varname, returnLineno): """ @@ -4126,7 +4126,7 @@ ) if not (isCase1 or isCase2): - self.violations.append((node, "M301")) + self.violations.append((node, "M-301")) elif node.func.attr == "time": # time(12, 10, 45, 0, datetime.timezone.utc) @@ -4143,20 +4143,20 @@ ) if not (isCase1 or isCase2): - self.violations.append((node, "M321")) + self.violations.append((node, "M-321")) elif node.func.attr == "date": - self.violations.append((node, "M311")) + self.violations.append((node, "M-311")) if isDateTimeClass or isDateTimeModuleAndClass: if node.func.attr == "today": - self.violations.append((node, "M302")) + self.violations.append((node, "M-302")) elif node.func.attr == "utcnow": - self.violations.append((node, "M303")) + self.violations.append((node, "M-303")) elif node.func.attr == "utcfromtimestamp": - self.violations.append((node, "M304")) + self.violations.append((node, "M-304")) elif node.func.attr in "now": # datetime.now(UTC) @@ -4177,7 +4177,7 @@ ) if not (isCase1 or isCase2): - self.violations.append((node, "M305")) + self.violations.append((node, "M-305")) elif node.func.attr == "fromtimestamp": # datetime.fromtimestamp(1234, UTC) @@ -4198,7 +4198,7 @@ ) if not (isCase1 or isCase2): - self.violations.append((node, "M306")) + self.violations.append((node, "M-306")) elif node.func.attr == "strptime": # datetime.strptime(...).replace(tzinfo=UTC) @@ -4216,10 +4216,10 @@ ) if not isCase1: - self.violations.append((node, "M307")) + self.violations.append((node, "M-307")) elif node.func.attr == "fromordinal": - self.violations.append((node, "M308")) + self.violations.append((node, "M-308")) # date.something() isDateClass = ( @@ -4239,16 +4239,16 @@ if isDateClass or isDateModuleAndClass: if node.func.attr == "today": - self.violations.append((node, "M312")) + self.violations.append((node, "M-312")) elif node.func.attr == "fromtimestamp": - self.violations.append((node, "M313")) + self.violations.append((node, "M-313")) elif node.func.attr == "fromordinal": - self.violations.append((node, "M314")) + self.violations.append((node, "M-314")) elif node.func.attr == "fromisoformat": - self.violations.append((node, "M315")) + self.violations.append((node, "M-315")) self.generic_visit(node) @@ -4337,23 +4337,23 @@ @type ast.Subscript """ if self.__isSysVersionUpperSlice(node, 1): - self.violations.append((node.value, "M423")) + self.violations.append((node.value, "M-423")) elif self.__isSysVersionUpperSlice(node, 3): - self.violations.append((node.value, "M401")) + self.violations.append((node.value, "M-401")) elif ( self.__isSys("version", node.value) and isinstance(node.slice, ast.Index) and AstUtilities.isNumber(node.slice.value) and AstUtilities.getValue(node.slice.value) == 2 ): - self.violations.append((node.value, "M402")) + self.violations.append((node.value, "M-402")) elif ( self.__isSys("version", node.value) and isinstance(node.slice, ast.Index) and AstUtilities.isNumber(node.slice.value) and AstUtilities.getValue(node.slice.value) == 0 ): - self.violations.append((node.value, "M421")) + self.violations.append((node.value, "M-421")) self.generic_visit(node) @@ -4375,7 +4375,7 @@ and AstUtilities.isNumber(node.comparators[0]) and AstUtilities.getValue(node.comparators[0]) == 3 ): - self.violations.append((node.left, "M411")) + self.violations.append((node.left, "M-411")) elif ( self.__isSys("version", node.left) and len(node.ops) == 1 @@ -4383,9 +4383,9 @@ and AstUtilities.isString(node.comparators[0]) ): if len(AstUtilities.getValue(node.comparators[0])) == 1: - errorCode = "M422" + errorCode = "M-422" else: - errorCode = "M403" + errorCode = "M-403" self.violations.append((node.left, errorCode)) elif ( isinstance(node.left, ast.Subscript) @@ -4397,7 +4397,7 @@ and isinstance(node.ops[0], (ast.Lt, ast.LtE, ast.Gt, ast.GtE)) and AstUtilities.isNumber(node.comparators[0]) ): - self.violations.append((node, "M413")) + self.violations.append((node, "M-413")) elif ( isinstance(node.left, ast.Attribute) and self.__isSys("version_info", node.left.value) @@ -4406,7 +4406,7 @@ and isinstance(node.ops[0], (ast.Lt, ast.LtE, ast.Gt, ast.GtE)) and AstUtilities.isNumber(node.comparators[0]) ): - self.violations.append((node, "M414")) + self.violations.append((node, "M-414")) self.generic_visit(node) @@ -4422,7 +4422,7 @@ and node.value.id == "six" and node.attr == "PY3" ): - self.violations.append((node, "M412")) + self.violations.append((node, "M-412")) self.generic_visit(node) @@ -4434,7 +4434,7 @@ @type ast.Name """ if node.id == "PY3" and self.__fromImports.get(node.id) == "six": - self.violations.append((node, "M412")) + self.violations.append((node, "M-412")) self.generic_visit(node) @@ -4479,9 +4479,9 @@ for case in node.cases: if self.__emptyMatchDefault(case): if self.__lastStatementDoesNotRaise(case): - yield self.__findBadNode(case), "M901" + yield self.__findBadNode(case), "M-901" elif self.__returnPrecedesExceptionRaising(case): - yield self.__findBadNode(case), "M902" + yield self.__findBadNode(case), "M-902" def __emptyMatchDefault(self, case): """
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -13,317 +13,317 @@ _miscellaneousMessages = { ## Coding line - "M101": QCoreApplication.translate( + "M-101": QCoreApplication.translate( "MiscellaneousChecker", "coding magic comment not found", ), - "M102": QCoreApplication.translate( + "M-102": QCoreApplication.translate( "MiscellaneousChecker", "unknown encoding ({0}) found in coding magic comment", ), ## Copyright - "M111": QCoreApplication.translate( + "M-111": QCoreApplication.translate( "MiscellaneousChecker", "copyright notice not present", ), - "M112": QCoreApplication.translate( + "M-112": QCoreApplication.translate( "MiscellaneousChecker", "copyright notice contains invalid author", ), ## Shadowed Builtins - "M131": QCoreApplication.translate( + "M-131": QCoreApplication.translate( "MiscellaneousChecker", '"{0}" is a Python builtin and is being shadowed; ' "consider renaming the variable", ), - "M132": QCoreApplication.translate( + "M-132": QCoreApplication.translate( "MiscellaneousChecker", '"{0}" is used as an argument and thus shadows a ' "Python builtin; consider renaming the argument", ), ## Comprehensions - "M180": QCoreApplication.translate( + "M-180": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary generator - rewrite as a list comprehension", ), - "M181": QCoreApplication.translate( + "M-181": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary generator - rewrite as a set comprehension", ), - "M182": QCoreApplication.translate( + "M-182": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary generator - rewrite as a dict comprehension", ), - "M183": QCoreApplication.translate( + "M-183": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary list comprehension - rewrite as a set comprehension", ), - "M184": QCoreApplication.translate( + "M-184": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary list comprehension - rewrite as a dict comprehension", ), - "M185": QCoreApplication.translate( + "M-185": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} literal - rewrite as a {1} literal", ), - "M186": QCoreApplication.translate( + "M-186": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} literal - rewrite as a {1} literal", ), - "M188": QCoreApplication.translate( + "M-188": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} call - rewrite as a literal", ), - "M189a": QCoreApplication.translate( + "M-189a": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} passed to tuple() - remove the outer call to {1}()", ), - "M189b": QCoreApplication.translate( + "M-189b": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} passed to tuple() - rewrite as a {1} literal", ), - "M190a": QCoreApplication.translate( + "M-190a": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} passed to list() - remove the outer call to {1}()", ), - "M190b": QCoreApplication.translate( + "M-190b": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} passed to list() - rewrite as a {1} literal", ), - "M191": QCoreApplication.translate( + "M-191": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary list call - remove the outer call to list()", ), - "M193a": QCoreApplication.translate( + "M-193a": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} call around {1}() - toggle reverse argument to sorted()", ), - "M193b": QCoreApplication.translate( + "M-193b": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} call around {1}() - use sorted(..., reverse={2!r})", ), - "M193c": QCoreApplication.translate( + "M-193c": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} call around {1}()", ), - "M194": QCoreApplication.translate( + "M-194": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} call within {1}()", ), - "M195": QCoreApplication.translate( + "M-195": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary subscript reversal of iterable within {0}()", ), - "M196": QCoreApplication.translate( + "M-196": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} comprehension - rewrite using {0}()", ), - "M197": QCoreApplication.translate( + "M-197": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary use of map - use a {0} instead", ), - "M198": QCoreApplication.translate( + "M-198": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} passed to dict() - remove the outer call to dict()", ), - "M199": QCoreApplication.translate( + "M-199": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary list comprehension passed to {0}() prevents short-circuiting" " - rewrite as a generator", ), - "M200": QCoreApplication.translate( + "M-200": QCoreApplication.translate( "MiscellaneousChecker", "unnecessary {0} comprehension - rewrite using dict.fromkeys()", ), ## Dictionaries with sorted keys - "M251": QCoreApplication.translate( + "M-251": QCoreApplication.translate( "MiscellaneousChecker", "sort keys - '{0}' should be before '{1}'", ), ## Property - "M260": QCoreApplication.translate( + "M-260": QCoreApplication.translate( "MiscellaneousChecker", "the number of arguments for property getter method is wrong" " (should be 1 instead of {0})", ), - "M261": QCoreApplication.translate( + "M-261": QCoreApplication.translate( "MiscellaneousChecker", "the number of arguments for property setter method is wrong" " (should be 2 instead of {0})", ), - "M262": QCoreApplication.translate( + "M-262": QCoreApplication.translate( "MiscellaneousChecker", "the number of arguments for property deleter method is wrong" " (should be 1 instead of {0})", ), - "M263": QCoreApplication.translate( + "M-263": QCoreApplication.translate( "MiscellaneousChecker", "the name of the setter method is wrong (should be '{0}' instead of '{1}')", ), - "M264": QCoreApplication.translate( + "M-264": QCoreApplication.translate( "MiscellaneousChecker", "the name of the deleter method is wrong (should be '{0}' instead of '{1}')", ), - "M265": QCoreApplication.translate( + "M-265": QCoreApplication.translate( "MiscellaneousChecker", "the name of the setter decorator is wrong (should be '{0}' instead of '{1}')", ), - "M266": QCoreApplication.translate( + "M-266": QCoreApplication.translate( "MiscellaneousChecker", "the name of the deleter decorator is wrong (should be '{0}' instead of '{1}')", ), - "M267": QCoreApplication.translate( + "M-267": QCoreApplication.translate( "MiscellaneousChecker", "multiple decorators were used to declare property '{0}'", ), ## Naive datetime usage - "M301": QCoreApplication.translate( + "M-301": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime()' without 'tzinfo' argument should be avoided", ), - "M302": QCoreApplication.translate( + "M-302": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime.today()' should be avoided.\n" "Use 'datetime.datetime.now(tz=)' instead.", ), - "M303": QCoreApplication.translate( + "M-303": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime.utcnow()' should be avoided.\n" "Use 'datetime.datetime.now(tz=datetime.timezone.utc)' instead.", ), - "M304": QCoreApplication.translate( + "M-304": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime.utcfromtimestamp()' should be avoided.\n" "Use 'datetime.datetime.fromtimestamp(..., tz=datetime.timezone.utc)' instead.", ), - "M305": QCoreApplication.translate( + "M-305": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime.now()' without 'tz' argument should be avoided", ), - "M306": QCoreApplication.translate( + "M-306": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime.fromtimestamp()' without 'tz' argument" " should be avoided", ), - "M307": QCoreApplication.translate( + "M-307": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime.strptime()' should be followed by" " '.replace(tzinfo=)'", ), - "M308": QCoreApplication.translate( + "M-308": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.datetime.fromordinal()' should be avoided", ), - "M311": QCoreApplication.translate( + "M-311": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.date()' should be avoided.\n" "Use 'datetime.datetime(, tzinfo=).date()' instead.", ), - "M312": QCoreApplication.translate( + "M-312": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.date.today()' should be avoided.\n" "Use 'datetime.datetime.now(tz=).date()' instead.", ), - "M313": QCoreApplication.translate( + "M-313": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.date.fromtimestamp()' should be avoided.\n" "Use 'datetime.datetime.fromtimestamp(tz=).date()' instead.", ), - "M314": QCoreApplication.translate( + "M-314": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.date.fromordinal()' should be avoided", ), - "M315": QCoreApplication.translate( + "M-315": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.date.fromisoformat()' should be avoided", ), - "M321": QCoreApplication.translate( + "M-321": QCoreApplication.translate( "MiscellaneousChecker", "use of 'datetime.time()' without 'tzinfo' argument should be avoided", ), ## sys.version and sys.version_info usage - "M401": QCoreApplication.translate( + "M-401": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version[:3]' referenced (Python 3.10), use 'sys.version_info'", ), - "M402": QCoreApplication.translate( + "M-402": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version[2]' referenced (Python 3.10), use 'sys.version_info'", ), - "M403": QCoreApplication.translate( + "M-403": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version' compared to string (Python 3.10), use 'sys.version_info'", ), - "M411": QCoreApplication.translate( + "M-411": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version_info[0] == 3' referenced (Python 4), use '>='", ), - "M412": QCoreApplication.translate( + "M-412": QCoreApplication.translate( "MiscellaneousChecker", "'six.PY3' referenced (Python 4), use 'not six.PY2'", ), - "M413": QCoreApplication.translate( + "M-413": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version_info[1]' compared to integer (Python 4)," " compare 'sys.version_info' to tuple", ), - "M414": QCoreApplication.translate( + "M-414": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version_info.minor' compared to integer (Python 4)," " compare 'sys.version_info' to tuple", ), - "M421": QCoreApplication.translate( + "M-421": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version[0]' referenced (Python 10), use 'sys.version_info'", ), - "M422": QCoreApplication.translate( + "M-422": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version' compared to string (Python 10), use 'sys.version_info'", ), - "M423": QCoreApplication.translate( + "M-423": QCoreApplication.translate( "MiscellaneousChecker", "'sys.version[:1]' referenced (Python 10), use 'sys.version_info'", ), ## Bugbear - "M501": QCoreApplication.translate( + "M-501": QCoreApplication.translate( "MiscellaneousChecker", "Do not use bare 'except:', it also catches unexpected events like memory" " errors, interrupts, system exit, and so on. Prefer excepting specific" " exceptions. If you're sure what you're doing, be explicit and write" " 'except BaseException:'.", ), - "M502": QCoreApplication.translate( + "M-502": QCoreApplication.translate( "MiscellaneousChecker", "Python does not support the unary prefix increment", ), - "M503": QCoreApplication.translate( + "M-503": QCoreApplication.translate( "MiscellaneousChecker", "assigning to 'os.environ' does not clear the environment -" " use 'os.environ.clear()'", ), - "M504": QCoreApplication.translate( + "M-504": QCoreApplication.translate( "MiscellaneousChecker", """using 'hasattr(x, "__call__")' to test if 'x' is callable is""" """ unreliable. Use 'callable(x)' for consistent results.""", ), - "M505": QCoreApplication.translate( + "M-505": QCoreApplication.translate( "MiscellaneousChecker", "using .strip() with multi-character strings is misleading. Use .replace()," " .removeprefix(), .removesuffix(), or regular expressions to remove string" " fragments.", ), - "M506": QCoreApplication.translate( + "M-506": QCoreApplication.translate( "MiscellaneousChecker", "Do not use mutable data structures for argument defaults. They are created" " during function definition time. All calls to the function reuse this one" " instance of that data structure, persisting changes between them.", ), - "M507": QCoreApplication.translate( + "M-507": QCoreApplication.translate( "MiscellaneousChecker", "loop control variable {0} not used within the loop body -" " start the name with an underscore", ), - "M508": QCoreApplication.translate( + "M-508": QCoreApplication.translate( "MiscellaneousChecker", "Do not perform function calls in argument defaults. The call is performed" " only once at function definition time. All calls to your function will reuse" @@ -331,44 +331,44 @@ " assign the function call to a module-level variable and use that variable as" " a default value.", ), - "M509": QCoreApplication.translate( + "M-509": QCoreApplication.translate( "MiscellaneousChecker", "do not call getattr with a constant attribute value", ), - "M510": QCoreApplication.translate( + "M-510": QCoreApplication.translate( "MiscellaneousChecker", "do not call setattr with a constant attribute value", ), - "M511": QCoreApplication.translate( + "M-511": QCoreApplication.translate( "MiscellaneousChecker", "do not call assert False since python -O removes these calls", ), - "M512": QCoreApplication.translate( + "M-512": QCoreApplication.translate( "MiscellaneousChecker", "return/continue/break inside finally blocks cause exceptions to be silenced." " Exceptions should be silenced in except{0} blocks. Control statements can be" " moved outside the finally block.", ), - "M513": QCoreApplication.translate( + "M-513": QCoreApplication.translate( "MiscellaneousChecker", "A length-one tuple literal is redundant. Write 'except{1} {0}:' instead of" " 'except{1} ({0},):'.", ), - "M514": QCoreApplication.translate( + "M-514": QCoreApplication.translate( "MiscellaneousChecker", "Redundant exception types in 'except{3} ({0}){1}:'. Write 'except{3} {2}{1}:'," " which catches exactly the same exceptions.", ), - "M515": QCoreApplication.translate( + "M-515": QCoreApplication.translate( "MiscellaneousChecker", "Result of comparison is not used. This line doesn't do anything. Did you" " intend to prepend it with assert?", ), - "M516": QCoreApplication.translate( + "M-516": QCoreApplication.translate( "MiscellaneousChecker", "Cannot raise a literal. Did you intend to return it or raise an Exception?", ), - "M517": QCoreApplication.translate( + "M-517": QCoreApplication.translate( "MiscellaneousChecker", "'assertRaises(Exception)' and 'pytest.raises(Exception)' should " "be considered evil. They can lead to your test passing even if the " @@ -377,61 +377,61 @@ "(if using 'assertRaises'), or add the 'match' keyword argument (if " "using 'pytest.raises'), or use the context manager form with a target.", ), - "M518": QCoreApplication.translate( + "M-518": QCoreApplication.translate( "MiscellaneousChecker", "Found useless {0} expression. Consider either assigning it to a variable or" " removing it.", ), - "M519": QCoreApplication.translate( + "M-519": QCoreApplication.translate( "MiscellaneousChecker", "Use of 'functools.lru_cache' or 'functools.cache' on methods can lead to" " memory leaks. The cache may retain instance references, preventing garbage" " collection.", ), - "M520": QCoreApplication.translate( + "M-520": QCoreApplication.translate( "MiscellaneousChecker", "Found for loop that reassigns the iterable it is iterating with each" " iterable value.", ), - "M521": QCoreApplication.translate( + "M-521": QCoreApplication.translate( "MiscellaneousChecker", "f-string used as docstring. This will be interpreted by python as a joined" " string rather than a docstring.", ), - "M522": QCoreApplication.translate( + "M-522": QCoreApplication.translate( "MiscellaneousChecker", "No arguments passed to 'contextlib.suppress'. No exceptions will be" " suppressed and therefore this context manager is redundant.", ), - "M523": QCoreApplication.translate( + "M-523": QCoreApplication.translate( "MiscellaneousChecker", "Function definition does not bind loop variable '{0}'.", ), - "M524": QCoreApplication.translate( + "M-524": QCoreApplication.translate( "MiscellaneousChecker", "{0} is an abstract base class, but none of the methods it defines are" " abstract. This is not necessarily an error, but you might have forgotten to" " add the @abstractmethod decorator, potentially in conjunction with" " @classmethod, @property and/or @staticmethod.", ), - "M525": QCoreApplication.translate( + "M-525": QCoreApplication.translate( "MiscellaneousChecker", "Exception '{0}' has been caught multiple times. Only the first except{1} will" " be considered and all other except{1} catches can be safely removed.", ), - "M526": QCoreApplication.translate( + "M-526": QCoreApplication.translate( "MiscellaneousChecker", "Star-arg unpacking after a keyword argument is strongly discouraged," " because it only works when the keyword parameter is declared after all" " parameters supplied by the unpacked sequence, and this change of ordering can" " surprise and mislead readers.", ), - "M527": QCoreApplication.translate( + "M-527": QCoreApplication.translate( "MiscellaneousChecker", "{0} is an empty method in an abstract base class, but has no abstract" " decorator. Consider adding @abstractmethod.", ), - "M528": QCoreApplication.translate( + "M-528": QCoreApplication.translate( "MiscellaneousChecker", "No explicit stacklevel argument found. The warn method from the" " warnings module uses a stacklevel of 1 by default. This will only show a" @@ -439,209 +439,209 @@ " It is therefore recommended to use a stacklevel of 2 or" " greater to provide more information to the user.", ), - "M529": QCoreApplication.translate( + "M-529": QCoreApplication.translate( "MiscellaneousChecker", "Using 'except{0} ():' with an empty tuple does not handle/catch " "anything. Add exceptions to handle.", ), - "M530": QCoreApplication.translate( + "M-530": QCoreApplication.translate( "MiscellaneousChecker", "Except handlers should only be names of exception classes", ), - "M531": QCoreApplication.translate( + "M-531": QCoreApplication.translate( "MiscellaneousChecker", "Using the generator returned from 'itertools.groupby()' more than once" " will do nothing on the second usage. Save the result to a list, if the" " result is needed multiple times.", ), - "M532": QCoreApplication.translate( + "M-532": QCoreApplication.translate( "MiscellaneousChecker", "Possible unintentional type annotation (using ':'). Did you mean to" " assign (using '=')?", ), - "M533": QCoreApplication.translate( + "M-533": QCoreApplication.translate( "MiscellaneousChecker", "Set should not contain duplicate item '{0}'. Duplicate items will be replaced" " with a single item at runtime.", ), - "M534": QCoreApplication.translate( + "M-534": QCoreApplication.translate( "MiscellaneousChecker", "re.{0} should get '{1}' and 'flags' passed as keyword arguments to avoid" " confusion due to unintuitive argument positions.", ), - "M535": QCoreApplication.translate( + "M-535": QCoreApplication.translate( "MiscellaneousChecker", "Static key in dict comprehension: {0!r}.", ), - "M536": QCoreApplication.translate( + "M-536": QCoreApplication.translate( "MiscellaneousChecker", "Don't except 'BaseException' unless you plan to re-raise it.", ), - "M537": QCoreApplication.translate( + "M-537": QCoreApplication.translate( "MiscellaneousChecker", "Class '__init__' methods must not return or yield any values.", ), - "M539": QCoreApplication.translate( + "M-539": QCoreApplication.translate( "MiscellaneousChecker", "ContextVar with mutable literal or function call as default. This is only" " evaluated once, and all subsequent calls to `.get()` will return the same" " instance of the default.", ), - "M540": QCoreApplication.translate( + "M-540": QCoreApplication.translate( "MiscellaneousChecker", "Exception with added note not used. Did you forget to raise it?", ), - "M541": QCoreApplication.translate( + "M-541": QCoreApplication.translate( "MiscellaneousChecker", "Repeated key-value pair in dictionary literal.", ), ## Bugbear, opininonated - "M569": QCoreApplication.translate( + "M-569": QCoreApplication.translate( "MiscellaneousChecker", "Editing a loop's mutable iterable often leads to unexpected results/bugs.", ), ## Bugbear++ - "M581": QCoreApplication.translate( + "M-581": QCoreApplication.translate( "MiscellaneousChecker", "unncessary f-string", ), - "M582": QCoreApplication.translate( + "M-582": QCoreApplication.translate( "MiscellaneousChecker", "cannot use 'self.__class__' as first argument of 'super()' call", ), ## Format Strings - "M601": QCoreApplication.translate( + "M-601": QCoreApplication.translate( "MiscellaneousChecker", "found {0} formatter", ), - "M611": QCoreApplication.translate( + "M-611": QCoreApplication.translate( "MiscellaneousChecker", "format string does contain unindexed parameters", ), - "M612": QCoreApplication.translate( + "M-612": QCoreApplication.translate( "MiscellaneousChecker", "docstring does contain unindexed parameters", ), - "M613": QCoreApplication.translate( + "M-613": QCoreApplication.translate( "MiscellaneousChecker", "other string does contain unindexed parameters", ), - "M621": QCoreApplication.translate( + "M-621": QCoreApplication.translate( "MiscellaneousChecker", "format call uses too large index ({0})", ), - "M622": QCoreApplication.translate( + "M-622": QCoreApplication.translate( "MiscellaneousChecker", "format call uses missing keyword ({0})", ), - "M623": QCoreApplication.translate( + "M-623": QCoreApplication.translate( "MiscellaneousChecker", "format call uses keyword arguments but no named entries", ), - "M624": QCoreApplication.translate( + "M-624": QCoreApplication.translate( "MiscellaneousChecker", "format call uses variable arguments but no numbered entries", ), - "M625": QCoreApplication.translate( + "M-625": QCoreApplication.translate( "MiscellaneousChecker", "format call uses implicit and explicit indexes together", ), - "M631": QCoreApplication.translate( + "M-631": QCoreApplication.translate( "MiscellaneousChecker", "format call provides unused index ({0})", ), - "M632": QCoreApplication.translate( + "M-632": QCoreApplication.translate( "MiscellaneousChecker", "format call provides unused keyword ({0})", ), ## Future statements - "M701": QCoreApplication.translate( + "M-701": QCoreApplication.translate( "MiscellaneousChecker", "expected these __future__ imports: {0}; but only got: {1}", ), - "M702": QCoreApplication.translate( + "M-702": QCoreApplication.translate( "MiscellaneousChecker", "expected these __future__ imports: {0}; but got none", ), ## Gettext - "M711": QCoreApplication.translate( + "M-711": QCoreApplication.translate( "MiscellaneousChecker", "gettext import with alias _ found: {0}", ), ##~ print() statements - "M801": QCoreApplication.translate( + "M-801": QCoreApplication.translate( "MiscellaneousChecker", "print statement found", ), ## one element tuple - "M811": QCoreApplication.translate( + "M-811": QCoreApplication.translate( "MiscellaneousChecker", "one element tuple found", ), ## Mutable Defaults - "M821": QCoreApplication.translate( + "M-821": QCoreApplication.translate( "MiscellaneousChecker", "mutable default argument of type {0}", ), - "M822": QCoreApplication.translate( + "M-822": QCoreApplication.translate( "MiscellaneousChecker", "mutable default argument of type {0}", ), - "M823": QCoreApplication.translate( + "M-823": QCoreApplication.translate( "MiscellaneousChecker", "mutable default argument of function call '{0}'", ), ##~ return statements - "M831": QCoreApplication.translate( + "M-831": QCoreApplication.translate( "MiscellaneousChecker", "None should not be added at any return if function has no return" " value except None", ), - "M832": QCoreApplication.translate( + "M-832": QCoreApplication.translate( "MiscellaneousChecker", "an explicit value at every return should be added if function has" " a return value except None", ), - "M833": QCoreApplication.translate( + "M-833": QCoreApplication.translate( "MiscellaneousChecker", "an explicit return at the end of the function should be added if" " it has a return value except None", ), - "M834": QCoreApplication.translate( + "M-834": QCoreApplication.translate( "MiscellaneousChecker", "a value should not be assigned to a variable if it will be used as a" " return value only", ), ## line continuation - "M841": QCoreApplication.translate( + "M-841": QCoreApplication.translate( "MiscellaneousChecker", "prefer implied line continuation inside parentheses, " "brackets and braces as opposed to a backslash", ), ## implicitly concatenated strings - "M851": QCoreApplication.translate( + "M-851": QCoreApplication.translate( "MiscellaneousChecker", "implicitly concatenated string or bytes literals on one line", ), - "M852": QCoreApplication.translate( + "M-852": QCoreApplication.translate( "MiscellaneousChecker", "implicitly concatenated string or bytes literals over continuation line", ), - "M853": QCoreApplication.translate( + "M-853": QCoreApplication.translate( "MiscellaneousChecker", "explicitly concatenated string or bytes should be implicitly concatenated", ), ## commented code - "M891": QCoreApplication.translate( + "M-891": QCoreApplication.translate( "MiscellaneousChecker", "commented code lines should be removed", ), ## structural pattern matching - "M901": QCoreApplication.translate( + "M-901": QCoreApplication.translate( "MiscellaneousChecker", "matching a default value should raise a `ValueError` exception", ), - "M902": QCoreApplication.translate( + "M-902": QCoreApplication.translate( "MiscellaneousChecker", "matching a default value should not contain a `return` statement before " "raising a `ValueError` exception", @@ -650,66 +650,66 @@ _miscellaneousMessagesSampleArgs = { ## Coding line - "M102": ["enc42"], + "M-102": ["enc42"], ## Shadowed Builtins - "M131": ["list"], - "M132": ["list"], + "M-131": ["list"], + "M-132": ["list"], ## Comprehensions - "M185": ["list", "set"], - "M186": ["list", "dict"], - "M188": ["list"], - "M189a": ["tuple", "tuple"], - "M189b": ["list", "tuple"], - "M190a": ["list", "list"], - "M190b": ["tuple", "list"], - "M193a": ["reversed", "sorted"], - "M193b": ["reversed", "sorted", "True"], - "M193c": ["list", "sorted"], - "M194": ["list", "sorted"], - "M195": ["sorted"], - "M196": ["list"], - "M197": ["list"], - "M198": ["dict comprehension"], - "M199": ["any"], - "M200": ["dict"], + "M-185": ["list", "set"], + "M-186": ["list", "dict"], + "M-188": ["list"], + "M-189a": ["tuple", "tuple"], + "M-189b": ["list", "tuple"], + "M-190a": ["list", "list"], + "M-190b": ["tuple", "list"], + "M-193a": ["reversed", "sorted"], + "M-193b": ["reversed", "sorted", "True"], + "M-193c": ["list", "sorted"], + "M-194": ["list", "sorted"], + "M-195": ["sorted"], + "M-196": ["list"], + "M-197": ["list"], + "M-198": ["dict comprehension"], + "M-199": ["any"], + "M-200": ["dict"], ## Dictionaries with sorted keys - "M251": ["bar", "foo"], + "M-251": ["bar", "foo"], ## Property - "M260": [2], - "M261": [1], - "M262": [2], - "M263": ["foo", "bar"], - "M264": ["foo", "bar"], - "M265": ["foo", "bar"], - "M266": ["foo", "bar"], - "M267": ["foo"], + "M-260": [2], + "M-261": [1], + "M-262": [2], + "M-263": ["foo", "bar"], + "M-264": ["foo", "bar"], + "M-265": ["foo", "bar"], + "M-266": ["foo", "bar"], + "M-267": ["foo"], ## Bugbear - "M507": ["x"], - "M512": [""], - "M513": ["Exception", ""], - "M514": ["OSError, IOError", " as err", "OSError", ""], - "M518": ["List"], - "M523": ["x"], - "M524": ["foobar"], - "M525": ["OSError", ""], - "M527": ["foo"], - "M529": [""], - "M533": ["foo"], - "M534": ["split", "maxsplit"], - "M535": ["foo"], + "M-507": ["x"], + "M-512": [""], + "M-513": ["Exception", ""], + "M-514": ["OSError, IOError", " as err", "OSError", ""], + "M-518": ["List"], + "M-523": ["x"], + "M-524": ["foobar"], + "M-525": ["OSError", ""], + "M-527": ["foo"], + "M-529": [""], + "M-533": ["foo"], + "M-534": ["split", "maxsplit"], + "M-535": ["foo"], ## Format Strings - "M601": ["%s"], - "M621": [5], - "M622": ["foo"], - "M631": [5], - "M632": ["foo"], + "M-601": ["%s"], + "M-621": [5], + "M-622": ["foo"], + "M-631": [5], + "M-632": ["foo"], ## Future statements - "M701": ["print_function, unicode_literals", "print_function"], - "M702": ["print_function, unicode_literals"], + "M-701": ["print_function, unicode_literals", "print_function"], + "M-702": ["print_function, unicode_literals"], ## Gettext - "M711": ["lgettext"], + "M-711": ["lgettext"], ## Mutable Defaults - "M821": ["Dict"], - "M822": ["Call"], - "M823": ["dict"], + "M-821": ["Dict"], + "M-822": ["Call"], + "M-823": ["dict"], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Naming/NamingStyleChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Naming/NamingStyleChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,25 +26,25 @@ """ Codes = [ - "N801", - "N802", - "N803", - "N804", - "N805", - "N806", - "N807", - "N808", - "N809", - "N811", - "N812", - "N813", - "N814", - "N815", - "N818", - "N821", - "N822", - "N823", - "N831", + "N-801", + "N-802", + "N-803", + "N-804", + "N-805", + "N-806", + "N-807", + "N-808", + "N-809", + "N-811", + "N-812", + "N-813", + "N-814", + "N-815", + "N-818", + "N-821", + "N-822", + "N-823", + "N-831", ] def __init__(self, source, filename, tree, select, ignore, expected, repeat, args): @@ -87,23 +87,23 @@ self.__checkersWithCodes = { "classdef": [ - (self.__checkClassName, ("N801", "N818")), - (self.__checkNameToBeAvoided, ("N831",)), + (self.__checkClassName, ("N-801", "N-818")), + (self.__checkNameToBeAvoided, ("N-831",)), ], "module": [ - (self.__checkModule, ("N807", "N808")), + (self.__checkModule, ("N-807", "N-808")), ], } for name in ("functiondef", "asyncfunctiondef"): self.__checkersWithCodes[name] = [ - (self.__checkFunctionName, ("N802", "N809")), - (self.__checkFunctionArgumentNames, ("N803", "N804", "N805", "N806")), - (self.__checkNameToBeAvoided, ("N831",)), + (self.__checkFunctionName, ("N-802", "N-809")), + (self.__checkFunctionArgumentNames, ("N-803", "N-804", "N-805", "N-806")), + (self.__checkNameToBeAvoided, ("N-831",)), ] for name in ("assign", "namedexpr", "annassign"): self.__checkersWithCodes[name] = [ - (self.__checkVariableNames, ("N821",)), - (self.__checkNameToBeAvoided, ("N831",)), + (self.__checkVariableNames, ("N-821",)), + (self.__checkNameToBeAvoided, ("N-831",)), ] for name in ( "with", @@ -117,11 +117,11 @@ "setcomp", ): self.__checkersWithCodes[name] = [ - (self.__checkVariableNames, ("N821",)), + (self.__checkVariableNames, ("N-821",)), ] for name in ("import", "importfrom"): self.__checkersWithCodes[name] = [ - (self.__checkImportAs, ("N811", "N812", "N813", "N814", "N815")), + (self.__checkImportAs, ("N-811", "N-812", "N-813", "N-814", "N-815")), ] self.__checkers = collections.defaultdict(list) @@ -335,13 +335,13 @@ if isinstance(node, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)): name = node.name if self.__isNameToBeAvoided(name): - self.__error(node, "N831") + self.__error(node, "N-831") elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): argNames = self.__getArgNames(node) for arg in argNames: if self.__isNameToBeAvoided(arg): - self.__error(node, "N831") + self.__error(node, "N-831") elif isinstance(node, (ast.Assign, ast.NamedExpr, ast.AnnAssign)): if isinstance(node, ast.Assign): @@ -352,14 +352,14 @@ if isinstance(target, ast.Name): name = target.id if bool(name) and self.__isNameToBeAvoided(name): - self.__error(node, "N831") + self.__error(node, "N-831") elif isinstance(target, (ast.Tuple, ast.List)): for element in target.elts: if isinstance(element, ast.Name): name = element.id if bool(name) and self.__isNameToBeAvoided(name): - self.__error(node, "N831") + self.__error(node, "N-831") def __getClassdef(self, name, parents): """ @@ -422,11 +422,11 @@ name = node.name strippedName = name.strip("_") if not strippedName[:1].isupper() or "_" in strippedName: - self.__error(node, "N801") + self.__error(node, "N-801") superClasses = self.__superClassNames(name, parents) if "Exception" in superClasses and not name.endswith("Error"): - self.__error(node, "N818") + self.__error(node, "N-818") def __checkFunctionName(self, node, _parents): """ @@ -451,9 +451,9 @@ return if name.lower() != name: - self.__error(node, "N802") + self.__error(node, "N-802") if functionType == "function" and name[:2] == "__" and name[-2:] == "__": - self.__error(node, "N809") + self.__error(node, "N-809") def __checkFunctionArgumentNames(self, node, _parents): """ @@ -472,12 +472,12 @@ if node.args.kwarg is not None: kwarg = node.args.kwarg.arg if kwarg.lower() != kwarg: - self.__error(node, "N803") + self.__error(node, "N-803") elif node.args.vararg is not None: vararg = node.args.vararg.arg if vararg.lower() != vararg: - self.__error(node, "N803") + self.__error(node, "N-803") else: argNames = self.__getArgNames(node) @@ -485,19 +485,19 @@ if not argNames: if functionType == "method": - self.__error(node, "N805") + self.__error(node, "N-805") elif functionType == "classmethod": - self.__error(node, "N804") + self.__error(node, "N-804") elif functionType == "method" and argNames[0] != "self": - self.__error(node, "N805") + self.__error(node, "N-805") elif functionType == "classmethod" and argNames[0] != "cls": - self.__error(node, "N804") + self.__error(node, "N-804") elif functionType == "staticmethod" and argNames[0] in ("cls", "self"): - self.__error(node, "N806") + self.__error(node, "N-806") for arg in argNames: if arg.lower() != arg: - self.__error(node, "N803") + self.__error(node, "N-803") break def __checkVariableNames(self, node, parents): @@ -607,7 +607,7 @@ @rtype str or None """ if self.__isMixedCase(name): - return "N823" + return "N-823" return None @@ -621,7 +621,7 @@ @rtype str or None """ if self.__isMixedCase(name): - return "N822" + return "N-822" return None @@ -637,7 +637,7 @@ @rtype str or None """ if varName not in func.global_names and varName.lower() != varName: - return "N821" + return "N-821" return None @@ -675,13 +675,13 @@ if self.__filename: moduleName = os.path.splitext(os.path.basename(self.__filename))[0] if moduleName.lower() != moduleName: - self.__error(node, "N807") + self.__error(node, "N-807") if moduleName == "__init__": # we got a package packageName = os.path.split(os.path.dirname(self.__filename))[1] if packageName.lower() != packageName: - self.__error(node, "N808") + self.__error(node, "N-808") def __checkImportAs(self, node, _parents): """ @@ -701,14 +701,14 @@ originalName = name.name if originalName.isupper(): if not asname.isupper(): - self.__error(node, "N811") + self.__error(node, "N-811") elif originalName.islower(): if asname.lower() != asname: - self.__error(node, "N812") + self.__error(node, "N-812") elif asname.islower(): - self.__error(node, "N813") + self.__error(node, "N-813") elif asname.isupper(): if "".join(filter(str.isupper, originalName)) == asname: - self.__error(node, "N815") + self.__error(node, "N-815") else: - self.__error(node, "N814") + self.__error(node, "N-814")
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Naming/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Naming/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -12,62 +12,62 @@ from PyQt6.QtCore import QCoreApplication _namingStyleMessages = { - "N801": QCoreApplication.translate( + "N-801": QCoreApplication.translate( "NamingStyleChecker", "class names should use CapWords convention" ), - "N802": QCoreApplication.translate( + "N-802": QCoreApplication.translate( "NamingStyleChecker", "function name should be lowercase" ), - "N803": QCoreApplication.translate( + "N-803": QCoreApplication.translate( "NamingStyleChecker", "argument name should be lowercase" ), - "N804": QCoreApplication.translate( + "N-804": QCoreApplication.translate( "NamingStyleChecker", "first argument of a class method should be named 'cls'" ), - "N805": QCoreApplication.translate( + "N-805": QCoreApplication.translate( "NamingStyleChecker", "first argument of a method should be named 'self'" ), - "N806": QCoreApplication.translate( + "N-806": QCoreApplication.translate( "NamingStyleChecker", "first argument of a static method should not be named 'self' or 'cls", ), - "N807": QCoreApplication.translate( + "N-807": QCoreApplication.translate( "NamingStyleChecker", "module names should be lowercase" ), - "N808": QCoreApplication.translate( + "N-808": QCoreApplication.translate( "NamingStyleChecker", "package names should be lowercase" ), - "N809": QCoreApplication.translate( + "N-809": QCoreApplication.translate( "NamingStyleChecker", "function name should not start and end with '__'" ), - "N811": QCoreApplication.translate( + "N-811": QCoreApplication.translate( "NamingStyleChecker", "constant imported as non constant" ), - "N812": QCoreApplication.translate( + "N-812": QCoreApplication.translate( "NamingStyleChecker", "lowercase imported as non lowercase" ), - "N813": QCoreApplication.translate( + "N-813": QCoreApplication.translate( "NamingStyleChecker", "camelcase imported as lowercase" ), - "N814": QCoreApplication.translate( + "N-814": QCoreApplication.translate( "NamingStyleChecker", "camelcase imported as constant" ), - "N815": QCoreApplication.translate( + "N-815": QCoreApplication.translate( "NamingStyleChecker", "camelcase imported as acronym" ), - "N818": QCoreApplication.translate( + "N-818": QCoreApplication.translate( "NamingStyleChecker", "exception name should be named with an 'Error' suffix" ), - "N821": QCoreApplication.translate( + "N-821": QCoreApplication.translate( "NamingStyleChecker", "variable in function should be lowercase" ), - "N822": QCoreApplication.translate( + "N-822": QCoreApplication.translate( "NamingStyleChecker", "variable in class scope should not be mixed case" ), - "N823": QCoreApplication.translate( + "N-823": QCoreApplication.translate( "NamingStyleChecker", "variable in global scope should not be mixed case" ), - "N831": QCoreApplication.translate( + "N-831": QCoreApplication.translate( "NamingStyleChecker", "names 'l', 'O' and 'I' should be avoided" ), }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/PathLib/PathlibChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/PathLib/PathlibChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -45,71 +45,71 @@ Codes = [ ## Replacements for the os module functions - "P101", - "P102", - "P103", - "P104", - "P105", - "P106", - "P107", - "P108", - "P109", - "P110", - "P111", - "P112", - "P113", - "P114", + "P-101", + "P-102", + "P-103", + "P-104", + "P-105", + "P-106", + "P-107", + "P-108", + "P-109", + "P-110", + "P-111", + "P-112", + "P-113", + "P-114", ## Replacements for the os.path module functions - "P201", - "P202", - "P203", - "P204", - "P205", - "P206", - "P207", - "P208", - "P209", - "P210", - "P211", - "P212", - "P213", + "P-201", + "P-202", + "P-203", + "P-204", + "P-205", + "P-206", + "P-207", + "P-208", + "P-209", + "P-210", + "P-211", + "P-212", + "P-213", ## Replacements for some Python standard library functions - "P301", + "P-301", ## Replacements for py.path.local - "P401", + "P-401", ] # map functions to be replaced to error codes Function2Code = { - "os.chmod": "P101", - "os.mkdir": "P102", - "os.makedirs": "P103", - "os.rename": "P104", - "os.replace": "P105", - "os.rmdir": "P106", - "os.remove": "P107", - "os.unlink": "P108", - "os.getcwd": "P109", - "os.readlink": "P110", - "os.stat": "P111", - "os.listdir": "P112", - "os.link": "P113", - "os.symlink": "P114", - "os.path.abspath": "P201", - "os.path.exists": "P202", - "os.path.expanduser": "P203", - "os.path.isdir": "P204", - "os.path.isfile": "P205", - "os.path.islink": "P206", - "os.path.isabs": "P207", - "os.path.join": "P208", - "os.path.basename": "P209", - "os.path.dirname": "P210", - "os.path.samefile": "P211", - "os.path.splitext": "P212", - "os.path.relpath": "P213", - "open": "P301", - "py.path.local": "P401", + "os.chmod": "P-101", + "os.mkdir": "P-102", + "os.makedirs": "P-103", + "os.rename": "P-104", + "os.replace": "P-105", + "os.rmdir": "P-106", + "os.remove": "P-107", + "os.unlink": "P-108", + "os.getcwd": "P-109", + "os.readlink": "P-110", + "os.stat": "P-111", + "os.listdir": "P-112", + "os.link": "P-113", + "os.symlink": "P-114", + "os.path.abspath": "P-201", + "os.path.exists": "P-202", + "os.path.expanduser": "P-203", + "os.path.isdir": "P-204", + "os.path.isfile": "P-205", + "os.path.islink": "P-206", + "os.path.isabs": "P-207", + "os.path.join": "P-208", + "os.path.basename": "P-209", + "os.path.dirname": "P-210", + "os.path.samefile": "P-211", + "os.path.splitext": "P-212", + "os.path.relpath": "P-213", + "open": "P-301", + "py.path.local": "P-401", } def __init__(self, source, filename, tree, selected, ignored, expected, repeat):
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/PathLib/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/PathLib/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -12,115 +12,115 @@ from PyQt6.QtCore import QCoreApplication _pathlibMessages = { - "P101": QCoreApplication.translate( + "P-101": QCoreApplication.translate( "PathlibChecker", "os.chmod('foo', 0o444) should be replaced by foo_path.chmod(0o444)", ), - "P102": QCoreApplication.translate( + "P-102": QCoreApplication.translate( "PathlibChecker", "os.mkdir('foo') should be replaced by foo_path.mkdir()" ), - "P103": QCoreApplication.translate( + "P-103": QCoreApplication.translate( "PathlibChecker", "os.makedirs('foo/bar') should be replaced by bar_path.mkdir(parents=True)", ), - "P104": QCoreApplication.translate( + "P-104": QCoreApplication.translate( "PathlibChecker", "os.rename('foo', 'bar') should be replaced by foo_path.rename(Path('bar'))", ), - "P105": QCoreApplication.translate( + "P-105": QCoreApplication.translate( "PathlibChecker", "os.replace('foo', 'bar') should be replaced by " "foo_path.replace(Path('bar'))", ), - "P106": QCoreApplication.translate( + "P-106": QCoreApplication.translate( "PathlibChecker", "os.rmdir('foo') should be replaced by foo_path.rmdir()" ), - "P107": QCoreApplication.translate( + "P-107": QCoreApplication.translate( "PathlibChecker", "os.remove('foo') should be replaced by foo_path.unlink()" ), - "P108": QCoreApplication.translate( + "P-108": QCoreApplication.translate( "PathlibChecker", "os.unlink('foo'') should be replaced by foo_path.unlink()" ), - "P109": QCoreApplication.translate( + "P-109": QCoreApplication.translate( "PathlibChecker", "os.getcwd() should be replaced by Path.cwd()" ), - "P110": QCoreApplication.translate( + "P-110": QCoreApplication.translate( "PathlibChecker", "os.readlink('foo') should be replaced by foo_path.readlink()" ), - "P111": QCoreApplication.translate( + "P-111": QCoreApplication.translate( "PathlibChecker", "os.stat('foo') should be replaced by foo_path.stat() or " "foo_path.owner() or foo_path.group()", ), - "P112": QCoreApplication.translate( + "P-112": QCoreApplication.translate( "PathlibChecker", "os.listdir(path='foo') should be replaced by foo_path.iterdir()", ), - "P113": QCoreApplication.translate( + "P-113": QCoreApplication.translate( "PathlibChecker", "os.link('bar', 'foo') should be replaced by foo_path.hardlink_to('bar')", ), - "P114": QCoreApplication.translate( + "P-114": QCoreApplication.translate( "PathlibChecker", "os.symlink('bar', 'foo') should be replaced by foo_path.symlink_to('bar')", ), - "P201": QCoreApplication.translate( + "P-201": QCoreApplication.translate( "PathlibChecker", "os.path.abspath('foo') should be replaced by foo_path.resolve()", ), - "P202": QCoreApplication.translate( + "P-202": QCoreApplication.translate( "PathlibChecker", "os.path.exists('foo') should be replaced by foo_path.exists()", ), - "P203": QCoreApplication.translate( + "P-203": QCoreApplication.translate( "PathlibChecker", "os.path.expanduser('~/foo') should be replaced by foo_path.expanduser()", ), - "P204": QCoreApplication.translate( + "P-204": QCoreApplication.translate( "PathlibChecker", "os.path.isdir('foo') should be replaced by foo_path.is_dir()" ), - "P205": QCoreApplication.translate( + "P-205": QCoreApplication.translate( "PathlibChecker", "os.path.isfile('foo') should be replaced by foo_path.is_file()", ), - "P206": QCoreApplication.translate( + "P-206": QCoreApplication.translate( "PathlibChecker", "os.path.islink('foo') should be replaced by foo_path.is_symlink()", ), - "P207": QCoreApplication.translate( + "P-207": QCoreApplication.translate( "PathlibChecker", "os.path.isabs('foo') should be replaced by foo_path.is_absolute()", ), - "P208": QCoreApplication.translate( + "P-208": QCoreApplication.translate( "PathlibChecker", "os.path.join('foo', 'bar') should be replaced by foo_path / 'bar'", ), - "P209": QCoreApplication.translate( + "P-209": QCoreApplication.translate( "PathlibChecker", "os.path.basename('foo/bar') should be replaced by bar_path.name", ), - "P210": QCoreApplication.translate( + "P-210": QCoreApplication.translate( "PathlibChecker", "os.path.dirname('foo/bar') should be replaced by bar_path.parent", ), - "P211": QCoreApplication.translate( + "P-211": QCoreApplication.translate( "PathlibChecker", "os.path.samefile('foo', 'bar') should be replaced by " "foo_path.samefile(bar_path)", ), - "P212": QCoreApplication.translate( + "P-212": QCoreApplication.translate( "PathlibChecker", "os.path.splitext('foo.bar') should be replaced by foo_path.suffix", ), - "P213": QCoreApplication.translate( + "P-213": QCoreApplication.translate( "PathlibChecker", "os.path.relpath('/bar/foo', start='bar') should be replaced by " "foo_path.relative_to('/bar')", ), - "P301": QCoreApplication.translate( + "P-301": QCoreApplication.translate( "PathlibChecker", "open('foo') should be replaced by Path('foo').open()" ), - "P401": QCoreApplication.translate( + "P-401": QCoreApplication.translate( "PathlibChecker", "py.path.local is in maintenance mode, use pathlib instead" ), }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/assert.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/assert.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Assert": [ - (checkAssertUsed, ("S101",)), + (checkAssertUsed, ("S-101",)), ], } @@ -42,4 +42,4 @@ @param _config dictionary with configuration data (unused) @type dict """ - reportError(context.node.lineno - 1, context.node.col_offset, "S101", "L", "H") + reportError(context.node.lineno - 1, context.node.col_offset, "S-101", "L", "H")
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/awsHardcodedPassword.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/awsHardcodedPassword.py Mon Feb 24 15:11:18 2025 +0100 @@ -33,7 +33,7 @@ """ return { "Str": [ - (checkHardcodedAwsKey, ("S801", "S802")), + (checkHardcodedAwsKey, ("S-801", "S-802")), ], } @@ -90,7 +90,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S801", + "S-801", "L", "M", node.value, @@ -102,7 +102,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S802", + "S-802", "M", "M", node.value,
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/certificateValidation.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/certificateValidation.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkNoCertificateValidation, ("S501",)), + (checkNoCertificateValidation, ("S-501",)), ], } @@ -52,7 +52,7 @@ reportError( context.getLinenoForCallArg("verify") - 1, context.getOffsetForCallArg("verify"), - "S501", + "S-501", "H", "H", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoSqlInjection.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoSqlInjection.py Mon Feb 24 15:11:18 2025 +0100 @@ -30,8 +30,8 @@ """ return { "Call": [ - (checkDjangoExtraUsed, ("S610",)), - (checkDjangoRawSqlUsed, ("S611",)), + (checkDjangoExtraUsed, ("S-610",)), + (checkDjangoRawSqlUsed, ("S-611",)), ], } @@ -106,7 +106,7 @@ if insecure: reportError( - context.node.lineno - 1, context.node.col_offset, "S610", "M", "M" + context.node.lineno - 1, context.node.col_offset, "S-610", "M", "M" ) @@ -132,5 +132,5 @@ sql = kwargs["sql"] if not AstUtilities.isString(sql): reportError( - context.node.lineno - 1, context.node.col_offset, "S611", "M", "M" + context.node.lineno - 1, context.node.col_offset, "S-611", "M", "M" )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoXssVulnerability.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoXssVulnerability.py Mon Feb 24 15:11:18 2025 +0100 @@ -30,7 +30,7 @@ """ return { "Call": [ - (checkDjangoXssVulnerability, ("S703",)), + (checkDjangoXssVulnerability, ("S-703",)), ], } @@ -104,7 +104,7 @@ secure = evaluateCall(newCall, parent) if not secure: - reportError(node.lineno - 1, node.col_offset, "S703", "M", "H") + reportError(node.lineno - 1, node.col_offset, "S-703", "M", "H") class DeepAssignation:
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/exec.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/exec.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkExecUsed, ("S102",)), + (checkExecUsed, ("S-102",)), ], } @@ -43,4 +43,4 @@ @type dict """ if context.callFunctionNameQual == "exec": - reportError(context.node.lineno - 1, context.node.col_offset, "S102", "M", "H") + reportError(context.node.lineno - 1, context.node.col_offset, "S-102", "M", "H")
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/flaskDebug.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/flaskDebug.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkFlaskDebug, ("S201",)), + (checkFlaskDebug, ("S-201",)), ], } @@ -47,4 +47,4 @@ and context.callFunctionNameQual.endswith(".run") and context.checkCallArgValue("debug", "True") ): - reportError(context.node.lineno - 1, context.node.col_offset, "S201", "L", "M") + reportError(context.node.lineno - 1, context.node.col_offset, "S-201", "L", "M")
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalBindAllInterfaces.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalBindAllInterfaces.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Str": [ - (checkBindAllInterfaces, ("S104",)), + (checkBindAllInterfaces, ("S-104",)), ], } @@ -46,7 +46,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S104", + "S-104", "M", "M", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalFilePermissions.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalFilePermissions.py Mon Feb 24 15:11:18 2025 +0100 @@ -28,7 +28,7 @@ """ return { "Call": [ - (checkFilePermissions, ("S102",)), + (checkFilePermissions, ("S-102",)), ], } @@ -78,7 +78,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S103", + "S-103", severity, "H", oct(mode),
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py Mon Feb 24 15:11:18 2025 +0100 @@ -34,13 +34,13 @@ """ return { "Str": [ - (checkHardcodedPasswordAsString, ("S105",)), + (checkHardcodedPasswordAsString, ("S-105",)), ], "Call": [ - (checkHardcodedPasswordAsFunctionArg, ("S106",)), + (checkHardcodedPasswordAsFunctionArg, ("S-106",)), ], "FunctionDef": [ - (checkHardcodedPasswordAsDefault, ("S107",)), + (checkHardcodedPasswordAsDefault, ("S-107",)), ], } @@ -64,7 +64,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S105", + "S-105", "L", "M", node.value, @@ -80,7 +80,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S105", + "S-105", "L", "M", assign.value.value, @@ -97,7 +97,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S105", + "S-105", "L", "M", comp.comparators[0].s, @@ -121,7 +121,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S106", + "S-106", "L", "M", kw.value.value, @@ -155,7 +155,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S107", + "S-107", "L", "M", val.value,
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedTmp.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedTmp.py Mon Feb 24 15:11:18 2025 +0100 @@ -28,7 +28,7 @@ """ return { "Str": [ - (checkHardcodedTmpDirectory, ("S108",)), + (checkHardcodedTmpDirectory, ("S-108",)), ], } @@ -54,7 +54,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S108", + "S-108", "M", "M", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/hashlibInsecureFunctions.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/hashlibInsecureFunctions.py Mon Feb 24 15:11:18 2025 +0100 @@ -29,7 +29,7 @@ """ return { "Call": [ - (checkHashlib, ("S331", "S332")), + (checkHashlib, ("S-331", "S-332")), ], } @@ -62,7 +62,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S332", + "S-332", "H", "H", func.upper(), @@ -78,7 +78,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S332", + "S-332", "H", "H", name.upper(), @@ -114,7 +114,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S331", + "S-331", "M", "H", name.upper(), @@ -126,7 +126,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S331", + "S-331", "M", "H", name.upper(),
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionParamiko.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionParamiko.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkParamikoCalls, ("S601",)), + (checkParamikoCalls, ("S-601",)), ], } @@ -49,7 +49,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S601", + "S-601", "M", "M", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionShell.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionShell.py Mon Feb 24 15:11:18 2025 +0100 @@ -37,12 +37,12 @@ """ return { "Call": [ - (checkSubprocessPopenWithShell, ("S602",)), - (checkSubprocessPopenWithoutShell, ("S603",)), - (checkOtherFunctionWithShell, ("S604",)), - (checkStartProcessWithShell, ("S605",)), - (checkStartProcessWithNoShell, ("S606",)), - (checkStartProcessWithPartialPath, ("S607",)), + (checkSubprocessPopenWithShell, ("S-602",)), + (checkSubprocessPopenWithoutShell, ("S-603",)), + (checkOtherFunctionWithShell, ("S-604",)), + (checkStartProcessWithShell, ("S-605",)), + (checkStartProcessWithNoShell, ("S-606",)), + (checkStartProcessWithPartialPath, ("S-607",)), ], } @@ -122,7 +122,7 @@ reportError( context.getLinenoForCallArg("shell") - 1, context.getOffsetForCallArg("shell"), - "S602.L", + "S-602.L", sev, "H", ) @@ -130,7 +130,7 @@ reportError( context.getLinenoForCallArg("shell") - 1, context.getOffsetForCallArg("shell"), - "S602.H", + "S-602.H", sev, "H", ) @@ -157,7 +157,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S603", + "S-603", "L", "H", ) @@ -184,7 +184,7 @@ reportError( context.getLinenoForCallArg("shell") - 1, context.getOffsetForCallArg("shell"), - "S604", + "S-604", "M", "L", ) @@ -213,7 +213,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S605.L", + "S-605.L", sev, "H", ) @@ -221,7 +221,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S605.H", + "S-605.H", sev, "H", ) @@ -248,7 +248,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S606", + "S-606", "L", "M", ) @@ -293,7 +293,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S607", + "S-607", "L", "H", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionSql.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionSql.py Mon Feb 24 15:11:18 2025 +0100 @@ -31,7 +31,7 @@ """ return { "Str": [ - (checkHardcodedSqlExpressions, ("S608",)), + (checkHardcodedSqlExpressions, ("S-608",)), ], } @@ -121,7 +121,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S608", + "S-608", "M", "M" if executeCall and not strReplace else "L", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionWildcard.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionWildcard.py Mon Feb 24 15:11:18 2025 +0100 @@ -28,7 +28,7 @@ """ return { "Call": [ - (checkLinuxCommandsWildcardInjection, ("S609",)), + (checkLinuxCommandsWildcardInjection, ("S-609",)), ], } @@ -84,7 +84,7 @@ reportError( lineNo - 1, offset, - "S609", + "S-609", "H", "M", context.callFunctionNameQual,
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/insecureSslTls.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/insecureSslTls.py Mon Feb 24 15:11:18 2025 +0100 @@ -28,11 +28,11 @@ """ return { "Call": [ - (checkInsecureSslProtocolVersion, ("S502",)), - (checkSslWithoutVersion, ("S504",)), + (checkInsecureSslProtocolVersion, ("S-502",)), + (checkSslWithoutVersion, ("S-504",)), ], "FunctionDef": [ - (checkInsecureSslDefaults, ("S503",)), + (checkInsecureSslDefaults, ("S-503",)), ], } @@ -59,7 +59,7 @@ reportError( context.getLinenoForCallArg("ssl_version") - 1, context.getOffsetForCallArg("ssl_version"), - "S502.1", + "S-502.1", "H", "H", ) @@ -69,7 +69,7 @@ reportError( context.getLinenoForCallArg("method") - 1, context.getOffsetForCallArg("method"), - "S502.2", + "S-502.2", "H", "H", ) @@ -82,7 +82,7 @@ reportError( context.getLinenoForCallArg("method") - 1, context.getOffsetForCallArg("method"), - "S502.3", + "S-502.3", "H", "H", ) @@ -91,7 +91,7 @@ reportError( context.getLinenoForCallArg("ssl_version") - 1, context.getOffsetForCallArg("ssl_version"), - "S502.3", + "S-502.3", "H", "H", ) @@ -120,7 +120,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S503", + "S-503", "M", "M", ) @@ -148,7 +148,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S504", + "S-504", "L", "M", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/jinja2Templates.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/jinja2Templates.py Mon Feb 24 15:11:18 2025 +0100 @@ -28,7 +28,7 @@ """ return { "Call": [ - (checkJinja2Autoescape, ("S701",)), + (checkJinja2Autoescape, ("S-701",)), ], } @@ -58,7 +58,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S701.1", + "S-701.1", "H", "H", ) @@ -86,7 +86,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S701.1", + "S-701.1", "H", "M", ) @@ -97,7 +97,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S701.2", + "S-701.2", "H", "H", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/loggingConfigInsecureListen.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/loggingConfigInsecureListen.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkLoggingConfigListen, ("S612",)), + (checkLoggingConfigListen, ("S-612",)), ], } @@ -46,4 +46,4 @@ context.callFunctionNameQual == "logging.config.listen" and "verify" not in context.callKeywords ): - reportError(context.node.lineno - 1, context.node.col_offset, "S612", "M", "H") + reportError(context.node.lineno - 1, context.node.col_offset, "S-612", "M", "H")
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/makoTemplates.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/makoTemplates.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkMakoTemplateUsage, ("S702",)), + (checkMakoTemplateUsage, ("S-702",)), ], } @@ -51,7 +51,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S702", + "S-702", "M", "H", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/prohibitedCalls.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/prohibitedCalls.py Mon Feb 24 15:11:18 2025 +0100 @@ -21,7 +21,7 @@ import AstUtilities _prohibitedCalls = { - "S301": ( + "S-301": ( [ "pickle.loads", "pickle.load", @@ -38,8 +38,8 @@ ], "M", ), - "S302": (["marshal.load", "marshal.loads"], "M"), - "S303": ( + "S-302": (["marshal.load", "marshal.loads"], "M"), + "S-303": ( [ "Crypto.Hash.MD2.new", "Crypto.Hash.MD4.new", @@ -54,7 +54,7 @@ ], "M", ), - "S304": ( + "S-304": ( [ "Crypto.Cipher.ARC2.new", "Crypto.Cipher.ARC4.new", @@ -75,11 +75,11 @@ ], "H", ), - "S305": (["cryptography.hazmat.primitives.ciphers.modes.ECB"], "M"), - "S306": (["tempfile.mktemp"], "M"), - "S307": (["eval"], "M"), - "S308": (["django.utils.safestring.mark_safe"], "M"), - "S310": ( + "S-305": (["cryptography.hazmat.primitives.ciphers.modes.ECB"], "M"), + "S-306": (["tempfile.mktemp"], "M"), + "S-307": (["eval"], "M"), + "S-308": (["django.utils.safestring.mark_safe"], "M"), + "S-310": ( [ "urllib.request.urlopen", "urllib.request.urlretrieve", @@ -92,7 +92,7 @@ ], "", ), - "S311": ( + "S-311": ( [ "random.Random", "random.random", @@ -106,8 +106,8 @@ ], "L", ), - "S312": (["telnetlib.Telnet"], "H"), - "S313": ( + "S-312": (["telnetlib.Telnet"], "H"), + "S-313": ( [ "xml.etree.cElementTree.parse", "xml.etree.cElementTree.iterparse", @@ -116,7 +116,7 @@ ], "M", ), - "S314": ( + "S-314": ( [ "xml.etree.ElementTree.parse", "xml.etree.ElementTree.iterparse", @@ -125,16 +125,16 @@ ], "M", ), - "S315": (["xml.sax.expatreader.create_parser"], "M"), - "S316": ( + "S-315": (["xml.sax.expatreader.create_parser"], "M"), + "S-316": ( ["xml.dom.expatbuilder.parse", "xml.dom.expatbuilder.parseString"], "M", ), - "S317": (["xml.sax.parse", "xml.sax.parseString", "xml.sax.make_parser"], "M"), - "S318": (["xml.dom.minidom.parse", "xml.dom.minidom.parseString"], "M"), - "S319": (["xml.dom.pulldom.parse", "xml.dom.pulldom.parseString"], "M"), - "S321": (["ftplib.FTP"], "H"), - "S323": (["ssl._create_unverified_context"], "M"), + "S-317": (["xml.sax.parse", "xml.sax.parseString", "xml.sax.make_parser"], "M"), + "S-318": (["xml.dom.minidom.parse", "xml.dom.minidom.parseString"], "M"), + "S-319": (["xml.dom.pulldom.parse", "xml.dom.pulldom.parseString"], "M"), + "S-321": (["ftplib.FTP"], "H"), + "S-323": (["ssl._create_unverified_context"], "M"), }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/prohibitedImports.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/prohibitedImports.py Mon Feb 24 15:11:18 2025 +0100 @@ -16,17 +16,17 @@ # _prohibitedImports = { - "S401": (["telnetlib"], "H"), - "S402": (["ftplib"], "H"), - "S403": (["pickle", "cPickle", "dill", "shelve"], "L"), - "S404": (["subprocess"], "L"), - "S405": (["xml.etree.cElementTree", "xml.etree.ElementTree"], "L"), - "S406": (["xml.sax"], "L"), - "S407": (["xml.dom.expatbuilder"], "L"), - "S408": (["xml.dom.minidom"], "L"), - "S409": (["xml.dom.pulldom"], "L"), - "S411": (["xmlrpc"], "H"), - "S412": ( + "S-401": (["telnetlib"], "H"), + "S-402": (["ftplib"], "H"), + "S-403": (["pickle", "cPickle", "dill", "shelve"], "L"), + "S-404": (["subprocess"], "L"), + "S-405": (["xml.etree.cElementTree", "xml.etree.ElementTree"], "L"), + "S-406": (["xml.sax"], "L"), + "S-407": (["xml.dom.expatbuilder"], "L"), + "S-408": (["xml.dom.minidom"], "L"), + "S-409": (["xml.dom.pulldom"], "L"), + "S-411": (["xmlrpc"], "H"), + "S-412": ( [ "wsgiref.handlers.CGIHandler", "twisted.web.twcgi.CGIScript", @@ -34,7 +34,7 @@ ], "H", ), - "S413": ( + "S-413": ( [ "Crypto.Cipher", "Crypto.Hash", @@ -47,7 +47,7 @@ ], "H", ), - "S414": (["pyghmi"], "H"), + "S-414": (["pyghmi"], "H"), }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/pytorchLoadSave.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/pytorchLoadSave.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkPytorchLoadSave, ("S614",)), + (checkPytorchLoadSave, ("S-614",)), ], } @@ -63,7 +63,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S614", + "S-614", "M", "H", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/requestWithoutTimeout.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/requestWithoutTimeout.py Mon Feb 24 15:11:18 2025 +0100 @@ -24,7 +24,7 @@ """ return { "Call": [ - (checkRequestWithouTimeout, ("S114",)), + (checkRequestWithouTimeout, ("S-114",)), ], } @@ -53,7 +53,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S114.1", + "S-114.1", "M", "L", qualName, @@ -67,7 +67,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S114.2", + "S-114.2", "M", "L", qualName,
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/snmpSecurity.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/snmpSecurity.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,8 +26,8 @@ """ return { "Call": [ - (checkInsecureVersion, ("S508",)), - (checkWeakCryptography, ("S509",)), + (checkInsecureVersion, ("S-508",)), + (checkWeakCryptography, ("S-509",)), ], } @@ -52,7 +52,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S508", + "S-508", "M", "H", ) @@ -74,4 +74,4 @@ context.callFunctionNameQual == "pysnmp.hlapi.UsmUserData" and context.callArgsCount < 3 ): - reportError(context.node.lineno - 1, context.node.col_offset, "S509", "M", "H") + reportError(context.node.lineno - 1, context.node.col_offset, "S-509", "M", "H")
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/sshNoHostKeyVerification.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/sshNoHostKeyVerification.py Mon Feb 24 15:11:18 2025 +0100 @@ -28,7 +28,7 @@ """ return { "Call": [ - (checkSshNoHostKeyVerification, ("S507",)), + (checkSshNoHostKeyVerification, ("S-507",)), ], } @@ -66,7 +66,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S507", + "S-507", "H", "M", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/tarfileUnsafeMembers.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/tarfileUnsafeMembers.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkTarfileUnsafeMembers, ("S202",)), + (checkTarfileUnsafeMembers, ("S-202",)), ], } @@ -95,7 +95,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S202.1", + "S-202.1", "L", "L", str(members), @@ -104,12 +104,12 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S202.2", + "S-202.2", "M", "M", str(members), ) else: reportError( - context.node.lineno - 1, context.node.col_offset, "S202.3", "H", "H" + context.node.lineno - 1, context.node.col_offset, "S-202.3", "H", "H" )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/trojanSource.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/trojanSource.py Mon Feb 24 15:11:18 2025 +0100 @@ -29,7 +29,7 @@ """ return { "File": [ - (checkTrojanSource, ("S613",)), + (checkTrojanSource, ("S-613",)), ], } @@ -75,7 +75,7 @@ reportError( lineno, colOffset, - "S613", + "S-613", "H", "M", repr(char),
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/tryExcept.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/tryExcept.py Mon Feb 24 15:11:18 2025 +0100 @@ -30,11 +30,11 @@ """ return { "ExceptHandler": [ - (checkTryExceptPass, ("S110",)), - (checkTryExceptContinue, ("S112",)), + (checkTryExceptPass, ("S-110",)), + (checkTryExceptContinue, ("S-112",)), ], "Call": [ - (checkContextlibSuppress, ("S113",)), + (checkContextlibSuppress, ("S-113",)), ], } @@ -69,7 +69,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S110", + "S-110", "L", "H", ) @@ -105,7 +105,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S112", + "S-112", "L", "H", ) @@ -146,7 +146,7 @@ reportError( context.node.lineno - 1, context.node.col_offset, - "S113", + "S-113", "L", "H", )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/weakCryptographicKey.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/weakCryptographicKey.py Mon Feb 24 15:11:18 2025 +0100 @@ -28,7 +28,7 @@ """ return { "Call": [ - (checkWeakCryptographicKey, ("S505",)), + (checkWeakCryptographicKey, ("S-505",)), ], } @@ -81,7 +81,7 @@ for size, level in keySizes[keyType]: if keySize < size: reportError( - node.lineno - 1, node.col_offset, "S505", level, "H", keyType, size + node.lineno - 1, node.col_offset, "S-505", level, "H", keyType, size ) return True
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/yamlLoad.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/yamlLoad.py Mon Feb 24 15:11:18 2025 +0100 @@ -26,7 +26,7 @@ """ return { "Call": [ - (checkYamlLoad, ("S506",)), + (checkYamlLoad, ("S-506",)), ], } @@ -59,4 +59,4 @@ context.getCallArgAtPosition(1) != "CSafeLoader", ] ): - reportError(context.node.lineno - 1, context.node.col_offset, "S506", "M", "H") + reportError(context.node.lineno - 1, context.node.col_offset, "S-506", "M", "H")
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -21,101 +21,101 @@ Codes = [ # assert used - "S101", + "S-101", # exec used - "S102", + "S-102", # bad file permissions - "S103", + "S-103", # bind to all interfaces - "S104", + "S-104", # hardcoded passwords - "S105", - "S106", - "S107" + "S-105", + "S-106", + "S-107" # hardcoded tmp directory - "S108", + "S-108", # try-except - "S110", - "S112", + "S-110", + "S-112", # flask app - "S201", + "S-201", # insecure function calls (prohibited) - "S301", - "S302", - "S303", - "S304", - "S305", - "S306", - "S307", - "S308", - "S310", - "S311", - "S312", - "S313", - "S314", - "S315", - "S316", - "S317", - "S318", - "S319", - "S321", - "S323", + "S-301", + "S-302", + "S-303", + "S-304", + "S-305", + "S-306", + "S-307", + "S-308", + "S-310", + "S-311", + "S-312", + "S-313", + "S-314", + "S-315", + "S-316", + "S-317", + "S-318", + "S-319", + "S-321", + "S-323", # hashlib functions - "S331", - "S332" + "S-331", + "S-332" # insecure imports (prohibited) - "S401", - "S402", - "S403", - "S404", - "S405", - "S406", - "S407", - "S408", - "S409", - "S411", - "S412", - "S413", + "S-401", + "S-402", + "S-403", + "S-404", + "S-405", + "S-406", + "S-407", + "S-408", + "S-409", + "S-411", + "S-412", + "S-413", # insecure certificate usage - "S501", + "S-501", # insecure SSL/TLS protocol version - "S502", - "S503", - "S504", + "S-502", + "S-503", + "S-504", # weak cryptographic keys - "S505", + "S-505", # YAML load - "S506", + "S-506", # SSH host key verification - "S507", + "S-507", # Shell injection - "S601", - "S602", - "S603", - "S604", - "S605", - "S606", - "S607", + "S-601", + "S-602", + "S-603", + "S-604", + "S-605", + "S-606", + "S-607", # SQL injection - "S608", + "S-608", # Wildcard injection - "S609", + "S-609", # Django SQL injection - "S610", - "S611", + "S-610", + "S-611", # insecure logging.config.listen() - "S612", - "S613", - "S614", + "S-612", + "S-613", + "S-614", # Jinja2 templates - "S701", + "S-701", # Mako templates - "S702", + "S-702", # Django XSS vulnerability - "S703", + "S-703", # hardcoded AWS passwords - "S801", - "S802", + "S-801", + "S-802", ] def __init__(self, source, filename, tree, select, ignore, expected, repeat, args):
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -13,162 +13,162 @@ _securityMessages = { # assert used - "S101": QCoreApplication.translate( + "S-101": QCoreApplication.translate( "Security", "Use of 'assert' detected. The enclosed code will be removed when" " compiling to optimised byte code.", ), # exec used - "S102": QCoreApplication.translate("Security", "Use of 'exec' detected."), + "S-102": QCoreApplication.translate("Security", "Use of 'exec' detected."), # bad file permissions - "S103": QCoreApplication.translate( + "S-103": QCoreApplication.translate( "Security", "'chmod' setting a permissive mask {0} on file ({1})." ), # bind to all interfaces - "S104": QCoreApplication.translate( + "S-104": QCoreApplication.translate( "Security", "Possible binding to all interfaces." ), # hardcoded passwords - "S105": QCoreApplication.translate( + "S-105": QCoreApplication.translate( "Security", "Possible hardcoded password: '{0}'" ), - "S106": QCoreApplication.translate( + "S-106": QCoreApplication.translate( "Security", "Possible hardcoded password: '{0}'" ), - "S107": QCoreApplication.translate( + "S-107": QCoreApplication.translate( "Security", "Possible hardcoded password: '{0}'" ), # hardcoded tmp directory - "S108": QCoreApplication.translate( + "S-108": QCoreApplication.translate( "Security", "Probable insecure usage of temp file/directory." ), # try-except and contextlib.suppress - "S110": QCoreApplication.translate("Security", "Try, Except, Pass detected."), - "S112": QCoreApplication.translate("Security", "Try, Except, Continue detected."), - "S113": QCoreApplication.translate("Security", "'contextlib.suppress()' detected."), + "S-110": QCoreApplication.translate("Security", "Try, Except, Pass detected."), + "S-112": QCoreApplication.translate("Security", "Try, Except, Continue detected."), + "S-113": QCoreApplication.translate("Security", "'contextlib.suppress()' detected."), # request without timeout - "S114.1": QCoreApplication.translate("Security", "Call to {0} without timeout."), - "S114.2": QCoreApplication.translate( + "S-114.1": QCoreApplication.translate("Security", "Call to {0} without timeout."), + "S-114.2": QCoreApplication.translate( "Security", "Call to {0} with timeout set to None.", ), # flask app - "S201": QCoreApplication.translate( + "S-201": QCoreApplication.translate( "Security", "A Flask app appears to be run with debug=True, which exposes the" " Werkzeug debugger and allows the execution of arbitrary code.", ), # tarfile.extractall - "S202.1": QCoreApplication.translate( + "S-202.1": QCoreApplication.translate( "Security", "Usage of 'tarfile.extractall(members=function(tarfile))'. " "Make sure your function properly discards dangerous members ({0}).", ), - "S202.2": QCoreApplication.translate( + "S-202.2": QCoreApplication.translate( "Security", "Found 'tarfile.extractall(members=?)' but couldn't identify the type of" " members. Check if the members were properly validated ({0}).", ), - "S202.3": QCoreApplication.translate( + "S-202.3": QCoreApplication.translate( "Security", "'tarfile.extractall()' used without any validation. Please check and" " discard dangerous members.", ), # prohibited calls - "S301": QCoreApplication.translate( + "S-301": QCoreApplication.translate( "Security", "Pickle and modules that wrap it can be unsafe when used to " "deserialize untrusted data, possible security issue.", ), - "S302": QCoreApplication.translate( + "S-302": QCoreApplication.translate( "Security", "Deserialization with the marshal module is possibly dangerous." ), - "S303": QCoreApplication.translate( + "S-303": QCoreApplication.translate( "Security", "Use of insecure MD2, MD4, MD5, or SHA1 hash function." ), - "S304": QCoreApplication.translate( + "S-304": QCoreApplication.translate( "Security", "Use of insecure cipher '{0}'. Replace with a known secure cipher" " such as AES.", ), - "S305": QCoreApplication.translate( + "S-305": QCoreApplication.translate( "Security", "Use of insecure cipher mode '{0}'." ), - "S306": QCoreApplication.translate( + "S-306": QCoreApplication.translate( "Security", "Use of insecure and deprecated function (mktemp)." ), - "S307": QCoreApplication.translate( + "S-307": QCoreApplication.translate( "Security", "Use of possibly insecure function - consider using safer ast.literal_eval.", ), - "S308": QCoreApplication.translate( + "S-308": QCoreApplication.translate( "Security", "Use of mark_safe() may expose cross-site scripting vulnerabilities" " and should be reviewed.", ), - "S310": QCoreApplication.translate( + "S-310": QCoreApplication.translate( "Security", "Audit url open for permitted schemes. Allowing use of file:/ or" " custom schemes is often unexpected.", ), - "S311": QCoreApplication.translate( + "S-311": QCoreApplication.translate( "Security", "Standard pseudo-random generators are not suitable for" " security/cryptographic purposes.", ), - "S312": QCoreApplication.translate( + "S-312": QCoreApplication.translate( "Security", "Telnet-related functions are being called. Telnet is considered" " insecure. Use SSH or some other encrypted protocol.", ), - "S313": QCoreApplication.translate( + "S-313": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable to" " XML attacks. Replace '{0}' with its defusedxml equivalent function" " or make sure defusedxml.defuse_stdlib() is called.", ), - "S314": QCoreApplication.translate( + "S-314": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable to" " XML attacks. Replace '{0}' with its defusedxml equivalent function" " or make sure defusedxml.defuse_stdlib() is called.", ), - "S315": QCoreApplication.translate( + "S-315": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable to" " XML attacks. Replace '{0}' with its defusedxml equivalent function" " or make sure defusedxml.defuse_stdlib() is called.", ), - "S316": QCoreApplication.translate( + "S-316": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable to" " XML attacks. Replace '{0}' with its defusedxml equivalent function" " or make sure defusedxml.defuse_stdlib() is called.", ), - "S317": QCoreApplication.translate( + "S-317": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable to" " XML attacks. Replace '{0}' with its defusedxml equivalent function" " or make sure defusedxml.defuse_stdlib() is called.", ), - "S318": QCoreApplication.translate( + "S-318": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable to" " XML attacks. Replace '{0}' with its defusedxml equivalent function" " or make sure defusedxml.defuse_stdlib() is called.", ), - "S319": QCoreApplication.translate( + "S-319": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable to" " XML attacks. Replace '{0}' with its defusedxml equivalent function" " or make sure defusedxml.defuse_stdlib() is called.", ), - "S321": QCoreApplication.translate( + "S-321": QCoreApplication.translate( "Security", "FTP-related functions are being called. FTP is considered insecure." " Use SSH/SFTP/SCP or some other encrypted protocol.", ), - "S323": QCoreApplication.translate( + "S-323": QCoreApplication.translate( "Security", "By default, Python will create a secure, verified SSL context for" " use in such classes as HTTPSConnection. However, it still allows" @@ -177,223 +177,223 @@ " certificates or perform hostname checks.", ), # hashlib functions - "S331": QCoreApplication.translate( + "S-331": QCoreApplication.translate( "Security", "Use of insecure {0} hash function." ), - "S332": QCoreApplication.translate( + "S-332": QCoreApplication.translate( "Security", "Use of insecure {0} hash for security. Consider 'usedforsecurity=False'.", ), # prohibited imports - "S401": QCoreApplication.translate( + "S-401": QCoreApplication.translate( "Security", "A telnet-related module is being imported. Telnet is considered" " insecure. Use SSH or some other encrypted protocol.", ), - "S402": QCoreApplication.translate( + "S-402": QCoreApplication.translate( "Security", "A FTP-related module is being imported. FTP is considered" " insecure. Use SSH/SFTP/SCP or some other encrypted protocol.", ), - "S403": QCoreApplication.translate( + "S-403": QCoreApplication.translate( "Security", "Consider possible security implications associated with the '{0}' module.", ), - "S404": QCoreApplication.translate( + "S-404": QCoreApplication.translate( "Security", "Consider possible security implications associated with the '{0}' module.", ), - "S405": QCoreApplication.translate( + "S-405": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable" " to XML attacks. Replace '{0}' with the equivalent defusedxml" " package, or make sure defusedxml.defuse_stdlib() is called.", ), - "S406": QCoreApplication.translate( + "S-406": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable" " to XML attacks. Replace '{0}' with the equivalent defusedxml" " package, or make sure defusedxml.defuse_stdlib() is called.", ), - "S407": QCoreApplication.translate( + "S-407": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable" " to XML attacks. Replace '{0}' with the equivalent defusedxml" " package, or make sure defusedxml.defuse_stdlib() is called.", ), - "S408": QCoreApplication.translate( + "S-408": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable" " to XML attacks. Replace '{0}' with the equivalent defusedxml" " package, or make sure defusedxml.defuse_stdlib() is called.", ), - "S409": QCoreApplication.translate( + "S-409": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable" " to XML attacks. Replace '{0}' with the equivalent defusedxml" " package, or make sure defusedxml.defuse_stdlib() is called.", ), - "S411": QCoreApplication.translate( + "S-411": QCoreApplication.translate( "Security", "Using '{0}' to parse untrusted XML data is known to be vulnerable" " to XML attacks. Use defusedxml.xmlrpc.monkey_patch() function to" " monkey-patch xmlrpclib and mitigate XML vulnerabilities.", ), - "S412": QCoreApplication.translate( + "S-412": QCoreApplication.translate( "Security", "Consider possible security implications associated with '{0}' module.", ), - "S413": QCoreApplication.translate( + "S-413": QCoreApplication.translate( "Security", "The pyCrypto library and its module '{0}' are no longer actively" " maintained and have been deprecated. Consider using" " pyca/cryptography library.", ), - "S414": QCoreApplication.translate( + "S-414": QCoreApplication.translate( "Security", "An IPMI-related module is being imported. IPMI is considered " "insecure. Use an encrypted protocol.", ), # insecure certificate usage - "S501": QCoreApplication.translate( + "S-501": QCoreApplication.translate( "Security", "'requests' call with verify=False disabling SSL certificate checks," " security issue.", ), # insecure SSL/TLS protocol version - "S502.1": QCoreApplication.translate( + "S-502.1": QCoreApplication.translate( "Security", "'ssl.wrap_socket' call with insecure SSL/TLS protocol version" " identified, security issue.", ), - "S502.2": QCoreApplication.translate( + "S-502.2": QCoreApplication.translate( "Security", "'SSL.Context' call with insecure SSL/TLS protocol version identified," " security issue.", ), - "S502.3": QCoreApplication.translate( + "S-502.3": QCoreApplication.translate( "Security", "Function call with insecure SSL/TLS protocol version identified," " security issue.", ), - "S503": QCoreApplication.translate( + "S-503": QCoreApplication.translate( "Security", "Function definition identified with insecure SSL/TLS protocol" " version by default, possible security issue.", ), - "S504": QCoreApplication.translate( + "S-504": QCoreApplication.translate( "Security", "'ssl.wrap_socket' call with no SSL/TLS protocol version specified," " the default 'SSLv23' could be insecure, possible security issue.", ), # weak cryptographic keys - "S505": QCoreApplication.translate( + "S-505": QCoreApplication.translate( "Security", "{0} key sizes below {1:d} bits are considered breakable." ), # YAML load - "S506": QCoreApplication.translate( + "S-506": QCoreApplication.translate( "Security", "Use of unsafe 'yaml.load()'. Allows instantiation of arbitrary" " objects. Consider 'yaml.safe_load()'.", ), # SSH host key verification - "S507": QCoreApplication.translate( + "S-507": QCoreApplication.translate( "Security", "Paramiko call with policy set to automatically trust the unknown host key.", ), # insecure SNMP - "S508": QCoreApplication.translate( + "S-508": QCoreApplication.translate( "Security", "The use of SNMPv1 and SNMPv2 is insecure. You should use SNMPv3 if possible.", ), - "S509": QCoreApplication.translate( + "S-509": QCoreApplication.translate( "Security", "You should not use SNMPv3 without encryption. noAuthNoPriv & authNoPriv is" " insecure.", ), # Shell injection - "S601": QCoreApplication.translate( + "S-601": QCoreApplication.translate( "Security", "Possible shell injection via 'Paramiko' call, check inputs are" " properly sanitized.", ), - "S602.L": QCoreApplication.translate( + "S-602.L": QCoreApplication.translate( "Security", "'subprocess' call with shell=True seems safe, but may be changed" " in the future, consider rewriting without shell", ), - "S602.H": QCoreApplication.translate( + "S-602.H": QCoreApplication.translate( "Security", "'subprocess' call with shell=True identified, security issue." ), - "S603": QCoreApplication.translate( + "S-603": QCoreApplication.translate( "Security", "'subprocess' call - check for execution of untrusted input." ), - "S604": QCoreApplication.translate( + "S-604": QCoreApplication.translate( "Security", "Function call with shell=True parameter identified, possible" " security issue.", ), - "S605.L": QCoreApplication.translate( + "S-605.L": QCoreApplication.translate( "Security", "Starting a process with a shell: Seems safe, but may be changed in" " the future, consider rewriting without shell", ), - "S605.H": QCoreApplication.translate( + "S-605.H": QCoreApplication.translate( "Security", "Starting a process with a shell, possible injection detected," " security issue.", ), - "S606": QCoreApplication.translate( + "S-606": QCoreApplication.translate( "Security", "Starting a process without a shell." ), - "S607": QCoreApplication.translate( + "S-607": QCoreApplication.translate( "Security", "Starting a process with a partial executable path." ), # SQL injection - "S608": QCoreApplication.translate( + "S-608": QCoreApplication.translate( "Security", "Possible SQL injection vector through string-based query construction.", ), # Wildcard injection - "S609": QCoreApplication.translate( + "S-609": QCoreApplication.translate( "Security", "Possible wildcard injection in call: {0}" ), # Django SQL injection - "S610": QCoreApplication.translate( + "S-610": QCoreApplication.translate( "Security", "Use of 'extra()' opens a potential SQL attack vector." ), - "S611": QCoreApplication.translate( + "S-611": QCoreApplication.translate( "Security", "Use of 'RawSQL()' opens a potential SQL attack vector." ), # insecure logging.config.listen() - "S612": QCoreApplication.translate( + "S-612": QCoreApplication.translate( "Security", "Use of insecure logging.config.listen() detected.", ), # Trojan Source - "S613": QCoreApplication.translate( + "S-613": QCoreApplication.translate( "Security", "The Python source file contains bidirectional control characters ({0}).", ), # PyTorch unsafe load or save - "S614": QCoreApplication.translate( + "S-614": QCoreApplication.translate( "Security", "Use of unsafe PyTorch load or save." ), # Jinja2 templates - "S701.1": QCoreApplication.translate( + "S-701.1": QCoreApplication.translate( "Security", "Using jinja2 templates with 'autoescape=False' is dangerous and can" " lead to XSS. Use 'autoescape=True' or use the 'select_autoescape'" " function to mitigate XSS vulnerabilities.", ), - "S701.2": QCoreApplication.translate( + "S-701.2": QCoreApplication.translate( "Security", "By default, jinja2 sets 'autoescape' to False. Consider using" " 'autoescape=True' or use the 'select_autoescape' function to" " mitigate XSS vulnerabilities.", ), # Mako templates - "S702": QCoreApplication.translate( + "S-702": QCoreApplication.translate( "Security", "Mako templates allow HTML/JS rendering by default and are inherently" " open to XSS attacks. Ensure variables in all templates are properly" @@ -401,50 +401,50 @@ " example, to HTML escape the variable 'data' do ${{ data |h }}.", ), # Django XSS vulnerability - "S703": QCoreApplication.translate( + "S-703": QCoreApplication.translate( "Security", "Potential XSS on 'mark_safe()' function." ), # hardcoded AWS passwords - "S801": QCoreApplication.translate( + "S-801": QCoreApplication.translate( "Security", "Possible hardcoded AWS access key ID: {0}" ), - "S802": QCoreApplication.translate( + "S-802": QCoreApplication.translate( "Security", "Possible hardcoded AWS secret access key: {0}" ), } _securityMessagesSampleArgs = { - "S103": ["0o777", "testfile.txt"], - "S105": ["password"], - "S106": ["password"], - "S107": ["password"], - "S114.1": ["requests"], - "S114.2": ["httpx"], - "S202.1": ["members_filter(tar)"], - "S202.2": ["tar"], - "S304": ["Crypto.Cipher.DES"], - "S305": ["cryptography.hazmat.primitives.ciphers.modes.ECB"], - "S313": ["xml.etree.cElementTree.parse"], - "S314": ["xml.etree.ElementTree.parse"], - "S315": ["xml.sax.expatreader.create_parser"], - "S316": ["xml.dom.expatbuilder.parse"], - "S317": ["xml.sax.parse"], - "S318": ["xml.dom.minidom.parse"], - "S319": ["xml.dom.pulldom.parse"], - "S331": ["MD5"], - "S403": ["pickle"], - "S404": ["subprocess"], - "S405": ["xml.etree.ElementTree"], - "S406": ["xml.sax"], - "S407": ["xml.dom.expatbuilder"], - "S408": ["xml.dom.minidom"], - "S409": ["xml.dom.pulldom"], - "S411": ["xmlrpclib"], - "S412": ["wsgiref.handlers.CGIHandler"], - "S413": ["Crypto.Cipher"], - "S505": ["RSA", 2048], - "S609": ["os.system"], - "S613": [repr("\u202e")], - "S801": ["A1B2C3D4E5F6G7H8I9J0"], # secok - "S802": ["aA1bB2cC3dD4/eE5fF6gG7+hH8iI9jJ0=kKlLM+="], # secok + "S-103": ["0o777", "testfile.txt"], + "S-105": ["password"], + "S-106": ["password"], + "S-107": ["password"], + "S-114.1": ["requests"], + "S-114.2": ["httpx"], + "S-202.1": ["members_filter(tar)"], + "S-202.2": ["tar"], + "S-304": ["Crypto.Cipher.DES"], + "S-305": ["cryptography.hazmat.primitives.ciphers.modes.ECB"], + "S-313": ["xml.etree.cElementTree.parse"], + "S-314": ["xml.etree.ElementTree.parse"], + "S-315": ["xml.sax.expatreader.create_parser"], + "S-316": ["xml.dom.expatbuilder.parse"], + "S-317": ["xml.sax.parse"], + "S-318": ["xml.dom.minidom.parse"], + "S-319": ["xml.dom.pulldom.parse"], + "S-331": ["MD5"], + "S-403": ["pickle"], + "S-404": ["subprocess"], + "S-405": ["xml.etree.ElementTree"], + "S-406": ["xml.sax"], + "S-407": ["xml.dom.expatbuilder"], + "S-408": ["xml.dom.minidom"], + "S-409": ["xml.dom.pulldom"], + "S-411": ["xmlrpclib"], + "S-412": ["wsgiref.handlers.CGIHandler"], + "S-413": ["Crypto.Cipher"], + "S-505": ["RSA", 2048], + "S-609": ["os.system"], + "S-613": [repr("\u202e")], + "S-801": ["A1B2C3D4E5F6G7H8I9J0"], # secok + "S-802": ["aA1bB2cC3dD4/eE5fF6gG7+hH8iI9jJ0=kKlLM+="], # secok }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -20,64 +20,64 @@ Codes = [ # Python-specifics - "Y101", - "Y102", - "Y103", - "Y104", - "Y105", - "Y106", - "Y107", - "Y108", - "Y109", - "Y110", - "Y111", - "Y112", - "Y113", - "Y114", - "Y115", - "Y116", - "Y117", - "Y118", - "Y119", - "Y120", - "Y121", - "Y122", - "Y123", + "Y-101", + "Y-102", + "Y-103", + "Y-104", + "Y-105", + "Y-106", + "Y-107", + "Y-108", + "Y-109", + "Y-110", + "Y-111", + "Y-112", + "Y-113", + "Y-114", + "Y-115", + "Y-116", + "Y-117", + "Y-118", + "Y-119", + "Y-120", + "Y-121", + "Y-122", + "Y-123", # Python-specifics not part of flake8-simplify - "Y181", - "Y182", + "Y-181", + "Y-182", # Comparations - "Y201", - "Y202", - "Y203", - "Y204", - "Y205", - "Y206", - "Y207", - "Y208", - "Y211", - "Y212", - "Y213", - "Y221", - "Y222", - "Y223", - "Y224", + "Y-201", + "Y-202", + "Y-203", + "Y-204", + "Y-205", + "Y-206", + "Y-207", + "Y-208", + "Y-211", + "Y-212", + "Y-213", + "Y-221", + "Y-222", + "Y-223", + "Y-224", # Opinionated - "Y301", + "Y-301", # General Code Style - "Y401", - "Y402", + "Y-401", + "Y-402", # f-Strings - "Y411", + "Y-411", # Additional Checks - "Y901", - "Y904", - "Y905", - "Y906", - "Y907", - "Y909", - "Y910", - "Y911", + "Y-901", + "Y-904", + "Y-905", + "Y-906", + "Y-907", + "Y-909", + "Y-910", + "Y-911", ] def __init__(self, source, filename, tree, selected, ignored, expected, repeat):
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py Mon Feb 24 15:11:18 2025 +0100 @@ -459,7 +459,7 @@ """ if isinstance(node.op, ast.Or): for variable in self.__getDuplicatedIsinstanceCall(node): - self.__error(node.lineno - 1, node.col_offset, "Y101", variable) + self.__error(node.lineno - 1, node.col_offset, "Y-101", variable) def __check102(self, node): """ @@ -496,7 +496,7 @@ # if c: <--- # d if isPattern1: - self.__error(node.lineno - 1, node.col_offset, "Y102") + self.__error(node.lineno - 1, node.col_offset, "Y-102") def __check103(self, node): """ @@ -526,7 +526,7 @@ ) ): condition = unparse(node.test) - self.__error(node.lineno - 1, node.col_offset, "Y103", condition) + self.__error(node.lineno - 1, node.col_offset, "Y-103", condition) def __check104(self, node): """ @@ -557,7 +557,7 @@ if not isinstance(parent, ast.AsyncFunctionDef): iterable = unparse(node.iter) - self.__error(node.lineno - 1, node.col_offset, "Y104", iterable) + self.__error(node.lineno - 1, node.col_offset, "Y-104", iterable) def __check105(self, node): """ @@ -583,7 +583,7 @@ exception = ", ".join([unparse(n) for n in node.handlers[0].type.elts]) else: exception = unparse(node.handlers[0].type) - self.__error(node.lineno - 1, node.col_offset, "Y105", exception) + self.__error(node.lineno - 1, node.col_offset, "Y-105", exception) def __check106(self, node): """ @@ -609,7 +609,7 @@ and not isinstance(node.body[-1], ast.Raise) ) if just_one or many: - self.__error(node.lineno - 1, node.col_offset, "Y106") + self.__error(node.lineno - 1, node.col_offset, "Y-106") def __check107(self, node): """ @@ -648,7 +648,7 @@ break if (tryHasReturn or exceptHasReturn) and finallyHasReturn: - self.__error(finallyReturn.lineno - 1, finallyReturn.col_offset, "Y107") + self.__error(finallyReturn.lineno - 1, finallyReturn.col_offset, "Y-107") def __check108(self, node): """ @@ -700,7 +700,7 @@ orelse = unparse(node.orelse[0].value) self.__error( - node.lineno - 1, node.col_offset, "Y108", assign, body, cond, orelse + node.lineno - 1, node.col_offset, "Y-108", assign, body, cond, orelse ) def __check109(self, node): @@ -740,7 +740,7 @@ self.__error( node.lineno - 1, node.col_offset, - "Y109", + "Y-109", value, unparse(ast.Tuple(elts=values)), unparse(node), @@ -776,7 +776,7 @@ iterable = unparse(node.iter) if node.body[0].body[0].value.value is True: self.__error( - node.lineno - 1, node.col_offset, "Y110", check, target, iterable + node.lineno - 1, node.col_offset, "Y-110", check, target, iterable ) elif node.body[0].body[0].value.value is False: isCompoundExpression = " and " in check or " or " in check @@ -789,7 +789,7 @@ else: check = f"not {check}" self.__error( - node.lineno - 1, node.col_offset, "Y111", check, target, iterable + node.lineno - 1, node.col_offset, "Y-111", check, target, iterable ) def __check112(self, node): @@ -862,7 +862,7 @@ else: return - self.__error(node.lineno - 1, node.col_offset, "Y112", expected, original) + self.__error(node.lineno - 1, node.col_offset, "Y-112", expected, original) def __check113(self, node): """ @@ -911,7 +911,7 @@ for match in matches: variable = unparse(match) - self.__error(match.lineno - 1, match.col_offset, "Y113", variable) + self.__error(match.lineno - 1, match.col_offset, "Y-113", variable) def __check114(self, node): """ @@ -937,7 +937,7 @@ self.__error( ifbody1[0].lineno - 1, ifbody1[0].col_offset, - "Y114", + "Y-114", unparse(ifbody1[0]), unparse(ifbody2[0]), ) @@ -958,7 +958,7 @@ and node.func.id == "open" and not isinstance(node.parent, ast.withitem) ): - self.__error(node.lineno - 1, node.col_offset, "Y115") + self.__error(node.lineno - 1, node.col_offset, "Y-115") def __check116(self, node): """ @@ -1054,7 +1054,7 @@ else: ret = f"{keyValuePairs}.get({variable.id})" - self.__error(node.lineno - 1, node.col_offset, "Y116", ret) + self.__error(node.lineno - 1, node.col_offset, "Y-116", ret) def __check117(self, node): """ @@ -1071,7 +1071,7 @@ for withitem in node.items + node.body[0].items: withItems.append(f"{unparse(withitem)}") mergedWith = f"with {', '.join(withItems)}:" - self.__error(node.lineno - 1, node.col_offset, "Y117", mergedWith) + self.__error(node.lineno - 1, node.col_offset, "Y-117", mergedWith) def __check118(self, node): """ @@ -1115,7 +1115,7 @@ else: keyStr = unparse(node.target) dictStr = unparse(attrNode.value) - self.__error(node.lineno - 1, node.col_offset, "Y118", keyStr, dictStr) + self.__error(node.lineno - 1, node.col_offset, "Y-118", keyStr, dictStr) def __check119(self, node): """ @@ -1145,7 +1145,7 @@ hasOnlyConstructorMethod and sum(1 for el in node.body if isinstance(el, ast.FunctionDef)) > 0 ): - self.__error(node.lineno - 1, node.col_offset, "Y119", node.name) + self.__error(node.lineno - 1, node.col_offset, "Y-119", node.name) def __check120_121(self, node): """ @@ -1161,7 +1161,7 @@ and isinstance(node.bases[0], ast.Name) and node.bases[0].id == "object" ): - self.__error(node.lineno - 1, node.col_offset, "Y120", node.name) + self.__error(node.lineno - 1, node.col_offset, "Y-120", node.name) elif ( len(node.bases) > 1 @@ -1171,7 +1171,7 @@ self.__error( node.lineno - 1, node.col_offset, - "Y121", + "Y-121", node.name, ", ".join(b.id for b in node.bases[:-1]), ) @@ -1204,7 +1204,7 @@ ): key = unparse(node.test.left) dictname = unparse(node.test.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y122", dictname, key) + self.__error(node.lineno - 1, node.col_offset, "Y-122", dictname, key) def __check123(self, node): """ @@ -1269,7 +1269,7 @@ self.__error( node.lineno - 1, node.col_offset, - "Y123", + "Y-123", valueStr, dictStr, keyStr, @@ -1297,7 +1297,7 @@ self.__error( node.lineno - 1, node.col_offset, - "Y181", + "Y-181", unparse(newNode), unparse(node), ) @@ -1320,7 +1320,7 @@ and node.args[0].id == self.__classDefinitionStack[-1] and node.args[1].id == "self" ): - self.__error(node.lineno - 1, node.col_offset, "Y182", unparse(node)) + self.__error(node.lineno - 1, node.col_offset, "Y-182", unparse(node)) def __check201(self, node): """ @@ -1344,7 +1344,7 @@ comparison = node.operand left = unparse(comparison.left) right = unparse(comparison.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y201", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-201", left, right) def __check202(self, node): """ @@ -1368,7 +1368,7 @@ comparison = node.operand left = unparse(comparison.left) right = unparse(comparison.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y202", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-202", left, right) def __check203(self, node): """ @@ -1392,7 +1392,7 @@ comparison = node.operand left = unparse(comparison.left) right = unparse(comparison.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y203", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-203", left, right) def __check204(self, node): """ @@ -1415,7 +1415,7 @@ comparison = node.operand left = unparse(comparison.left) right = unparse(comparison.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y204", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-204", left, right) def __check205(self, node): """ @@ -1438,7 +1438,7 @@ comparison = node.operand left = unparse(comparison.left) right = unparse(comparison.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y205", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-205", left, right) def __check206(self, node): """ @@ -1461,7 +1461,7 @@ comparison = node.operand left = unparse(comparison.left) right = unparse(comparison.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y206", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-206", left, right) def __check207(self, node): """ @@ -1484,7 +1484,7 @@ comparison = node.operand left = unparse(comparison.left) right = unparse(comparison.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y207", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-207", left, right) def __check208(self, node): """ @@ -1500,7 +1500,7 @@ and isinstance(node.operand.op, ast.Not) ): var = unparse(node.operand.operand) - self.__error(node.lineno - 1, node.col_offset, "Y208", var) + self.__error(node.lineno - 1, node.col_offset, "Y-208", var) def __check211(self, node): """ @@ -1521,7 +1521,7 @@ newCond = "bool({0})".format(cond) else: newCond = cond - self.__error(node.lineno - 1, node.col_offset, "Y211", cond, newCond) + self.__error(node.lineno - 1, node.col_offset, "Y-211", cond, newCond) def __check212(self, node): """ @@ -1545,7 +1545,7 @@ newCond = unparse(self.__negateTest(node.test)) else: newCond = "not ({0})".format(cond) - self.__error(node.lineno - 1, node.col_offset, "Y212", cond, newCond) + self.__error(node.lineno - 1, node.col_offset, "Y-212", cond, newCond) def __check213(self, node): """ @@ -1562,7 +1562,7 @@ ): a = unparse(node.test.operand) b = unparse(node.body) - self.__error(node.lineno - 1, node.col_offset, "Y213", a, b) + self.__error(node.lineno - 1, node.col_offset, "Y-213", a, b) def __check221(self, node): """ @@ -1586,7 +1586,7 @@ for nonNegatedExpression in nonNegatedExpressions: if self.__isSameExpression(negatedExpression, nonNegatedExpression): negExp = unparse(negatedExpression) - self.__error(node.lineno - 1, node.col_offset, "Y221", negExp) + self.__error(node.lineno - 1, node.col_offset, "Y-221", negExp) def __check222(self, node): """ @@ -1610,7 +1610,7 @@ for nonNegatedExpression in nonNegatedExpressions: if self.__isSameExpression(negatedExpression, nonNegatedExpression): negExp = unparse(negatedExpression) - self.__error(node.lineno - 1, node.col_offset, "Y222", negExp) + self.__error(node.lineno - 1, node.col_offset, "Y-222", negExp) def __check223(self, node): """ @@ -1623,7 +1623,7 @@ if isinstance(node.op, ast.Or): for exp in node.values: if isinstance(exp, ast.Constant) and exp.value is True: - self.__error(node.lineno - 1, node.col_offset, "Y223") + self.__error(node.lineno - 1, node.col_offset, "Y-223") def __check224(self, node): """ @@ -1636,7 +1636,7 @@ if isinstance(node.op, ast.And): for exp in node.values: if isinstance(exp, ast.Constant) and exp.value is False: - self.__error(node.lineno - 1, node.col_offset, "Y224") + self.__error(node.lineno - 1, node.col_offset, "Y-224") def __check301(self, node): """ @@ -1658,7 +1658,7 @@ if isStr: left = f"'{left}'" right = unparse(node.comparators[0]) - self.__error(node.lineno - 1, node.col_offset, "Y301", left, right) + self.__error(node.lineno - 1, node.col_offset, "Y-301", left, right) def __check401(self, node): """ @@ -1677,7 +1677,7 @@ isException = isinstance(node.func, ast.Attribute) and node.func.attr in ["get"] if hasBareBool and not isException: - self.__error(node.lineno - 1, node.col_offset, "Y401") + self.__error(node.lineno - 1, node.col_offset, "Y-401") def __check402(self, node): """ @@ -1698,7 +1698,7 @@ ) if hasBareNumeric and not isException: - self.__error(node.lineno - 1, node.col_offset, "Y402") + self.__error(node.lineno - 1, node.col_offset, "Y-402") def __check411(self, node): """ @@ -1715,7 +1715,7 @@ self.__check411(innerNode) if fieldName == "value" and isinstance(value, ast.JoinedStr): - self.__error(node.lineno - 1, node.col_offset, "Y411") + self.__error(node.lineno - 1, node.col_offset, "Y-411") def __check901(self, node): """ @@ -1732,7 +1732,7 @@ ): actual = unparse(node) expected = unparse(node.args[0]) - self.__error(node.lineno - 1, node.col_offset, "Y901", expected, actual) + self.__error(node.lineno - 1, node.col_offset, "Y-901", expected, actual) def __check904(self, node): """ @@ -1755,7 +1755,7 @@ ): dictName = unparse(node.targets[0]) if not self.__expressionUsesVariable(n2.value, dictName): - self.__error(node.lineno - 1, node.col_offset, "Y904", dictName) + self.__error(node.lineno - 1, node.col_offset, "Y-904", dictName) def __check905(self, node): """ @@ -1773,7 +1773,7 @@ expected = json.dumps(value.split()) actual = unparse(node.func.value) + ".split()" - self.__error(node.lineno - 1, node.col_offset, "Y905", expected, actual) + self.__error(node.lineno - 1, node.col_offset, "Y-905", expected, actual) def __check906(self, node): """ @@ -1827,7 +1827,7 @@ actual = unparse(node) expected = "os.path.join({0})".format(", ".join(names)) - self.__error(node.lineno - 1, node.col_offset, "Y906", expected, actual) + self.__error(node.lineno - 1, node.col_offset, "Y-906", expected, actual) def __check907(self, node): """ @@ -1859,7 +1859,7 @@ if len(others) == 1 and hasNone: type_ = unparse(others[0]) self.__error( - node.lineno - 1, node.col_offset, "Y907", type_, unparse(node) + node.lineno - 1, node.col_offset, "Y-907", type_, unparse(node) ) def __check909(self, node): @@ -1877,7 +1877,7 @@ if len(names) != len(set(names)) and not isinstance(node.parent, ast.ClassDef): srccode = unparse(node) - self.__error(node.lineno - 1, node.col_offset, "Y909", srccode) + self.__error(node.lineno - 1, node.col_offset, "Y-909", srccode) def __check910(self, node): """ @@ -1905,7 +1905,7 @@ func = unparse(node.func) key = unparse(node.args[0]) expected = f"{func}({key})" - self.__error(node.lineno - 1, node.col_offset, "Y910", expected, actual) + self.__error(node.lineno - 1, node.col_offset, "Y-910", expected, actual) def __check911(self, node): """ @@ -1932,7 +1932,7 @@ and firstArg.func.value.id == secondArg.func.value.id ): self.__error( - node.lineno - 1, node.col_offset, "Y911", firstArg.func.value.id + node.lineno - 1, node.col_offset, "Y-911", firstArg.func.value.id )
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -13,172 +13,172 @@ _simplifyMessages = { # Python-specifics - "Y101": QCoreApplication.translate( + "Y-101": QCoreApplication.translate( "SimplifyChecker", """Multiple "isinstance()" calls which can be merged into a single """ '''call for variable "{0}"''', ), - "Y102": QCoreApplication.translate( + "Y-102": QCoreApplication.translate( "SimplifyChecker", """Use a single if-statement instead of nested if-statements""", ), - "Y103": QCoreApplication.translate( + "Y-103": QCoreApplication.translate( "SimplifyChecker", """Return the condition "{0}" directly""" ), - "Y104": QCoreApplication.translate("SimplifyChecker", '''Use "yield from {0}"'''), - "Y105": QCoreApplication.translate( + "Y-104": QCoreApplication.translate("SimplifyChecker", '''Use "yield from {0}"'''), + "Y-105": QCoreApplication.translate( "SimplifyChecker", '''Use "with contextlib.suppress({0}):"''' ), - "Y106": QCoreApplication.translate( + "Y-106": QCoreApplication.translate( "SimplifyChecker", """Handle error-cases first""" ), - "Y107": QCoreApplication.translate( + "Y-107": QCoreApplication.translate( "SimplifyChecker", """Don't use return in try/except and finally""" ), - "Y108": QCoreApplication.translate( + "Y-108": QCoreApplication.translate( "SimplifyChecker", """Use ternary operator "{0} = {1} if {2} else {3}" """ """instead of if-else-block""", ), - "Y109": QCoreApplication.translate( + "Y-109": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} in {1}" instead of "{2}"''' ), - "Y110": QCoreApplication.translate( + "Y-110": QCoreApplication.translate( "SimplifyChecker", '''Use "any({0} for {1} in {2})"''' ), - "Y111": QCoreApplication.translate( + "Y-111": QCoreApplication.translate( "SimplifyChecker", '''Use "all({0} for {1} in {2})"''' ), - "Y112": QCoreApplication.translate( + "Y-112": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}" instead of "{1}"''' ), - "Y113": QCoreApplication.translate( + "Y-113": QCoreApplication.translate( "SimplifyChecker", '''Use enumerate instead of "{0}"''' ), - "Y114": QCoreApplication.translate( + "Y-114": QCoreApplication.translate( "SimplifyChecker", """Use logical or ("({0}) or ({1})") and a single body""" ), - "Y115": QCoreApplication.translate( + "Y-115": QCoreApplication.translate( "SimplifyChecker", """Use context handler for opening files""" ), - "Y116": QCoreApplication.translate( + "Y-116": QCoreApplication.translate( "SimplifyChecker", """Use a dictionary lookup instead of 3+ if/elif-statements: """ """return {0}""", ), - "Y117": QCoreApplication.translate( + "Y-117": QCoreApplication.translate( "SimplifyChecker", """Use "{0}" instead of multiple with statements""" ), - "Y118": QCoreApplication.translate( + "Y-118": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} in {1}" instead of "{0} in {1}.keys()"''' ), - "Y119": QCoreApplication.translate( + "Y-119": QCoreApplication.translate( "SimplifyChecker", '''Use a dataclass for "class {0}"''' ), - "Y120": QCoreApplication.translate( + "Y-120": QCoreApplication.translate( "SimplifyChecker", '''Use "class {0}:" instead of "class {0}(object):"''' ), - "Y121": QCoreApplication.translate( + "Y-121": QCoreApplication.translate( "SimplifyChecker", '''Use "class {0}({1}):" instead of "class {0}({1}, object):"''', ), - "Y122": QCoreApplication.translate( + "Y-122": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}.get({1})" instead of "if {1} in {0}: {0}[{1}]"''' ), - "Y123": QCoreApplication.translate( + "Y-123": QCoreApplication.translate( "SimplifyChecker", """Use "{0} = {1}.get({2}, {3})" instead of an if-block""" ), # Python-specifics not part of flake8-simplify - "Y181": QCoreApplication.translate( + "Y-181": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}" instead of "{1}"''' ), - "Y182": QCoreApplication.translate( + "Y-182": QCoreApplication.translate( "SimplifyChecker", '''Use "super()" instead of "{0}"''' ), # Comparations - "Y201": QCoreApplication.translate( + "Y-201": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} != {1}" instead of "not {0} == {1}"''' ), - "Y202": QCoreApplication.translate( + "Y-202": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} == {1}" instead of "not {0} != {1}"''' ), - "Y203": QCoreApplication.translate( + "Y-203": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} not in {1}" instead of "not {0} in {1}"''' ), - "Y204": QCoreApplication.translate( + "Y-204": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} >= {1}" instead of "not ({0} < {1})"''' ), - "Y205": QCoreApplication.translate( + "Y-205": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} > {1}" instead of "not ({0} <= {1})"''' ), - "Y206": QCoreApplication.translate( + "Y-206": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} <= {1}" instead of "not ({0} > {1})"''' ), - "Y207": QCoreApplication.translate( + "Y-207": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} < {1}" instead of "not ({0} >= {1})"''' ), - "Y208": QCoreApplication.translate( + "Y-208": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}" instead of "not (not {0})"''' ), - "Y211": QCoreApplication.translate( + "Y-211": QCoreApplication.translate( "SimplifyChecker", '''Use "{1}" instead of "True if {0} else False"''' ), - "Y212": QCoreApplication.translate( + "Y-212": QCoreApplication.translate( "SimplifyChecker", '''Use "{1}" instead of "False if {0} else True"''' ), - "Y213": QCoreApplication.translate( + "Y-213": QCoreApplication.translate( "SimplifyChecker", '''Use "{0} if {0} else {1}" instead of "{1} if not {0} else {0}"''', ), - "Y221": QCoreApplication.translate( + "Y-221": QCoreApplication.translate( "SimplifyChecker", '''Use "False" instead of "{0} and not {0}"''' ), - "Y222": QCoreApplication.translate( + "Y-222": QCoreApplication.translate( "SimplifyChecker", '''Use "True" instead of "{0} or not {0}"''' ), - "Y223": QCoreApplication.translate( + "Y-223": QCoreApplication.translate( "SimplifyChecker", '''Use "True" instead of "... or True"''' ), - "Y224": QCoreApplication.translate( + "Y-224": QCoreApplication.translate( "SimplifyChecker", '''Use "False" instead of "... and False"''' ), # Opinionated - "Y301": QCoreApplication.translate( + "Y-301": QCoreApplication.translate( "SimplifyChecker", """Use "{1} == {0}" instead of "{0} == {1}" (Yoda-condition)""", ), # General Code Style - "Y401": QCoreApplication.translate( + "Y-401": QCoreApplication.translate( "SimplifyChecker", """Use keyword-argument instead of magic boolean""" ), - "Y402": QCoreApplication.translate( + "Y-402": QCoreApplication.translate( "SimplifyChecker", """Use keyword-argument instead of magic number""" ), # f-Strings - "Y411": QCoreApplication.translate("SimplifyChecker", "Do not nest f-strings"), + "Y-411": QCoreApplication.translate("SimplifyChecker", "Do not nest f-strings"), # Additional Checks - "Y901": QCoreApplication.translate( + "Y-901": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}" instead of "{1}"''' ), - "Y904": QCoreApplication.translate( + "Y-904": QCoreApplication.translate( "SimplifyChecker", """Initialize dictionary "{0}" directly""" ), - "Y905": QCoreApplication.translate( + "Y-905": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}" instead of "{1}"''' ), - "Y906": QCoreApplication.translate( + "Y-906": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}" instead of "{1}"''' ), - "Y907": QCoreApplication.translate( + "Y-907": QCoreApplication.translate( "SimplifyChecker", '''Use "Optional[{0}]" instead of "{1}"''' ), - "Y909": QCoreApplication.translate( + "Y-909": QCoreApplication.translate( "SimplifyChecker", '''Remove reflexive assignment "{0}"''' ), - "Y910": QCoreApplication.translate( + "Y-910": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}" instead of "{1}"''' ), - "Y911": QCoreApplication.translate( + "Y-911": QCoreApplication.translate( "SimplifyChecker", '''Use "{0}.items()" instead of "zip({0}.keys(), {0}.values())"''', ), @@ -186,55 +186,55 @@ _simplifyMessagesSampleArgs = { # Python-specifics - "Y101": ["foo"], - "Y103": ["foo != bar"], - "Y104": ["iterable"], - "Y105": ["Exception"], - "Y108": ["foo", "bar", "condition", "baz"], - "Y109": ["foo", "[1, 42]", "foo == 1 or foo == 42"], - "Y110": ["check", "foo", "iterable"], - "Y111": ["check", "foo", "iterable"], - "Y112": ["FOO", "foo"], - "Y113": ["foo"], - "Y114": ["foo > 42", "bar < 42"], - "Y116": ["bar_dict.get(foo, 42)"], - "Y117": ["with Foo() as foo, Bar() as bar:"], - "Y118": ["foo", "bar_dict"], - "Y119": ["Foo"], - "Y120": ["Foo"], - "Y121": ["FooBar", "Foo"], - "Y122": ["bar_dict", "'foo'"], - "Y123": ["foo", "fooDict", "bar", "default"], - "Y124": ["foo", "bar"], + "Y-101": ["foo"], + "Y-103": ["foo != bar"], + "Y-104": ["iterable"], + "Y-105": ["Exception"], + "Y-108": ["foo", "bar", "condition", "baz"], + "Y-109": ["foo", "[1, 42]", "foo == 1 or foo == 42"], + "Y-110": ["check", "foo", "iterable"], + "Y-111": ["check", "foo", "iterable"], + "Y-112": ["FOO", "foo"], + "Y-113": ["foo"], + "Y-114": ["foo > 42", "bar < 42"], + "Y-116": ["bar_dict.get(foo, 42)"], + "Y-117": ["with Foo() as foo, Bar() as bar:"], + "Y-118": ["foo", "bar_dict"], + "Y-119": ["Foo"], + "Y-120": ["Foo"], + "Y-121": ["FooBar", "Foo"], + "Y-122": ["bar_dict", "'foo'"], + "Y-123": ["foo", "fooDict", "bar", "default"], + "Y-124": ["foo", "bar"], # Python-specifics not part of flake8-simplify - "Y181": ["foo += 42", "foo = foo + 42"], - "Y182": ["super()"], + "Y-181": ["foo += 42", "foo = foo + 42"], + "Y-182": ["super()"], # Comparations - "Y201": ["foo", "bar"], - "Y202": ["foo", "bar"], - "Y203": ["foo", "bar"], - "Y204": ["foo", "bar"], - "Y205": ["foo", "bar"], - "Y206": ["foo", "bar"], - "Y207": ["foo", "bar"], - "Y208": ["foo"], - "Y211": ["foo", "bool(foo)"], - "Y212": ["foo", "not foo"], - "Y213": ["foo", "bar"], - "Y221": ["foo"], - "Y222": ["foo"], + "Y-201": ["foo", "bar"], + "Y-202": ["foo", "bar"], + "Y-203": ["foo", "bar"], + "Y-204": ["foo", "bar"], + "Y-205": ["foo", "bar"], + "Y-206": ["foo", "bar"], + "Y-207": ["foo", "bar"], + "Y-208": ["foo"], + "Y-211": ["foo", "bool(foo)"], + "Y-212": ["foo", "not foo"], + "Y-213": ["foo", "bar"], + "Y-221": ["foo"], + "Y-222": ["foo"], # Opinionated - "Y301": ["42", "foo"], + "Y-301": ["42", "foo"], # General Code Style # Additional checks - "Y901": ["foo == bar", "bool(foo == bar)"], - "Y904": ["foo"], - "Y905": [ + "Y-901": ["foo == bar", "bool(foo == bar)"], + "Y-904": ["foo"], + "Y-905": [ """["de", "com", "net", "org"]""", """domains = "de com net org".split()""", ], - "Y906": ["os.path.join(a, b, c)", "os.path.join(a,os.path.join(b,c))"], - "Y907": ["int", "Union[int, None]"], - "Y909": ["foo = foo"], - "Y911": ["foo"], + "Y-906": ["os.path.join(a, b, c)", "os.path.join(a,os.path.join(b,c))"], + "Y-907": ["int", "Union[int, None]"], + "Y-909": ["foo = foo"], + "Y-911": ["foo"], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Unused/UnusedChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Unused/UnusedChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -21,10 +21,10 @@ Codes = [ ## Unused Arguments - "U100", - "U101", + "U-100", + "U-101", ## Unused Globals - "U200", + "U-200", ] def __init__(self, source, filename, tree, select, ignore, expected, repeat, args): @@ -64,8 +64,8 @@ self.errors = [] checkersWithCodes = [ - (self.__checkUnusedArguments, ("U100", "U101")), - (self.__checkUnusedGlobals, ("U200",)), + (self.__checkUnusedArguments, ("U-100", "U-101")), + (self.__checkUnusedGlobals, ("U-200",)), ] self.__checkers = [] @@ -212,7 +212,7 @@ lineNumber = argument.lineno offset = argument.col_offset - errorCode = "U101" if name.startswith("_") else "U100" + errorCode = "U-101" if name.startswith("_") else "U-100" self.__error(lineNumber - 1, offset, errorCode, name) def __getDecoratorNames(self, functionNode): @@ -406,7 +406,7 @@ for varId, loads in loadCounter.getLoads(): if varId in globalVariables and loads == 0: storeInfo = loadCounter.getStoreInfo(varId) - errorInfo = (storeInfo.lineno - 1, storeInfo.offset, "U200", varId) + errorInfo = (storeInfo.lineno - 1, storeInfo.offset, "U-200", varId) errors[varId] = errorInfo for node in self.__tree.body[::-1]:
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Unused/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Unused/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -11,16 +11,16 @@ _unusedMessages = { ## Unused Arguments - "U100": QCoreApplication.translate("UnusedChecker", "Unused argument '{0}'"), - "U101": QCoreApplication.translate("UnusedChecker", "Unused argument '{0}'"), + "U-100": QCoreApplication.translate("UnusedChecker", "Unused argument '{0}'"), + "U-101": QCoreApplication.translate("UnusedChecker", "Unused argument '{0}'"), ## Unused Globals - "U200": QCoreApplication.translate("UnusedChecker", "Unused global variable '{0}'"), + "U-200": QCoreApplication.translate("UnusedChecker", "Unused global variable '{0}'"), } _unusedMessagesSampleArgs = { ## Unused Arguments - "U100": ["foo_arg"], - "U101": ["_bar_arg"], + "U-100": ["foo_arg"], + "U-101": ["_bar_arg"], ## Unused Globals - "U200": ["FOO"], + "U-200": ["FOO"], }
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/translations.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/translations.py Mon Feb 24 15:11:18 2025 +0100 @@ -38,185 +38,185 @@ ################################################################## _pycodestyleErrorMessages = { - "E101": QCoreApplication.translate( + "E-101": QCoreApplication.translate( "pycodestyle", "indentation contains mixed spaces and tabs" ), - "E111": QCoreApplication.translate( + "E-111": QCoreApplication.translate( "pycodestyle", "indentation is not a multiple of four" ), - "E112": QCoreApplication.translate("pycodestyle", "expected an indented block"), - "E113": QCoreApplication.translate("pycodestyle", "unexpected indentation"), - "E114": QCoreApplication.translate( + "E-112": QCoreApplication.translate("pycodestyle", "expected an indented block"), + "E-113": QCoreApplication.translate("pycodestyle", "unexpected indentation"), + "E-114": QCoreApplication.translate( "pycodestyle", "indentation is not a multiple of four (comment)" ), - "E115": QCoreApplication.translate( + "E-115": QCoreApplication.translate( "pycodestyle", "expected an indented block (comment)" ), - "E116": QCoreApplication.translate( + "E-116": QCoreApplication.translate( "pycodestyle", "unexpected indentation (comment)" ), - "E117": QCoreApplication.translate("pycodestyle", "over-indented"), - "E121": QCoreApplication.translate( + "E-117": QCoreApplication.translate("pycodestyle", "over-indented"), + "E-121": QCoreApplication.translate( "pycodestyle", "continuation line indentation is not a multiple of four" ), - "E122": QCoreApplication.translate( + "E-122": QCoreApplication.translate( "pycodestyle", "continuation line missing indentation or outdented" ), - "E123": QCoreApplication.translate( + "E-123": QCoreApplication.translate( "pycodestyle", "closing bracket does not match indentation of opening bracket's line", ), - "E124": QCoreApplication.translate( + "E-124": QCoreApplication.translate( "pycodestyle", "closing bracket does not match visual indentation" ), - "E125": QCoreApplication.translate( + "E-125": QCoreApplication.translate( "pycodestyle", "continuation line with same indent as next logical line" ), - "E126": QCoreApplication.translate( + "E-126": QCoreApplication.translate( "pycodestyle", "continuation line over-indented for hanging indent" ), - "E127": QCoreApplication.translate( + "E-127": QCoreApplication.translate( "pycodestyle", "continuation line over-indented for visual indent" ), - "E128": QCoreApplication.translate( + "E-128": QCoreApplication.translate( "pycodestyle", "continuation line under-indented for visual indent" ), - "E129": QCoreApplication.translate( + "E-129": QCoreApplication.translate( "pycodestyle", "visually indented line with same indent as next logical line" ), - "E131": QCoreApplication.translate( + "E-131": QCoreApplication.translate( "pycodestyle", "continuation line unaligned for hanging indent" ), - "E133": QCoreApplication.translate( + "E-133": QCoreApplication.translate( "pycodestyle", "closing bracket is missing indentation" ), - "E201": QCoreApplication.translate("pycodestyle", "whitespace after '{0}'"), - "E202": QCoreApplication.translate("pycodestyle", "whitespace before '{0}'"), - "E203": QCoreApplication.translate("pycodestyle", "whitespace before '{0}'"), - "E204": QCoreApplication.translate("pycodestyle", "whitespace after decorator '@'"), - "E211": QCoreApplication.translate("pycodestyle", "whitespace before '{0}'"), - "E221": QCoreApplication.translate( + "E-201": QCoreApplication.translate("pycodestyle", "whitespace after '{0}'"), + "E-202": QCoreApplication.translate("pycodestyle", "whitespace before '{0}'"), + "E-203": QCoreApplication.translate("pycodestyle", "whitespace before '{0}'"), + "E-204": QCoreApplication.translate("pycodestyle", "whitespace after decorator '@'"), + "E-211": QCoreApplication.translate("pycodestyle", "whitespace before '{0}'"), + "E-221": QCoreApplication.translate( "pycodestyle", "multiple spaces before operator" ), - "E222": QCoreApplication.translate("pycodestyle", "multiple spaces after operator"), - "E223": QCoreApplication.translate("pycodestyle", "tab before operator"), - "E224": QCoreApplication.translate("pycodestyle", "tab after operator"), - "E225": QCoreApplication.translate( + "E-222": QCoreApplication.translate("pycodestyle", "multiple spaces after operator"), + "E-223": QCoreApplication.translate("pycodestyle", "tab before operator"), + "E-224": QCoreApplication.translate("pycodestyle", "tab after operator"), + "E-225": QCoreApplication.translate( "pycodestyle", "missing whitespace around operator" ), - "E226": QCoreApplication.translate( + "E-226": QCoreApplication.translate( "pycodestyle", "missing whitespace around arithmetic operator" ), - "E227": QCoreApplication.translate( + "E-227": QCoreApplication.translate( "pycodestyle", "missing whitespace around bitwise or shift operator" ), - "E228": QCoreApplication.translate( + "E-228": QCoreApplication.translate( "pycodestyle", "missing whitespace around modulo operator" ), - "E231": QCoreApplication.translate("pycodestyle", "missing whitespace after '{0}'"), - "E241": QCoreApplication.translate("pycodestyle", "multiple spaces after '{0}'"), - "E242": QCoreApplication.translate("pycodestyle", "tab after '{0}'"), - "E251": QCoreApplication.translate( + "E-231": QCoreApplication.translate("pycodestyle", "missing whitespace after '{0}'"), + "E-241": QCoreApplication.translate("pycodestyle", "multiple spaces after '{0}'"), + "E-242": QCoreApplication.translate("pycodestyle", "tab after '{0}'"), + "E-251": QCoreApplication.translate( "pycodestyle", "unexpected spaces around keyword / parameter equals" ), - "E252": QCoreApplication.translate( + "E-252": QCoreApplication.translate( "pycodestyle", "missing whitespace around parameter equals" ), - "E261": QCoreApplication.translate( + "E-261": QCoreApplication.translate( "pycodestyle", "at least two spaces before inline comment" ), - "E262": QCoreApplication.translate( + "E-262": QCoreApplication.translate( "pycodestyle", "inline comment should start with '# '" ), - "E265": QCoreApplication.translate( + "E-265": QCoreApplication.translate( "pycodestyle", "block comment should start with '# '" ), - "E266": QCoreApplication.translate( + "E-266": QCoreApplication.translate( "pycodestyle", "too many leading '#' for block comment" ), - "E271": QCoreApplication.translate("pycodestyle", "multiple spaces after keyword"), - "E272": QCoreApplication.translate("pycodestyle", "multiple spaces before keyword"), - "E273": QCoreApplication.translate("pycodestyle", "tab after keyword"), - "E274": QCoreApplication.translate("pycodestyle", "tab before keyword"), - "E275": QCoreApplication.translate( + "E-271": QCoreApplication.translate("pycodestyle", "multiple spaces after keyword"), + "E-272": QCoreApplication.translate("pycodestyle", "multiple spaces before keyword"), + "E-273": QCoreApplication.translate("pycodestyle", "tab after keyword"), + "E-274": QCoreApplication.translate("pycodestyle", "tab before keyword"), + "E-275": QCoreApplication.translate( "pycodestyle", "missing whitespace after keyword" ), - "E301": QCoreApplication.translate( + "E-301": QCoreApplication.translate( "pycodestyle", "expected {0} blank lines, found {1}" ), - "E302": QCoreApplication.translate( + "E-302": QCoreApplication.translate( "pycodestyle", "expected {0} blank lines, found {1}" ), - "E303": QCoreApplication.translate( + "E-303": QCoreApplication.translate( "pycodestyle", "too many blank lines ({0}), expected {1}" ), - "E304": QCoreApplication.translate( + "E-304": QCoreApplication.translate( "pycodestyle", "blank lines found after function decorator" ), - "E305": QCoreApplication.translate( + "E-305": QCoreApplication.translate( "pycodestyle", "expected {0} blank lines after class or function definition, found {1}", ), - "E306": QCoreApplication.translate( + "E-306": QCoreApplication.translate( "pycodestyle", "expected {0} blank lines before a nested definition, found {1}" ), - "E307": QCoreApplication.translate( + "E-307": QCoreApplication.translate( "pycodestyle", "too many blank lines ({0}) before a nested definition, expected {1}", ), - "E308": QCoreApplication.translate("pycodestyle", "too many blank lines ({0})"), - "E401": QCoreApplication.translate("pycodestyle", "multiple imports on one line"), - "E402": QCoreApplication.translate( + "E-308": QCoreApplication.translate("pycodestyle", "too many blank lines ({0})"), + "E-401": QCoreApplication.translate("pycodestyle", "multiple imports on one line"), + "E-402": QCoreApplication.translate( "pycodestyle", "module level import not at top of file" ), - "E501": QCoreApplication.translate( + "E-501": QCoreApplication.translate( "pycodestyle", "line too long ({0} > {1} characters)" ), - "E502": QCoreApplication.translate( + "E-502": QCoreApplication.translate( "pycodestyle", "the backslash is redundant between brackets" ), - "E701": QCoreApplication.translate( + "E-701": QCoreApplication.translate( "pycodestyle", "multiple statements on one line (colon)" ), - "E702": QCoreApplication.translate( + "E-702": QCoreApplication.translate( "pycodestyle", "multiple statements on one line (semicolon)" ), - "E703": QCoreApplication.translate( + "E-703": QCoreApplication.translate( "pycodestyle", "statement ends with a semicolon" ), - "E704": QCoreApplication.translate( + "E-704": QCoreApplication.translate( "pycodestyle", "multiple statements on one line (def)" ), - "E711": QCoreApplication.translate( + "E-711": QCoreApplication.translate( "pycodestyle", "comparison to {0} should be {1}" ), - "E712": QCoreApplication.translate( + "E-712": QCoreApplication.translate( "pycodestyle", "comparison to {0} should be {1}" ), - "E713": QCoreApplication.translate( + "E-713": QCoreApplication.translate( "pycodestyle", "test for membership should be 'not in'" ), - "E714": QCoreApplication.translate( + "E-714": QCoreApplication.translate( "pycodestyle", "test for object identity should be 'is not'" ), - "E721": QCoreApplication.translate( + "E-721": QCoreApplication.translate( "pycodestyle", "do not compare types, for exact checks use 'is' / 'is not', " "for instance checks use 'isinstance()'", ), - "E722": QCoreApplication.translate("pycodestyle", "do not use bare except"), - "E731": QCoreApplication.translate( + "E-722": QCoreApplication.translate("pycodestyle", "do not use bare except"), + "E-731": QCoreApplication.translate( "pycodestyle", "do not assign a lambda expression, use a def" ), - "E741": QCoreApplication.translate("pycodestyle", "ambiguous variable name '{0}'"), - "E742": QCoreApplication.translate( + "E-741": QCoreApplication.translate("pycodestyle", "ambiguous variable name '{0}'"), + "E-742": QCoreApplication.translate( "pycodestyle", "ambiguous class definition '{0}'" ), - "E743": QCoreApplication.translate( + "E-743": QCoreApplication.translate( "pycodestyle", "ambiguous function definition '{0}'" ), - "E901": QCoreApplication.translate("pycodestyle", "{0}: {1}"), - "E902": QCoreApplication.translate("pycodestyle", "{0}"), + "E-901": QCoreApplication.translate("pycodestyle", "{0}: {1}"), + "E-902": QCoreApplication.translate("pycodestyle", "{0}"), } ################################################################## @@ -224,24 +224,24 @@ ################################################################## _pycodestyleWarningMessages = { - "W191": QCoreApplication.translate("pycodestyle", "indentation contains tabs"), - "W291": QCoreApplication.translate("pycodestyle", "trailing whitespace"), - "W292": QCoreApplication.translate("pycodestyle", "no newline at end of file"), - "W293": QCoreApplication.translate("pycodestyle", "blank line contains whitespace"), - "W391": QCoreApplication.translate("pycodestyle", "blank line at end of file"), - "W503": QCoreApplication.translate( + "W-191": QCoreApplication.translate("pycodestyle", "indentation contains tabs"), + "W-291": QCoreApplication.translate("pycodestyle", "trailing whitespace"), + "W-292": QCoreApplication.translate("pycodestyle", "no newline at end of file"), + "W-293": QCoreApplication.translate("pycodestyle", "blank line contains whitespace"), + "W-391": QCoreApplication.translate("pycodestyle", "blank line at end of file"), + "W-503": QCoreApplication.translate( "pycodestyle", "line break before binary operator" ), - "W504": QCoreApplication.translate( + "W-504": QCoreApplication.translate( "pycodestyle", "line break after binary operator" ), - "W505": QCoreApplication.translate( + "W-505": QCoreApplication.translate( "pycodestyle", "doc line too long ({0} > {1} characters)" ), - "W605": QCoreApplication.translate( + "W-605": QCoreApplication.translate( "pycodestyle", "invalid escape sequence '\\{0}'" ), - "W606": QCoreApplication.translate( + "W-606": QCoreApplication.translate( "pycodestyle", "'async' and 'await' are reserved keywords starting with Python 3.7", ), @@ -252,178 +252,178 @@ ################################################################## _fixMessages = { - "FIXD111": QCoreApplication.translate( + "FIX-D111": QCoreApplication.translate( "CodeStyleFixer", "Triple single quotes converted to triple double quotes." ), - "FIXD112": QCoreApplication.translate( + "FIX-D112": QCoreApplication.translate( "CodeStyleFixer", 'Introductory quotes corrected to be {0}"""' ), - "FIXD121": QCoreApplication.translate( + "FIX-D121": QCoreApplication.translate( "CodeStyleFixer", "Single line docstring put on one line." ), - "FIXD131": QCoreApplication.translate( + "FIX-D131": QCoreApplication.translate( "CodeStyleFixer", "Period added to summary line." ), - "FIXD141": QCoreApplication.translate( + "FIX-D141": QCoreApplication.translate( "CodeStyleFixer", "Blank line before function/method docstring removed." ), - "FIXD142": QCoreApplication.translate( + "FIX-D142": QCoreApplication.translate( "CodeStyleFixer", "Blank line inserted before class docstring." ), - "FIXD143": QCoreApplication.translate( + "FIX-D143": QCoreApplication.translate( "CodeStyleFixer", "Blank line inserted after class docstring." ), - "FIXD144": QCoreApplication.translate( + "FIX-D144": QCoreApplication.translate( "CodeStyleFixer", "Blank line inserted after docstring summary." ), - "FIXD145": QCoreApplication.translate( + "FIX-D145": QCoreApplication.translate( "CodeStyleFixer", "Blank line inserted after last paragraph of docstring." ), - "FIXD221": QCoreApplication.translate( + "FIX-D221": QCoreApplication.translate( "CodeStyleFixer", "Leading quotes put on separate line." ), - "FIXD222": QCoreApplication.translate( + "FIX-D222": QCoreApplication.translate( "CodeStyleFixer", "Trailing quotes put on separate line." ), - "FIXD242": QCoreApplication.translate( + "FIX-D242": QCoreApplication.translate( "CodeStyleFixer", "Blank line before class docstring removed." ), - "FIXD244": QCoreApplication.translate( + "FIX-D244": QCoreApplication.translate( "CodeStyleFixer", "Blank line before function/method docstring removed." ), - "FIXD243": QCoreApplication.translate( + "FIX-D243": QCoreApplication.translate( "CodeStyleFixer", "Blank line after class docstring removed." ), - "FIXD245": QCoreApplication.translate( + "FIX-D245": QCoreApplication.translate( "CodeStyleFixer", "Blank line after function/method docstring removed." ), - "FIXD247": QCoreApplication.translate( + "FIX-D247": QCoreApplication.translate( "CodeStyleFixer", "Blank line after last paragraph removed." ), - "FIXE101": QCoreApplication.translate( + "FIX-E101": QCoreApplication.translate( "CodeStyleFixer", "Tab converted to 4 spaces." ), - "FIXE111": QCoreApplication.translate( + "FIX-E111": QCoreApplication.translate( "CodeStyleFixer", "Indentation adjusted to be a multiple of four." ), - "FIXE121": QCoreApplication.translate( + "FIX-E121": QCoreApplication.translate( "CodeStyleFixer", "Indentation of continuation line corrected." ), - "FIXE124": QCoreApplication.translate( + "FIX-E124": QCoreApplication.translate( "CodeStyleFixer", "Indentation of closing bracket corrected." ), - "FIXE122": QCoreApplication.translate( + "FIX-E122": QCoreApplication.translate( "CodeStyleFixer", "Missing indentation of continuation line corrected." ), - "FIXE123": QCoreApplication.translate( + "FIX-E123": QCoreApplication.translate( "CodeStyleFixer", "Closing bracket aligned to opening bracket." ), - "FIXE125": QCoreApplication.translate( + "FIX-E125": QCoreApplication.translate( "CodeStyleFixer", "Indentation level changed." ), - "FIXE126": QCoreApplication.translate( + "FIX-E126": QCoreApplication.translate( "CodeStyleFixer", "Indentation level of hanging indentation changed." ), - "FIXE127": QCoreApplication.translate( + "FIX-E127": QCoreApplication.translate( "CodeStyleFixer", "Visual indentation corrected." ), - "FIXE201": QCoreApplication.translate( + "FIX-E201": QCoreApplication.translate( "CodeStyleFixer", "Extraneous whitespace removed." ), - "FIXE225": QCoreApplication.translate( + "FIX-E225": QCoreApplication.translate( "CodeStyleFixer", "Missing whitespace added." ), - "FIXE221": QCoreApplication.translate( + "FIX-E221": QCoreApplication.translate( "CodeStyleFixer", "Extraneous whitespace removed." ), - "FIXE231": QCoreApplication.translate( + "FIX-E231": QCoreApplication.translate( "CodeStyleFixer", "Missing whitespace added." ), - "FIXE251": QCoreApplication.translate( + "FIX-E251": QCoreApplication.translate( "CodeStyleFixer", "Extraneous whitespace removed." ), - "FIXE261": QCoreApplication.translate( + "FIX-E261": QCoreApplication.translate( "CodeStyleFixer", "Whitespace around comment sign corrected." ), - "FIXE302+": lambda n=1: QCoreApplication.translate( + "FIX-E302+": lambda n=1: QCoreApplication.translate( "CodeStyleFixer", "%n blank line(s) inserted.", "", n ), - "FIXE302-": lambda n=1: QCoreApplication.translate( + "FIX-E302-": lambda n=1: QCoreApplication.translate( "CodeStyleFixer", "%n superfluous lines removed", "", n ), - "FIXE303": QCoreApplication.translate( + "FIX-E303": QCoreApplication.translate( "CodeStyleFixer", "Superfluous blank lines removed." ), - "FIXE304": QCoreApplication.translate( + "FIX-E304": QCoreApplication.translate( "CodeStyleFixer", "Superfluous blank lines after function decorator removed." ), - "FIXE401": QCoreApplication.translate( + "FIX-E401": QCoreApplication.translate( "CodeStyleFixer", "Imports were put on separate lines." ), - "FIXE501": QCoreApplication.translate( + "FIX-E501": QCoreApplication.translate( "CodeStyleFixer", "Long lines have been shortened." ), - "FIXE502": QCoreApplication.translate( + "FIX-E502": QCoreApplication.translate( "CodeStyleFixer", "Redundant backslash in brackets removed." ), - "FIXE701": QCoreApplication.translate( + "FIX-E701": QCoreApplication.translate( "CodeStyleFixer", "Compound statement corrected." ), - "FIXE702": QCoreApplication.translate( + "FIX-E702": QCoreApplication.translate( "CodeStyleFixer", "Compound statement corrected." ), - "FIXE711": QCoreApplication.translate( + "FIX-E711": QCoreApplication.translate( "CodeStyleFixer", "Comparison to None/True/False corrected." ), - "FIXN804": QCoreApplication.translate("CodeStyleFixer", "'{0}' argument added."), - "FIXN806": QCoreApplication.translate("CodeStyleFixer", "'{0}' argument removed."), - "FIXW291": QCoreApplication.translate( + "FIX-N804": QCoreApplication.translate("CodeStyleFixer", "'{0}' argument added."), + "FIX-N806": QCoreApplication.translate("CodeStyleFixer", "'{0}' argument removed."), + "FIX-W291": QCoreApplication.translate( "CodeStyleFixer", "Whitespace stripped from end of line." ), - "FIXW292": QCoreApplication.translate( + "FIX-W292": QCoreApplication.translate( "CodeStyleFixer", "newline added to end of file." ), - "FIXW391": QCoreApplication.translate( + "FIX-W391": QCoreApplication.translate( "CodeStyleFixer", "Superfluous trailing blank lines removed from end of file." ), - "FIXW603": QCoreApplication.translate("CodeStyleFixer", "'<>' replaced by '!='."), - "FIXWRITE_ERROR": QCoreApplication.translate( + "FIX-W603": QCoreApplication.translate("CodeStyleFixer", "'<>' replaced by '!='."), + "FIX-WRITE_ERROR": QCoreApplication.translate( "CodeStyleFixer", "Could not save the file! Skipping it. Reason: {0}" ), } _pycodestyleErrorMessagesSampleArgs = { - "E201": ["([{"], - "E202": ["}])"], - "E203": [",;:"], - "E211": ["(["], - "E231": [",;:"], - "E241": [",;:"], - "E242": [",;:"], - "E301": [1, 0], - "E302": [2, 1], - "E303": [3, 2], - "E305": [2, 1], - "E306": [1, 0], - "E307": [3, 1], - "E308": [3], - "E501": [95, 88], - "E711": ["None", "'if cond is None:'"], - "E712": ["True", "'if cond is True:' or 'if cond:'"], - "E741": ["l"], - "E742": ["l"], - "E743": ["l"], - "E901": ["SyntaxError", "Invalid Syntax"], - "E902": ["OSError"], + "E-201": ["([{"], + "E-202": ["}])"], + "E-203": [",;:"], + "E-211": ["(["], + "E-231": [",;:"], + "E-241": [",;:"], + "E-242": [",;:"], + "E-301": [1, 0], + "E-302": [2, 1], + "E-303": [3, 2], + "E-305": [2, 1], + "E-306": [1, 0], + "E-307": [3, 1], + "E-308": [3], + "E-501": [95, 88], + "E-711": ["None", "'if cond is None:'"], + "E-712": ["True", "'if cond is True:' or 'if cond:'"], + "E-741": ["l"], + "E-742": ["l"], + "E-743": ["l"], + "E-901": ["SyntaxError", "Invalid Syntax"], + "E-902": ["OSError"], } _pycodestyleWarningMessagesSampleArgs = { - "W505": [80, 72], - "W605": ["A"], + "W-505": [80, 72], + "W-605": ["A"], } _fixMessagesSampleArgs = { - "FIXWRITE_ERROR": ["OSError"], + "FIX-WRITE_ERROR": ["OSError"], } messageCatalogs = {