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

branch
eric7
changeset 11147
dee6e106b4d3
parent 11143
ef75c265ab47
child 11148
15e30f0c76a8
diff -r 59e04f7003e9 -r dee6e106b4d3 src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py
--- 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

eric ide

mercurial