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

branch
eric7
changeset 11142
2f0fb22c1d63
parent 11090
f5f5f5803935
child 11143
ef75c265ab47
equal deleted inserted replaced
11141:2f5f73c51c7c 11142:2f0fb22c1d63
91 "L": QCoreApplication.translate("CheckerCategories", "Logging"), 91 "L": QCoreApplication.translate("CheckerCategories", "Logging"),
92 "M": QCoreApplication.translate("CheckerCategories", "Miscellaneous"), 92 "M": QCoreApplication.translate("CheckerCategories", "Miscellaneous"),
93 "N": QCoreApplication.translate("CheckerCategories", "Naming"), 93 "N": QCoreApplication.translate("CheckerCategories", "Naming"),
94 "NO": QCoreApplication.translate("CheckerCategories", "Name Order"), 94 "NO": QCoreApplication.translate("CheckerCategories", "Name Order"),
95 "P": QCoreApplication.translate("CheckerCategories", "'pathlib' Usage"), 95 "P": QCoreApplication.translate("CheckerCategories", "'pathlib' Usage"),
96 "PYD": QCoreApplication.translate("CheckerCategories", "'pydantic' Usage"),
96 "S": QCoreApplication.translate("CheckerCategories", "Security"), 97 "S": QCoreApplication.translate("CheckerCategories", "Security"),
97 "U": QCoreApplication.translate("CheckerCategories", "Unused"), 98 "U": QCoreApplication.translate("CheckerCategories", "Unused"),
98 "W": QCoreApplication.translate("CheckerCategories", "Warnings"), 99 "W": QCoreApplication.translate("CheckerCategories", "Warnings"),
99 "Y": QCoreApplication.translate("CheckerCategories", "Simplify Code"), 100 "Y": QCoreApplication.translate("CheckerCategories", "Simplify Code"),
100 } 101 }
792 ) 793 )
793 self.ignoreDunderGlobalsCheckBox.setChecked( 794 self.ignoreDunderGlobalsCheckBox.setChecked(
794 self.__data["UnusedChecker"]["IgnoreDunderGlobals"] 795 self.__data["UnusedChecker"]["IgnoreDunderGlobals"]
795 ) 796 )
796 797
797 self.__cleanupData()
798
799 def __prepareProgress(self): 798 def __prepareProgress(self):
800 """ 799 """
801 Private method to prepare the progress tab for the next run. 800 Private method to prepare the progress tab for the next run.
802 """ 801 """
803 self.progressList.clear() 802 self.progressList.clear()
877 ] 876 ]
878 877
879 self.__errorItem = None 878 self.__errorItem = None
880 self.__resetStatistics() 879 self.__resetStatistics()
881 self.__clearErrors(self.files) 880 self.__clearErrors(self.files)
882 self.__cleanupData()
883 self.__prepareProgress() 881 self.__prepareProgress()
884 882
885 # disable updates of the list for speed 883 # disable updates of the list for speed
886 self.resultList.setUpdatesEnabled(False) 884 self.resultList.setUpdatesEnabled(False)
887 self.resultList.setSortingEnabled(False) 885 self.resultList.setSortingEnabled(False)
891 "S" in self.__getCategories(True, asList=True) 889 "S" in self.__getCategories(True, asList=True)
892 ) 890 )
893 891
894 # extract the configuration values 892 # extract the configuration values
895 excludeMessages = self.__assembleExcludeMessages() 893 excludeMessages = self.__assembleExcludeMessages()
896 includeMessages = self.includeMessagesEdit.text() 894 includeMessages = self.__assembleIncludeMessages()
897 repeatMessages = self.repeatCheckBox.isChecked() 895 repeatMessages = self.repeatCheckBox.isChecked()
898 fixCodes = self.fixIssuesEdit.text() 896 fixCodes = self.fixIssuesEdit.text()
899 noFixCodes = self.noFixIssuesEdit.text() 897 noFixCodes = self.noFixIssuesEdit.text()
900 self.__noFixCodesList = [ 898 self.__noFixCodesList = [
901 c.strip() for c in noFixCodes.split(",") if c.strip() 899 c.strip() for c in noFixCodes.split(",") if c.strip()
1371 @pyqtSlot() 1369 @pyqtSlot()
1372 def on_startButton_clicked(self): 1370 def on_startButton_clicked(self):
1373 """ 1371 """
1374 Private slot to start a code style check run. 1372 Private slot to start a code style check run.
1375 """ 1373 """
1376 self.__cleanupData()
1377
1378 if self.__forProject: 1374 if self.__forProject:
1379 data = { 1375 data = {
1380 "EnabledCheckerCategories": self.__getCategories(True), 1376 "EnabledCheckerCategories": self.__getCategories(True),
1381 "ExcludeFiles": self.excludeFilesEdit.text(), 1377 "ExcludeFiles": self.excludeFilesEdit.text(),
1382 "ExcludeMessages": self.excludeMessagesEdit.text(), 1378 "ExcludeMessages": self.excludeMessagesEdit.text(),
2198 defaultParameters["UnusedChecker"]["IgnoreDunderGlobals"], 2194 defaultParameters["UnusedChecker"]["IgnoreDunderGlobals"],
2199 ) 2195 )
2200 ) 2196 )
2201 ) 2197 )
2202 2198
2203 self.__cleanupData()
2204
2205 @pyqtSlot() 2199 @pyqtSlot()
2206 def on_storeDefaultButton_clicked(self): 2200 def on_storeDefaultButton_clicked(self):
2207 """ 2201 """
2208 Private slot to store the current configuration values as 2202 Private slot to store the current configuration values as
2209 default values. 2203 default values.
2914 """ 2908 """
2915 excludeMessages = self.excludeMessagesEdit.text() 2909 excludeMessages = self.excludeMessagesEdit.text()
2916 disabledCategories = self.__getCategories(False) 2910 disabledCategories = self.__getCategories(False)
2917 2911
2918 if excludeMessages and disabledCategories: 2912 if excludeMessages and disabledCategories:
2919 return disabledCategories + "," + excludeMessages 2913 return disabledCategories + ", " + excludeMessages
2920 elif disabledCategories: 2914 elif disabledCategories:
2921 return disabledCategories 2915 return disabledCategories
2922 elif excludeMessages: 2916 elif excludeMessages:
2923 return excludeMessages 2917 return excludeMessages
2924 else: 2918 else:
2925 return "" 2919 return ""
2926 2920
2927 def __cleanupData(self): 2921 def __assembleIncludeMessages(self):
2928 """ 2922 """
2929 Private method to clean the loaded/entered data of redundant entries. 2923 Private method to assemble the list of included checks.
2930 """ 2924
2931 # Migrate single letter exclude messages to disabled checker categories 2925 @return list of included checks as a comma separated string.
2932 # and delete them from exclude messages 2926 @rtype str
2933 excludedMessages = [ 2927 """
2934 m.strip() for m in self.excludeMessagesEdit.text().split(",") if bool(m) 2928 includeMessages = self.includeMessagesEdit.text()
2935 ] 2929 enabledCategories = self.__getCategories(True)
2936 excludedMessageCategories = [c for c in excludedMessages if len(c) == 1] 2930
2937 enabledCheckers = self.__getCategories(True, asList=True) 2931 if includeMessages and enabledCategories:
2938 for category in excludedMessageCategories: 2932 return enabledCategories + ", " + includeMessages
2939 if category in enabledCheckers: 2933 elif enabledCategories:
2940 enabledCheckers.remove(category) 2934 return enabledCategories
2941 excludedMessages.remove(category) 2935 elif includeMessages:
2942 2936 return includeMessages
2943 # Remove excluded messages of an already excluded category 2937 else:
2944 disabledCheckers = self.__getCategories(False, asList=True) 2938 return ""
2945 for message in excludedMessages[:]:
2946 if message[0] in disabledCheckers:
2947 excludedMessages.remove(message)
2948
2949 self.excludeMessagesEdit.setText(",".join(excludedMessages))
2950 self.__initCategoriesList(",".join(enabledCheckers))
2951 2939
2952 def __initCommentedCodeCheckerWhiteList(self, whitelist): 2940 def __initCommentedCodeCheckerWhiteList(self, whitelist):
2953 """ 2941 """
2954 Private method to populate the list of commented code whitelist 2942 Private method to populate the list of commented code whitelist
2955 patterns. 2943 patterns.

eric ide

mercurial