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

branch
eric7
changeset 11147
dee6e106b4d3
parent 11143
ef75c265ab47
child 11148
15e30f0c76a8
equal deleted inserted replaced
11146:59e04f7003e9 11147:dee6e106b4d3
10 import collections 10 import collections
11 import copy 11 import copy
12 import fnmatch 12 import fnmatch
13 import json 13 import json
14 import os 14 import os
15 import re
15 import time 16 import time
16 17
17 from PyQt6.QtCore import QCoreApplication, Qt, QTimer, pyqtSlot 18 from PyQt6.QtCore import QCoreApplication, Qt, QTimer, pyqtSlot
18 from PyQt6.QtGui import QIcon 19 from PyQt6.QtGui import QIcon
19 from PyQt6.QtWidgets import ( 20 from PyQt6.QtWidgets import (
452 # better code formatting than pycodestyle.MAX_LINE_LENGTH 453 # better code formatting than pycodestyle.MAX_LINE_LENGTH
453 # see the Black tool 454 # see the Black tool
454 "MaxDocLineLength": 88, 455 "MaxDocLineLength": 88,
455 "BlankLines": (2, 1), # top level, method 456 "BlankLines": (2, 1), # top level, method
456 "HangClosing": False, 457 "HangClosing": False,
457 "NoFixCodes": "E501", 458 "NoFixCodes": "E-501",
458 "DocstringType": "pep257", 459 "DocstringType": "pep257",
459 "ShowIgnored": False, 460 "ShowIgnored": False,
460 # Complexity 461 # Complexity
461 "MaxCodeComplexity": 10, 462 "MaxCodeComplexity": 10,
462 "LineComplexity": 15, 463 "LineComplexity": 15,
795 ) 796 )
796 self.ignoreDunderGlobalsCheckBox.setChecked( 797 self.ignoreDunderGlobalsCheckBox.setChecked(
797 self.__data["UnusedChecker"]["IgnoreDunderGlobals"] 798 self.__data["UnusedChecker"]["IgnoreDunderGlobals"]
798 ) 799 )
799 800
801 self.__migrateIssueCodes()
802
800 def __prepareProgress(self): 803 def __prepareProgress(self):
801 """ 804 """
802 Private method to prepare the progress tab for the next run. 805 Private method to prepare the progress tab for the next run.
803 """ 806 """
804 self.progressList.clear() 807 self.progressList.clear()
878 ] 881 ]
879 882
880 self.__errorItem = None 883 self.__errorItem = None
881 self.__resetStatistics() 884 self.__resetStatistics()
882 self.__clearErrors(self.files) 885 self.__clearErrors(self.files)
886 self.__migrateIssueCodes()
883 self.__prepareProgress() 887 self.__prepareProgress()
884 888
885 # disable updates of the list for speed 889 # disable updates of the list for speed
886 self.resultList.setUpdatesEnabled(False) 890 self.resultList.setUpdatesEnabled(False)
887 self.resultList.setSortingEnabled(False) 891 self.resultList.setSortingEnabled(False)
1371 @pyqtSlot() 1375 @pyqtSlot()
1372 def on_startButton_clicked(self): 1376 def on_startButton_clicked(self):
1373 """ 1377 """
1374 Private slot to start a code style check run. 1378 Private slot to start a code style check run.
1375 """ 1379 """
1380 self.__migrateIssueCodes()
1381
1376 if self.__forProject: 1382 if self.__forProject:
1377 data = { 1383 data = {
1378 "EnabledCheckerCategories": self.__getCategories(True), 1384 "EnabledCheckerCategories": self.__getCategories(True),
1379 "ExcludeFiles": self.excludeFilesEdit.text(), 1385 "ExcludeFiles": self.excludeFilesEdit.text(),
1380 "ExcludeMessages": self.excludeMessagesEdit.text(), 1386 "ExcludeMessages": self.excludeMessagesEdit.text(),
1597 1603
1598 vm = ericApp().getObject("ViewManager") 1604 vm = ericApp().getObject("ViewManager")
1599 vm.openSourceFile(fn, lineno=lineno, pos=position + 1) 1605 vm.openSourceFile(fn, lineno=lineno, pos=position + 1)
1600 editor = vm.getOpenEditor(fn) 1606 editor = vm.getOpenEditor(fn)
1601 1607
1602 if issueCode in ["E901", "E902"]: 1608 if issueCode in ["E-901", "E-902"]:
1603 editor.toggleSyntaxError(lineno, 0, True, message, True) 1609 editor.toggleSyntaxError(lineno, 0, True, message, True)
1604 else: 1610 else:
1605 editor.toggleWarning( 1611 editor.toggleWarning(
1606 lineno, 1612 lineno,
1607 0, 1613 0,
2196 defaultParameters["UnusedChecker"]["IgnoreDunderGlobals"], 2202 defaultParameters["UnusedChecker"]["IgnoreDunderGlobals"],
2197 ) 2203 )
2198 ) 2204 )
2199 ) 2205 )
2200 2206
2207 self.__migrateIssueCodes()
2208
2201 @pyqtSlot() 2209 @pyqtSlot()
2202 def on_storeDefaultButton_clicked(self): 2210 def on_storeDefaultButton_clicked(self):
2203 """ 2211 """
2204 Private slot to store the current configuration values as 2212 Private slot to store the current configuration values as
2205 default values. 2213 default values.
2937 elif includeMessages: 2945 elif includeMessages:
2938 return includeMessages 2946 return includeMessages
2939 else: 2947 else:
2940 return "" 2948 return ""
2941 2949
2950 def __migrateIssueCodes(self):
2951 """
2952 Private method to migrate the issue codes to the form 'category'-'number'.
2953 """
2954 pat = re.compile(r"([A-Z]{1,3}(?!-))(\d{,3}[a-z]*)")
2955 for widget in (
2956 self.excludeMessagesEdit,
2957 self.includeMessagesEdit,
2958 self.fixIssuesEdit,
2959 self.noFixIssuesEdit,
2960 ):
2961 codes = widget.text()
2962 newCodes = pat.sub(r"\1-\2", codes)
2963 widget.setText(newCodes)
2964
2942 def __initCommentedCodeCheckerWhiteList(self, whitelist): 2965 def __initCommentedCodeCheckerWhiteList(self, whitelist):
2943 """ 2966 """
2944 Private method to populate the list of commented code whitelist 2967 Private method to populate the list of commented code whitelist
2945 patterns. 2968 patterns.
2946 2969

eric ide

mercurial