eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py

branch
eric7
changeset 8790
548df4df8256
parent 8318
962bce857696
child 8881
54e42bc2437a
diff -r b165effc3c62 -r 548df4df8256 eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py
--- a/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py	Wed Nov 24 20:08:25 2021 +0100
+++ b/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py	Thu Nov 25 17:48:51 2021 +0100
@@ -15,9 +15,9 @@
 
 from .translations import getTranslatedMessage
 
-from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog
+from . import CodeStyleCheckerUtilities
 
-import UI.PixmapCache
+from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog
 
 
 class CodeStyleStatisticsDialog(QDialog, Ui_CodeStyleStatisticsDialog):
@@ -25,11 +25,11 @@
     Class implementing a dialog showing statistical data for the last
     code style checker run.
     """
-    def __init__(self, statistics, parent=None):
+    def __init__(self, statisticData, parent=None):
         """
         Constructor
         
-        @param statistics dictionary with the statistical data
+        @param statisticData dictionary with the statistical data
         @type dict
         @param parent reference to the parent widget
         @type QWidget
@@ -37,7 +37,7 @@
         super().__init__(parent)
         self.setupUi(self)
         
-        stats = statistics.copy()
+        stats = statisticData.copy()
         filesCount = stats["_FilesCount"]
         filesIssues = stats["_FilesIssues"]
         fixesCount = stats["_IssuesFixed"]
@@ -52,15 +52,15 @@
         
         textWrapper = textwrap.TextWrapper(width=80)
         
-        for code in sorted(stats.keys()):
-            message = getTranslatedMessage(code, [], example=True)
+        for msgCode in sorted(stats.keys()):
+            message = getTranslatedMessage(msgCode, [], example=True)
             if message is None:
                 continue
             
-            self.__createItem(stats[code], code,
+            self.__createItem(stats[msgCode], msgCode,
                               "\n".join(textWrapper.wrap(message)))
-            totalIssues += stats[code]["total"]
-            ignoresCount += stats[code]["ignored"]
+            totalIssues += stats[msgCode]["total"]
+            ignoresCount += stats[msgCode]["ignored"]
         
         self.totalIssues.setText(
             self.tr("%n issue(s) found", "", totalIssues))
@@ -79,35 +79,22 @@
         self.statisticsList.resizeColumnToContents(1)
         self.statisticsList.resizeColumnToContents(2)
     
-    def __createItem(self, counts, code, message):
+    def __createItem(self, counts, msgCode, message):
         """
         Private method to create an entry in the result list.
         
         @param counts dictionary containing the total and ignored occurrences
             of the issue
         @type dict
-        @param code of a code style issue message
+        @param msgCode code of a code style issue message
         @type str
         @param message code style issue message to be shown
         @type str
         """
         itm = QTreeWidgetItem(self.statisticsList, [
-            code, "{0:6d}".format(counts["total"] - counts["ignored"]),
+            msgCode, "{0:6d}".format(counts["total"] - counts["ignored"]),
             "{0:6d}".format(counts["ignored"]), message])
-        if code.startswith(("W", "C", "M")):
-            itm.setIcon(0, UI.PixmapCache.getIcon("warning"))
-        elif code.startswith("E"):
-            itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError"))
-        elif code.startswith("N"):
-            itm.setIcon(0, UI.PixmapCache.getIcon("namingError"))
-        elif code.startswith("D"):
-            itm.setIcon(0, UI.PixmapCache.getIcon("docstringError"))
-        elif code.startswith("S"):
-            itm.setIcon(0, UI.PixmapCache.getIcon("securityLow"))
-        elif code.startswith("P"):
-            itm.setIcon(0, UI.PixmapCache.getIcon("dirClosed"))
-        elif code.startswith("Y"):
-            itm.setIcon(0, UI.PixmapCache.getIcon("filePython"))
+        CodeStyleCheckerUtilities.setItemIcon(itm, 0, msgCode)
         
         itm.setTextAlignment(
             0, Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter)

eric ide

mercurial