src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py

branch
eric7
changeset 10069
435cc5875135
parent 10059
9e3452188615
child 10116
4a619fb7bd09
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Thu May 25 11:12:05 2023 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Thu May 25 19:51:47 2023 +0200
@@ -65,29 +65,29 @@
         self.__repeat = options.repeat
         self.errors = []
 
-    def error_args(self, line_number, offset, code, check, *args):
+    def error_args(self, line_number, offset, errorCode, check, *args):
         """
         Public method to collect the error messages.
 
         @param line_number line number of the issue (integer)
         @param offset position within line of the issue (integer)
-        @param code message code (string)
+        @param errorCode error message code (string)
         @param check reference to the checker function (function)
         @param args arguments for the message (list)
         @return error code (string)
         """
-        code = super().error_args(line_number, offset, code, check, *args)
-        if code and (self.counters[code] == 1 or self.__repeat):
+        errorCode = super().error_args(line_number, offset, errorCode, check, *args)
+        if errorCode and (self.counters[errorCode] == 1 or self.__repeat):
             self.errors.append(
                 {
                     "file": self.filename,
                     "line": line_number,
                     "offset": offset,
-                    "code": code,
+                    "code": errorCode,
                     "args": args,
                 }
             )
-        return code
+        return errorCode
 
 
 def extractLineFlags(line, startComment="#", endComment="", flagsLine=False):
@@ -118,27 +118,27 @@
                 ]
             else:
                 flags = [
-                    f.strip()
+                    f
                     for f in comment.split()
                     if (f.startswith("__") and f.endswith("__"))
                 ]
                 flags += [
-                    f.strip().lower()
+                    f.lower()
                     for f in comment.split()
                     if f in ("noqa", "NOQA", "nosec", "NOSEC", "secok", "SECOK")
                 ]
     return flags
 
 
-def ignoreCode(code, lineFlags):
+def ignoreCode(errorCode, lineFlags):
     """
     Function to check, if the given code should be ignored as per line flags.
 
-    @param code error code to be checked
+    @param errorCode error code to be checked
     @type str
     @param lineFlags list of line flags to check against
     @type list of str
-    @return flag indicating to ignore the code
+    @return flag indicating to ignore the error code
     @rtype bool
     """
     if lineFlags:
@@ -154,21 +154,21 @@
             # check individual warning code
             if flag.startswith("__IGNORE_WARNING_"):
                 ignoredCode = flag[2:-2].rsplit("_", 1)[-1]
-                if code.startswith(ignoredCode):
+                if errorCode.startswith(ignoredCode):
                     return True
             elif flag.startswith("noqa:"):
                 ignoredCode = flag[len("noqa:") :].strip()
-                if code.startswith(ignoredCode):
+                if errorCode.startswith(ignoredCode):
                     return True
 
     return False
 
 
-def securityOk(code, lineFlags):
+def securityOk(errorCode, lineFlags):  # noqa: U100
     """
-    Function to check, if the given code is an acknowledged security report.
+    Function to check, if the given error code is an acknowledged security report.
 
-    @param code error code to be checked
+    @param errorCode error code to be checked
     @type str
     @param lineFlags list of line flags to check against
     @type list of str
@@ -183,11 +183,11 @@
 
 def codeStyleCheck(filename, source, args):
     """
-    Do the code style check and/or fix found errors.
+    Do the source code style check and/or fix found errors.
 
     @param filename source filename
     @type str
-    @param source string containing the code to check
+    @param source string containing the source code to check
     @type str
     @param args arguments used by the codeStyleCheck function (list of
         excludeMessages, includeMessages, repeatMessages, fixCodes,
@@ -208,7 +208,7 @@
 
 def codeStyleBatchCheck(argumentsList, send, fx, cancelled, maxProcesses=0):
     """
-    Module function to check code style for a batch of files.
+    Module function to check source code style for a batch of files.
 
     @param argumentsList list of arguments tuples as given for codeStyleCheck
     @type list
@@ -304,7 +304,7 @@
 
     @param filename source filename
     @type str
-    @param source string containing the code to check
+    @param source string containing the source code to check
     @type str
     @return tuple containing the error dictionary with syntax error details,
         a statistics dictionary and None or a tuple containing two None and
@@ -346,12 +346,12 @@
 
 def __checkCodeStyle(filename, source, args):
     """
-    Private module function to perform the code style check and/or fix
+    Private module function to perform the source code style check and/or fix
     found errors.
 
     @param filename source filename
     @type str
-    @param source string containing the code to check
+    @param source string containing the source code to check
     @type str
     @param args arguments used by the codeStyleCheck function (list of
         excludeMessages, includeMessages, repeatMessages, fixCodes,
@@ -367,7 +367,7 @@
         <li>file: file name</li>
         <li>line: line_number</li>
         <li>offset: offset within line</li>
-        <li>code: message code</li>
+        <li>code: error message code</li>
         <li>args: list of arguments to format the message</li>
         <li>ignored: flag indicating this issue was ignored</li>
         <li>fixed: flag indicating this issue was fixed</li>
@@ -604,22 +604,22 @@
             )
 
             if source:
-                code = error["code"]
+                errorCode = error["code"]
                 lineFlags = extractLineFlags(source[lineno - 1].strip())
                 with contextlib.suppress(IndexError):
                     lineFlags += extractLineFlags(
                         source[lineno].strip(), flagsLine=True
                     )
 
-                if securityOk(code, lineFlags):
+                if securityOk(errorCode, lineFlags):
                     error["securityOk"] = True
 
-                if ignoreCode(code, lineFlags):
+                if ignoreCode(errorCode, lineFlags):
                     error["ignored"] = True
                 else:
                     if fixer:
                         res, fixcode, fixargs, id_ = fixer.fixIssue(
-                            lineno, error["offset"], code
+                            lineno, error["offset"], errorCode
                         )
                         if res == -1:
                             deferredFixes[id_] = error

eric ide

mercurial