eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

Mon, 12 Apr 2021 18:25:52 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Apr 2021 18:25:52 +0200
changeset 8226
6dc5b1db7bdc
parent 8218
7c09585bd960
child 8246
e4b95b0ebd31
permissions
-rw-r--r--

CodeStyleCheckerDialog: changed code to prevent false report of changed check parameters.

832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7849
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
2980
2cb4e3c50b37 Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2979
diff changeset
7 Module implementing a dialog to show the results of the code style check.
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import fnmatch
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
12 import copy
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
13 import collections
8226
6dc5b1db7bdc CodeStyleCheckerDialog: changed code to prevent false report of changed check parameters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
14 import json
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
16 from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QCoreApplication
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
17 from PyQt5.QtGui import QIcon
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
18 from PyQt5.QtWidgets import (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
19 QDialog, QTreeWidgetItem, QAbstractButton, QDialogButtonBox, QApplication,
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
20 QHeaderView, QListWidgetItem, QInputDialog, QLineEdit
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
21 )
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 from E5Gui.E5Application import e5App
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
2973
284c7f4bc875 Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2972
diff changeset
25 from .Ui_CodeStyleCheckerDialog import Ui_CodeStyleCheckerDialog
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 import UI.PixmapCache
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import Preferences
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 import Utilities
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
5147
d39dd5cee0c8 Renamed pep8.py to pycodestyle.py in order to track the upstream renaming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
31 from . import pycodestyle
2863
62171fa4a6a4 Removed some obsolete code and corrected a PEP8 issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2862
diff changeset
32
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
33 from .Miscellaneous.MiscellaneousDefaults import (
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
34 MiscellaneousCheckerDefaultArgs
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
35 )
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
36
4556
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
37 try:
4563
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4556
diff changeset
38 basestring # __IGNORE_WARNING__
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4556
diff changeset
39 except Exception:
4556
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
40 basestring = str # define for Python3
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
41
2863
62171fa4a6a4 Removed some obsolete code and corrected a PEP8 issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2862
diff changeset
42
2973
284c7f4bc875 Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2972
diff changeset
43 class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
2980
2cb4e3c50b37 Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2979
diff changeset
45 Class implementing a dialog to show the results of the code style check.
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
47 filenameRole = Qt.ItemDataRole.UserRole + 1
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
48 lineRole = Qt.ItemDataRole.UserRole + 2
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
49 positionRole = Qt.ItemDataRole.UserRole + 3
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
50 messageRole = Qt.ItemDataRole.UserRole + 4
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
51 fixableRole = Qt.ItemDataRole.UserRole + 5
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
52 codeRole = Qt.ItemDataRole.UserRole + 6
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
53 ignoredRole = Qt.ItemDataRole.UserRole + 7
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
54 argsRole = Qt.ItemDataRole.UserRole + 8
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
56 availableFutures = [
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
57 'division', 'absolute_import', 'with_statement',
7600
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
58 'print_function', 'unicode_literals', 'generator_stop',
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
59 'annotations']
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
60
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
61 cryptoBitSelectionsDsaRsa = [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
62 "512", "1024", "2048", "4096", "8192", "16384", "32786",
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
63 ]
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
64 cryptoBitSelectionsEc = [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
65 "160", "224", "256", "384", "512",
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
66 ]
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
67
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
68 checkCategories = {
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
69 "A": QCoreApplication.translate(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
70 "CheckerCategories",
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
71 "Annotations"),
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
72 "C": QCoreApplication.translate(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
73 "CheckerCategories",
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
74 "Code Complexity"),
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
75 "D": QCoreApplication.translate(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
76 "CheckerCategories",
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
77 "Documentation"),
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
78 "E": QCoreApplication.translate(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
79 "CheckerCategories",
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
80 "Errors"),
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
81 "M": QCoreApplication.translate(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
82 "CheckerCategories",
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
83 "Miscellaneous"),
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
84 "N": QCoreApplication.translate(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
85 "CheckerCategories",
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
86 "Naming"),
8166
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
87 "P": QCoreApplication.translate(
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
88 "CheckerCategories",
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
89 "'pathlib' Usage"),
7611
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
90 "S": QCoreApplication.translate(
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
91 "CheckerCategories",
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
92 "Security"),
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
93 "W": QCoreApplication.translate(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
94 "CheckerCategories",
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
95 "Warnings"),
8186
655b658aa7ee Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8166
diff changeset
96 "Y": QCoreApplication.translate(
655b658aa7ee Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8166
diff changeset
97 "CheckerCategories",
655b658aa7ee Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8166
diff changeset
98 "Simplify Code"),
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
99 }
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
100
5290
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
101 noResults = 0
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
102 noFiles = 1
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
103 hasResults = 2
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
104
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
105 def __init__(self, styleCheckService, project=None, parent=None):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 Constructor
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
109 @param styleCheckService reference to the service
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
110 @type CodeStyleCheckService
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
111 @param project reference to the project if called on project or project
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
112 browser level
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
113 @type Project
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
114 @param parent reference to the parent widget
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
115 @type QWidget
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8213
diff changeset
117 super().__init__(parent)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.setupUi(self)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
119 self.setWindowFlags(Qt.WindowType.Window)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
121 self.__project = project
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
122
5661
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
123 self.optionsTabWidget.setCurrentIndex(0)
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
124
3186
a05eff845522 Changed all the file or directory selection buttons to QToolButton and gave them an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
125 self.excludeMessagesSelectButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
126 UI.PixmapCache.getIcon("select"))
3186
a05eff845522 Changed all the file or directory selection buttons to QToolButton and gave them an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
127 self.includeMessagesSelectButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
128 UI.PixmapCache.getIcon("select"))
3186
a05eff845522 Changed all the file or directory selection buttons to QToolButton and gave them an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
129 self.fixIssuesSelectButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
130 UI.PixmapCache.getIcon("select"))
3186
a05eff845522 Changed all the file or directory selection buttons to QToolButton and gave them an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
131 self.noFixIssuesSelectButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
132 UI.PixmapCache.getIcon("select"))
3186
a05eff845522 Changed all the file or directory selection buttons to QToolButton and gave them an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
133
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
134 self.docTypeComboBox.addItem(self.tr("PEP-257"), "pep257")
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
135 self.docTypeComboBox.addItem(self.tr("Eric"), "eric")
2928
4f74d3f595ce Started enhancing the docstring checker to include the eric docstring style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2920
diff changeset
136
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
137 for category, text in CodeStyleCheckerDialog.checkCategories.items():
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
138 itm = QListWidgetItem(text, self.categoriesList)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
139 itm.setData(Qt.ItemDataRole.UserRole, category)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
140 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
141 itm.setCheckState(Qt.CheckState.Unchecked)
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
142
5636
709a306baa81 Changed some lists of the style checker to contain checkable items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5625
diff changeset
143 for future in CodeStyleCheckerDialog.availableFutures:
709a306baa81 Changed some lists of the style checker to contain checkable items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5625
diff changeset
144 itm = QListWidgetItem(future, self.futuresList)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
145 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
146 itm.setCheckState(Qt.CheckState.Unchecked)
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
147
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
148 self.dsaHighRiskCombo.addItems(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
149 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
150 self.dsaMediumRiskCombo.addItems(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
151 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
152 self.rsaHighRiskCombo.addItems(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
153 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
154 self.rsaMediumRiskCombo.addItems(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
155 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
156 self.ecHighRiskCombo.addItems(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
157 CodeStyleCheckerDialog.cryptoBitSelectionsEc)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
158 self.ecMediumRiskCombo.addItems(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
159 CodeStyleCheckerDialog.cryptoBitSelectionsEc)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
160
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
161 self.statisticsButton.setEnabled(False)
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
162 self.showButton.setEnabled(False)
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
163 self.cancelButton.setEnabled(True)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
164 self.buttonBox.button(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
165 QDialogButtonBox.StandardButton.Close).setEnabled(False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 self.resultList.headerItem().setText(self.resultList.columnCount(), "")
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
168 self.resultList.header().setSortIndicator(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
169 0, Qt.SortOrder.AscendingOrder)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
171 self.addBuiltinButton.setIcon(UI.PixmapCache.getIcon("plus"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
172 self.deleteBuiltinButton.setIcon(UI.PixmapCache.getIcon("minus"))
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
173 self.addWhitelistButton.setIcon(UI.PixmapCache.getIcon("plus"))
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
174 self.deleteWhitelistButton.setIcon(UI.PixmapCache.getIcon("minus"))
5619
ab999dc48132 Made the built-ins checker configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
175
7600
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
176 self.restartButton.setEnabled(False)
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
177 self.fixButton.setEnabled(False)
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
178
2947
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
179 self.checkProgress.setVisible(False)
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
180 self.checkProgressLabel.setVisible(False)
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
181 self.checkProgressLabel.setMaximumWidth(600)
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
182
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
183 self.styleCheckService = styleCheckService
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
184 self.styleCheckService.styleChecked.connect(self.__processResult)
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
185 self.styleCheckService.batchFinished.connect(self.__batchFinished)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
186 self.styleCheckService.error.connect(self.__processError)
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
187 self.filename = None
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
188
5290
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
189 self.results = CodeStyleCheckerDialog.noResults
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.cancelled = False
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 self.__lastFileItem = None
5289
26e4a082ba54 Avoid exception and be able to close the code style dialog if no file found because of filter settings.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5147
diff changeset
192 self.__batch = False
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
193 self.__finished = True
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
194 self.__errorItem = None
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self.__fileOrFileList = ""
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.__project = None
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.__forProject = False
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.__data = {}
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
200 self.__statistics = collections.defaultdict(self.__defaultStatistics)
3746
0c1d19eb0ac6 Wrong behavior if more than one file for code style fixes selected fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3656
diff changeset
201 self.__onlyFixes = {}
4437
b9cc331a4576 Some little fixes to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4434
diff changeset
202 self.__noFixCodesList = []
8199
f6db89b067e7 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8195
diff changeset
203 self.__detectedCodes = []
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.on_loadDefaultButton_clicked()
7600
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
206
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
207 self.mainWidget.setCurrentWidget(self.configureTab)
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
208 self.optionsTabWidget.setCurrentWidget(self.globalOptionsTab)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
210 def __defaultStatistics(self):
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
211 """
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
212 Private method to return the default statistics entry.
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
213
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
214 @return dictionary with default statistics entry
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
215 @rtype dict
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
216 """
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
217 return {
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
218 "total": 0,
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
219 "ignored": 0,
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
220 }
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
221
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 def __resort(self):
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 Private method to resort the tree.
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
226 self.resultList.sortItems(self.resultList.sortColumn(),
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 self.resultList.header().sortIndicatorOrder()
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
228 )
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
230 def __createErrorItem(self, filename, message):
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
231 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
232 Private slot to create a new error item in the result list.
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
233
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
234 @param filename name of the file
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
235 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
236 @param message error message
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
237 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
238 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
239 if self.__errorItem is None:
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
240 self.__errorItem = QTreeWidgetItem(self.resultList, [
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
241 self.tr("Errors")])
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
242 self.__errorItem.setExpanded(True)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
243 self.__errorItem.setForeground(0, Qt.GlobalColor.red)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
244
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
245 msg = "{0} ({1})".format(self.__project.getRelativePath(filename),
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
246 message)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
247 if not self.resultList.findItems(msg, Qt.MatchFlag.MatchExactly):
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
248 itm = QTreeWidgetItem(self.__errorItem, [msg])
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
249 itm.setForeground(0, Qt.GlobalColor.red)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
250 itm.setFirstColumnSpanned(True)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
251
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
252 def __createFileErrorItem(self, filename, message):
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
253 """
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
254 Private method to create an error entry for a given file.
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
255
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
256 @param filename file name of the file
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
257 @type str
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
258 @param message error message text
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
259 @type str
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
260 """
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
261 result = {
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
262 "file": filename,
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
263 "line": 1,
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
264 "offset": 1,
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
265 "code": "",
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
266 "args": [],
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
267 "display": self.tr("Error: {0}").format(message).rstrip(),
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
268 "fixed": False,
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
269 "autofixing": False,
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
270 "ignored": False,
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
271 }
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
272 self.__createResultItem(filename, result)
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
273
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
274 def __createResultItem(self, filename, result):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 Private method to create an entry in the result list.
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
278 @param filename file name of the file
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
279 @type str
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
280 @param result dictionary containing check result data
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
281 @type dict
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
282 @return reference to the created item
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
283 @rtype QTreeWidgetItem
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 """
2978
9d63132a23e0 Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2973
diff changeset
285 from .CodeStyleFixer import FixableCodeStyleIssues
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
286
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 if self.__lastFileItem is None:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 # It's a new file
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
289 self.__lastFileItem = QTreeWidgetItem(self.resultList, [
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
290 self.__project.getRelativePath(filename)])
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 self.__lastFileItem.setFirstColumnSpanned(True)
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.__lastFileItem.setExpanded(True)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
293 self.__lastFileItem.setData(0, self.filenameRole, filename)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
295 msgCode = result["code"].split(".", 1)[0]
8199
f6db89b067e7 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8195
diff changeset
296 self.__detectedCodes.append(msgCode)
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
297
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
298 fixable = False
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
299 itm = QTreeWidgetItem(
7614
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
300 self.__lastFileItem, [
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
301 "{0:6}".format(result["line"]),
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
302 msgCode,
7614
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
303 result["display"]
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
304 ]
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
305 )
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
306 if msgCode.startswith(("W", "-", "C", "M")):
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
307 itm.setIcon(1, UI.PixmapCache.getIcon("warning"))
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
308 elif msgCode.startswith(("A", "N")):
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
309 itm.setIcon(1, UI.PixmapCache.getIcon("namingError"))
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
310 elif msgCode.startswith("D"):
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
311 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError"))
8166
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
312 elif msgCode.startswith("P"):
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
313 itm.setIcon(1, UI.PixmapCache.getIcon("dirClosed"))
8188
bfa6c0969acf Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8186
diff changeset
314 elif msgCode.startswith("Y"):
bfa6c0969acf Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8186
diff changeset
315 itm.setIcon(1, UI.PixmapCache.getIcon("filePython"))
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
316 elif msgCode.startswith("S"):
7611
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
317 if "severity" in result:
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
318 if result["severity"] == "H":
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
319 itm.setIcon(1, UI.PixmapCache.getIcon("securityLow"))
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
320 elif result["severity"] == "M":
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
321 itm.setIcon(1, UI.PixmapCache.getIcon("securityMedium"))
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
322 elif result["severity"] == "L":
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
323 itm.setIcon(1, UI.PixmapCache.getIcon("securityHigh"))
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
324 else:
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
325 itm.setIcon(1, UI.PixmapCache.getIcon("securityLow"))
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
326 else:
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
327 itm.setIcon(1, UI.PixmapCache.getIcon("securityLow"))
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 else:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
329 itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError"))
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
330 if result["fixed"]:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
331 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed"))
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
332 elif (
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
333 msgCode in FixableCodeStyleIssues and
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
334 not result["autofixing"] and
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
335 msgCode not in self.__noFixCodesList
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
336 ):
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
337 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable"))
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
338 fixable = True
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
339
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
340 itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
341 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignHCenter)
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
342
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
343 itm.setTextAlignment(0, Qt.AlignmentFlag.AlignVCenter)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
344 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignVCenter)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
345 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignVCenter)
853
ec7dd115e26b Continued implementing a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 849
diff changeset
346
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
347 itm.setData(0, self.filenameRole, filename)
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
348 itm.setData(0, self.lineRole, int(result["line"]))
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
349 itm.setData(0, self.positionRole, int(result["offset"]))
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
350 itm.setData(0, self.messageRole, result["display"])
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
351 itm.setData(0, self.fixableRole, fixable)
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
352 itm.setData(0, self.codeRole, msgCode)
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
353 itm.setData(0, self.ignoredRole, result["ignored"])
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
354 itm.setData(0, self.argsRole, result["args"])
3489
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
355
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
356 if result["ignored"]:
3489
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
357 font = itm.font(0)
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
358 font.setItalic(True)
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
359 for col in range(itm.columnCount()):
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
360 itm.setFont(col, font)
2891
6843b7d23279 Changed the PEP-8 fixer and dialog to decouple the indication of the fixed status from the generation of the PEP-8 status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2890
diff changeset
361
6843b7d23279 Changed the PEP-8 fixer and dialog to decouple the indication of the fixed status from the generation of the PEP-8 status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2890
diff changeset
362 return itm
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
363
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
364 def __modifyFixedResultItem(self, itm, result):
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
365 """
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
366 Private method to modify a result list entry to show its
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
367 positive fixed state.
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
368
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
369 @param itm reference to the item to modify
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
370 @type QTreeWidgetItem
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
371 @param result dictionary containing check result data
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
372 @type dict
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
373 """
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
374 if result["fixed"]:
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
375 itm.setText(2, result["display"])
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
376 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed"))
2890
86b03a0c94bc Started modifying PEP-8 dialog to change fixable state if a fixable issue could not be fixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2881
diff changeset
377
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
378 itm.setData(0, self.messageRole, result["display"])
2890
86b03a0c94bc Started modifying PEP-8 dialog to change fixable state if a fixable issue could not be fixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2881
diff changeset
379 else:
86b03a0c94bc Started modifying PEP-8 dialog to change fixable state if a fixable issue could not be fixed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2881
diff changeset
380 itm.setIcon(0, QIcon())
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
381 itm.setData(0, self.fixableRole, False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
383 def __updateStatistics(self, statistics, fixer, ignoredErrors, securityOk):
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
384 """
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
385 Private method to update the collected statistics.
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
386
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
387 @param statistics dictionary of statistical data with
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
388 message code as key and message count as value
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
389 @type dict
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
390 @param fixer reference to the code style fixer
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
391 @type CodeStyleFixer
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
392 @param ignoredErrors number of ignored errors
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
393 @type int
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
394 @param securityOk number of acknowledged security reports
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
395 @type int
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
396 """
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
397 self.__statistics["_FilesCount"] += 1
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
398 stats = [k for k in statistics if k[0].isupper()]
2914
6b30a602e404 Fixed an issue in the code style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2905
diff changeset
399 if stats:
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
400 self.__statistics["_FilesIssues"] += 1
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
401 for key in stats:
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
402 self.__statistics[key]["total"] += statistics[key]
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
403 for key in ignoredErrors:
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
404 self.__statistics[key]["ignored"] += ignoredErrors[key]
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
405 self.__statistics["_IssuesFixed"] += fixer
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
406 self.__statistics["_SecurityOK"] += securityOk
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
407
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
408 def __updateFixerStatistics(self, fixer):
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
409 """
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
410 Private method to update the collected fixer related statistics.
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
411
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
412 @param fixer reference to the code style fixer
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
413 @type CodeStyleFixer
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
414 """
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
415 self.__statistics["_IssuesFixed"] += fixer
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
416
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
417 def __resetStatistics(self):
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
418 """
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
419 Private slot to reset the statistics data.
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
420 """
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
421 self.__statistics.clear()
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
422 self.__statistics["_FilesCount"] = 0
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
423 self.__statistics["_FilesIssues"] = 0
853
ec7dd115e26b Continued implementing a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 849
diff changeset
424 self.__statistics["_IssuesFixed"] = 0
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
425 self.__statistics["_SecurityOK"] = 0
847
cc18fbcde9fc Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 843
diff changeset
426
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 def prepare(self, fileList, project):
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 Public method to prepare the dialog with a list of filenames.
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
431 @param fileList list of filenames
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
432 @type list of str
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
433 @param project reference to the project object
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
434 @type Project
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 self.__fileOrFileList = fileList[:]
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 self.__project = project
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.__forProject = True
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
440 self.buttonBox.button(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
441 QDialogButtonBox.StandardButton.Close).setEnabled(True)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
442 self.buttonBox.button(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
443 QDialogButtonBox.StandardButton.Close).setDefault(True)
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
444 self.cancelButton.setEnabled(False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 self.__data = self.__project.getData("CHECKERSPARMS", "Pep8Checker")
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
447 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
448 self.__data is None or
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
449 len(self.__data) < 6
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
450 ):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 # initialize the data structure
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 self.__data = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
453 "ExcludeFiles": "",
5147
d39dd5cee0c8 Renamed pep8.py to pycodestyle.py in order to track the upstream renaming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
454 "ExcludeMessages": pycodestyle.DEFAULT_IGNORE,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
455 "IncludeMessages": "",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
456 "RepeatMessages": False,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
457 "FixCodes": "",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
458 "FixIssues": False,
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 }
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
460 if "EnabledCheckerCategories" not in self.__data:
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
461 self.__data["EnabledCheckerCategories"] = ",".join(
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
462 CodeStyleCheckerDialog.checkCategories.keys())
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
463 if "MaxLineLength" not in self.__data:
5147
d39dd5cee0c8 Renamed pep8.py to pycodestyle.py in order to track the upstream renaming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
464 self.__data["MaxLineLength"] = pycodestyle.MAX_LINE_LENGTH
6786
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
465 if "MaxDocLineLength" not in self.__data:
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
466 # Use MAX_LINE_LENGTH to avoid messages on existing code
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
467 self.__data["MaxDocLineLength"] = pycodestyle.MAX_LINE_LENGTH
6264
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
468 if "BlankLines" not in self.__data:
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
469 self.__data["BlankLines"] = (2, 1)
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
470 # top level, method
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
471 if "HangClosing" not in self.__data:
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
472 self.__data["HangClosing"] = False
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
473 if "NoFixCodes" not in self.__data:
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
474 self.__data["NoFixCodes"] = "E501"
2928
4f74d3f595ce Started enhancing the docstring checker to include the eric docstring style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2920
diff changeset
475 if "DocstringType" not in self.__data:
4f74d3f595ce Started enhancing the docstring checker to include the eric docstring style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2920
diff changeset
476 self.__data["DocstringType"] = "pep257"
3489
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
477 if "ShowIgnored" not in self.__data:
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
478 self.__data["ShowIgnored"] = False
4423
14f3ca3dcef6 Added a code complexity checker iaw. McCabe to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4278
diff changeset
479 if "MaxCodeComplexity" not in self.__data:
14f3ca3dcef6 Added a code complexity checker iaw. McCabe to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4278
diff changeset
480 self.__data["MaxCodeComplexity"] = 10
5661
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
481 if "LineComplexity" not in self.__data:
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
482 self.__data["LineComplexity"] = 15
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
483 if "LineComplexityScore" not in self.__data:
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
484 self.__data["LineComplexityScore"] = 10
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
485 if "ValidEncodings" not in self.__data:
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
486 self.__data["ValidEncodings"] = (
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
487 MiscellaneousCheckerDefaultArgs["CodingChecker"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
488 )
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
489 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
490 "CopyrightMinFileSize" not in self.__data or
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
491 "CopyrightAuthor" not in self.__data
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
492 ):
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
493 self.__data["CopyrightMinFileSize"] = (
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
494 MiscellaneousCheckerDefaultArgs[
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
495 "CopyrightChecker"]["MinFilesize"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
496 )
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
497 self.__data["CopyrightAuthor"] = (
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
498 MiscellaneousCheckerDefaultArgs["CopyrightChecker"]["Author"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
499 )
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
500 if "FutureChecker" not in self.__data:
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
501 self.__data["FutureChecker"] = ""
5619
ab999dc48132 Made the built-ins checker configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
502 if "BuiltinsChecker" not in self.__data:
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
503 self.__data["BuiltinsChecker"] = copy.deepcopy(
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
504 MiscellaneousCheckerDefaultArgs["BuiltinsChecker"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
505 )
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
506
7040
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
507 if "CommentedCodeChecker" not in self.__data:
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
508 self.__data["CommentedCodeChecker"] = copy.deepcopy(
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
509 MiscellaneousCheckerDefaultArgs["CommentedCodeChecker"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
510 )
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
511 if "WhiteList" not in self.__data["CommentedCodeChecker"]:
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
512 self.__data["CommentedCodeChecker"]["WhiteList"] = (
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
513 MiscellaneousCheckerDefaultArgs[
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
514 "CommentedCodeChecker"]["WhiteList"][:]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
515 )
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
516
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
517 if "AnnotationsChecker" not in self.__data:
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
518 self.__data["AnnotationsChecker"] = {
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
519 "MinimumCoverage": 75,
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
520 "MaximumComplexity": 3,
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
521 }
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
522
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
523 if "SecurityChecker" not in self.__data:
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
524 from .Security.SecurityDefaults import SecurityDefaults
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
525 self.__data["SecurityChecker"] = {
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
526 "HardcodedTmpDirectories":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
527 SecurityDefaults["hardcoded_tmp_directories"],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
528 "InsecureHashes":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
529 SecurityDefaults["insecure_hashes"],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
530 "InsecureSslProtocolVersions":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
531 SecurityDefaults["insecure_ssl_protocol_versions"],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
532 "WeakKeySizeDsaHigh":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
533 str(SecurityDefaults["weak_key_size_dsa_high"]),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
534 "WeakKeySizeDsaMedium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
535 str(SecurityDefaults["weak_key_size_dsa_medium"]),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
536 "WeakKeySizeRsaHigh":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
537 str(SecurityDefaults["weak_key_size_rsa_high"]),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
538 "WeakKeySizeRsaMedium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
539 str(SecurityDefaults["weak_key_size_rsa_medium"]),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
540 "WeakKeySizeEcHigh":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
541 str(SecurityDefaults["weak_key_size_ec_high"]),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
542 "WeakKeySizeEcMedium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
543 str(SecurityDefaults["weak_key_size_ec_medium"]),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
544 "CheckTypedException":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
545 SecurityDefaults["check_typed_exception"],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
546 }
7614
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
547
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
548 self.__initCategoriesList(self.__data["EnabledCheckerCategories"])
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"])
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"])
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 self.includeMessagesEdit.setText(self.__data["IncludeMessages"])
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 self.repeatCheckBox.setChecked(self.__data["RepeatMessages"])
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 847
diff changeset
553 self.fixIssuesEdit.setText(self.__data["FixCodes"])
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
554 self.noFixIssuesEdit.setText(self.__data["NoFixCodes"])
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 847
diff changeset
555 self.fixIssuesCheckBox.setChecked(self.__data["FixIssues"])
3489
9c5af34205c9 Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
556 self.ignoredCheckBox.setChecked(self.__data["ShowIgnored"])
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
557 self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"])
6786
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
558 self.docLineLengthSpinBox.setValue(self.__data["MaxDocLineLength"])
6264
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
559 self.blankBeforeTopLevelSpinBox.setValue(self.__data["BlankLines"][0])
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
560 self.blankBeforeMethodSpinBox.setValue(self.__data["BlankLines"][1])
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
561 self.hangClosingCheckBox.setChecked(self.__data["HangClosing"])
2928
4f74d3f595ce Started enhancing the docstring checker to include the eric docstring style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2920
diff changeset
562 self.docTypeComboBox.setCurrentIndex(
4f74d3f595ce Started enhancing the docstring checker to include the eric docstring style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2920
diff changeset
563 self.docTypeComboBox.findData(self.__data["DocstringType"]))
4423
14f3ca3dcef6 Added a code complexity checker iaw. McCabe to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4278
diff changeset
564 self.complexitySpinBox.setValue(self.__data["MaxCodeComplexity"])
5661
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
565 self.lineComplexitySpinBox.setValue(self.__data["LineComplexity"])
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
566 self.lineComplexityScoreSpinBox.setValue(
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
567 self.__data["LineComplexityScore"])
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
568 self.encodingsEdit.setText(self.__data["ValidEncodings"])
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
569 self.copyrightFileSizeSpinBox.setValue(
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
570 self.__data["CopyrightMinFileSize"])
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
571 self.copyrightAuthorEdit.setText(self.__data["CopyrightAuthor"])
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
572 self.__initFuturesList(self.__data["FutureChecker"])
5619
ab999dc48132 Made the built-ins checker configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
573 self.__initBuiltinsIgnoreList(self.__data["BuiltinsChecker"])
7040
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
574 self.aggressiveCheckBox.setChecked(
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
575 self.__data["CommentedCodeChecker"]["Aggressive"])
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
576 self.__initCommentedCodeCheckerWhiteList(
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
577 self.__data["CommentedCodeChecker"]["WhiteList"])
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
578 self.minAnnotationsCoverageSpinBox.setValue(
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
579 self.__data["AnnotationsChecker"]["MinimumCoverage"])
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
580 self.maxAnnotationsComplexitySpinBox.setValue(
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
581 self.__data["AnnotationsChecker"]["MaximumComplexity"])
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
582
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
583 # security
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
584 self.tmpDirectoriesEdit.setPlainText("\n".join(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
585 self.__data["SecurityChecker"]["HardcodedTmpDirectories"]))
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
586 self.hashesEdit.setText(", ".join(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
587 self.__data["SecurityChecker"]["InsecureHashes"]))
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
588 self.insecureSslProtocolsEdit.setPlainText("\n".join(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
589 self.__data["SecurityChecker"]["InsecureSslProtocolVersions"]))
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
590 self.dsaHighRiskCombo.setCurrentText(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
591 self.__data["SecurityChecker"]["WeakKeySizeDsaHigh"])
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
592 self.dsaMediumRiskCombo.setCurrentText(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
593 self.__data["SecurityChecker"]["WeakKeySizeDsaMedium"])
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
594 self.rsaHighRiskCombo.setCurrentText(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
595 self.__data["SecurityChecker"]["WeakKeySizeRsaHigh"])
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
596 self.rsaMediumRiskCombo.setCurrentText(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
597 self.__data["SecurityChecker"]["WeakKeySizeRsaMedium"])
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
598 self.ecHighRiskCombo.setCurrentText(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
599 self.__data["SecurityChecker"]["WeakKeySizeEcHigh"])
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
600 self.ecMediumRiskCombo.setCurrentText(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
601 self.__data["SecurityChecker"]["WeakKeySizeEcMedium"])
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
602 self.typedExceptionsCheckBox.setChecked(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
603 self.__data["SecurityChecker"]["CheckTypedException"])
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
604
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
605 self.__cleanupData()
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
607 def __prepareProgress(self):
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
608 """
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
609 Private method to prepare the progress tab for the next run.
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
610 """
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
611 self.progressList.clear()
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
612 if len(self.files) > 0:
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
613 self.checkProgress.setMaximum(len(self.files))
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
614 self.checkProgressLabel.setVisible(len(self.files) > 1)
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
615 self.checkProgress.setVisible(len(self.files) > 1)
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
616 if len(self.files) > 1:
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
617 if self.__project:
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
618 self.progressList.addItems([
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
619 os.path.join("...", self.__project.getRelativePath(f))
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
620 for f in self.files
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
621 ])
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
622 else:
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
623 self.progressList.addItems(self.files)
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
624
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
625 QApplication.processEvents()
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
626
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
627 def start(self, fn, save=False, repeat=None):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 """
2980
2cb4e3c50b37 Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2979
diff changeset
629 Public slot to start the code style check.
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 @param fn file or list of files or directory to be checked
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
632 @type str or list of str
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
633 @param save flag indicating to save the given file/file list/directory
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
634 @type bool
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
635 @param repeat state of the repeat check box if it is not None
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
636 @type None or bool
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 if self.__project is None:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 self.__project = e5App().getObject("Project")
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
641 self.mainWidget.setCurrentWidget(self.progressTab)
7600
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
642
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 self.cancelled = False
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
644 self.buttonBox.button(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7980
diff changeset
645 QDialogButtonBox.StandardButton.Close).setEnabled(False)
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
646 self.cancelButton.setEnabled(True)
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
647 self.cancelButton.setDefault(True)
940
0f5461fe69d4 Implemented some speed improvements for the PEP 8 checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 853
diff changeset
648 self.statisticsButton.setEnabled(False)
0f5461fe69d4 Implemented some speed improvements for the PEP 8 checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 853
diff changeset
649 self.showButton.setEnabled(False)
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
650 self.fixButton.setEnabled(False)
2902
15a5fe0b0a09 Changed PEP-8 dialog code to disable the the start button while a check is in progress.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2895
diff changeset
651 self.startButton.setEnabled(False)
7600
d2bf0476484b CodeStyleCheckerDialog: changed the dialog layout to get more space for the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
652 self.restartButton.setEnabled(False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 if repeat is not None:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 self.repeatCheckBox.setChecked(repeat)
2947
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
655 self.checkProgress.setVisible(True)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 QApplication.processEvents()
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 if save:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 self.__fileOrFileList = fn
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 if isinstance(fn, list):
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
662 self.files = fn[:]
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 elif os.path.isdir(fn):
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
664 self.files = []
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7632
diff changeset
665 extensions = set(Preferences.getPython("Python3Extensions"))
2607
e5115553185a Fixes and consolidation for PEP8-checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
666 for ext in extensions:
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
667 self.files.extend(Utilities.direntries(
3065
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
668 fn, True, '*{0}'.format(ext), 0))
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 else:
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
670 self.files = [fn]
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
671
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 # filter the list depending on the filter string
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
673 if self.files:
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 filterString = self.excludeFilesEdit.text()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
675 filterList = [f.strip() for f in filterString.split(",")
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 if f.strip()]
5597
3d88d53f8c2b Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
677 for fileFilter in filterList:
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
678 self.files = [
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
679 f for f in self.files
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
680 if not fnmatch.fnmatch(f, fileFilter.strip())
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
681 ]
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
682
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
683 self.__errorItem = None
3175
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
684 self.__resetStatistics()
3456
96232974dcdb Merge with BgService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3178 3413
diff changeset
685 self.__clearErrors(self.files)
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
686 self.__cleanupData()
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
687 self.__prepareProgress()
3175
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
688
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
689 if len(self.files) > 0:
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
690 self.securityNoteLabel.setVisible(
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
691 "S" in self.__getCategories(True, asList=True))
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 # extract the configuration values
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
694 excludeMessages = self.__assembleExcludeMessages()
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 includeMessages = self.includeMessagesEdit.text()
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 repeatMessages = self.repeatCheckBox.isChecked()
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 847
diff changeset
697 fixCodes = self.fixIssuesEdit.text()
2876
bfa39cf40277 Extended the PEP-8 dialog to select fixable issues manually (i.e. fix only the selected issues).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2874
diff changeset
698 noFixCodes = self.noFixIssuesEdit.text()
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
699 self.__noFixCodesList = [
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
700 c.strip() for c in noFixCodes.split(",") if c.strip()
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
701 ]
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 847
diff changeset
702 fixIssues = self.fixIssuesCheckBox.isChecked() and repeatMessages
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
703 self.showIgnored = (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
704 self.ignoredCheckBox.isChecked() and repeatMessages
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
705 )
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
706 maxLineLength = self.lineLengthSpinBox.value()
6786
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
707 maxDocLineLength = self.docLineLengthSpinBox.value()
6264
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
708 blankLines = (
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
709 self.blankBeforeTopLevelSpinBox.value(),
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
710 self.blankBeforeMethodSpinBox.value()
04a671fa4adb code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
711 )
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
712 hangClosing = self.hangClosingCheckBox.isChecked()
2928
4f74d3f595ce Started enhancing the docstring checker to include the eric docstring style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2920
diff changeset
713 docType = self.docTypeComboBox.itemData(
4f74d3f595ce Started enhancing the docstring checker to include the eric docstring style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2920
diff changeset
714 self.docTypeComboBox.currentIndex())
5661
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
715 codeComplexityArgs = {
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
716 "McCabeComplexity": self.complexitySpinBox.value(),
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
717 "LineComplexity": self.lineComplexitySpinBox.value(),
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
718 "LineComplexityScore": self.lineComplexityScoreSpinBox.value(),
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
719 }
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
720 miscellaneousArgs = {
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
721 "CodingChecker": self.encodingsEdit.text(),
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
722 "CopyrightChecker": {
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
723 "MinFilesize": self.copyrightFileSizeSpinBox.value(),
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
724 "Author": self.copyrightAuthorEdit.text(),
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
725 },
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
726 "FutureChecker": self.__getSelectedFutureImports(),
5619
ab999dc48132 Made the built-ins checker configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
727 "BuiltinsChecker": self.__getBuiltinsIgnoreList(),
7040
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
728 "CommentedCodeChecker": {
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
729 "Aggressive": self.aggressiveCheckBox.isChecked(),
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
730 "WhiteList": self.__getCommentedCodeCheckerWhiteList(),
7040
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
731 }
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
732 }
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
733 annotationArgs = {
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
734 "MinimumCoverage":
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
735 self.minAnnotationsCoverageSpinBox.value(),
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
736 "MaximumComplexity":
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
737 self.maxAnnotationsComplexitySpinBox.value(),
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
738 }
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
740 securityArgs = {
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
741 "hardcoded_tmp_directories": [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
742 t.strip()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
743 for t in self.tmpDirectoriesEdit.toPlainText().splitlines()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
744 ],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
745 "insecure_hashes": [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
746 h.strip()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
747 for h in self.hashesEdit.text().split(",")
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
748 ],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
749 "insecure_ssl_protocol_versions": [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
750 p.strip()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
751 for p in self.insecureSslProtocolsEdit.toPlainText()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
752 .splitlines()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
753 ],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
754 "weak_key_size_dsa_high":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
755 int(self.dsaHighRiskCombo.currentText()),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
756 "weak_key_size_dsa_medium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
757 int(self.dsaMediumRiskCombo.currentText()),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
758 "weak_key_size_rsa_high":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
759 int(self.rsaHighRiskCombo.currentText()),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
760 "weak_key_size_rsa_medium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
761 int(self.rsaMediumRiskCombo.currentText()),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
762 "weak_key_size_ec_high":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
763 int(self.ecHighRiskCombo.currentText()),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
764 "weak_key_size_ec_medium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
765 int(self.ecMediumRiskCombo.currentText()),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
766 "check_typed_exception":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
767 self.typedExceptionsCheckBox.isChecked(),
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
768 }
7611
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
769
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
770 self.__options = [excludeMessages, includeMessages, repeatMessages,
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
771 fixCodes, noFixCodes, fixIssues, maxLineLength,
6786
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
772 maxDocLineLength, blankLines, hangClosing,
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
773 docType, codeComplexityArgs, miscellaneousArgs,
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
774 annotationArgs, securityArgs]
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
775
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
776 # now go through all the files
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
777 self.progress = 0
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
778 self.files.sort()
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
779 if len(self.files) == 1:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
780 self.__batch = False
7631
2c7ccb4484bf Code Style Checker: extended the dialog to show a list of files still to be checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7619
diff changeset
781 self.mainWidget.setCurrentWidget(self.resultsTab)
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
782 self.check()
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
783 else:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
784 self.__batch = True
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
785 self.checkBatch()
5289
26e4a082ba54 Avoid exception and be able to close the code style dialog if no file found because of filter settings.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5147
diff changeset
786 else:
5290
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
787 self.results = CodeStyleCheckerDialog.noFiles
5289
26e4a082ba54 Avoid exception and be able to close the code style dialog if no file found because of filter settings.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5147
diff changeset
788 self.__finished = False
26e4a082ba54 Avoid exception and be able to close the code style dialog if no file found because of filter settings.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5147
diff changeset
789 self.__finish()
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
790
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
791 def __modifyOptions(self, source):
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
792 """
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
793 Private method to modify the options based on eflag: entries.
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
794
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
795 This method looks for comment lines like '# eflag: noqa = M601'
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
796 at the end of the source in order to extend the list of excluded
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
797 messages for one file only.
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
798
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
799 @param source source text
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
800 @type list of str or str
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
801 @return list of checker options
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
802 @rtype list
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
803 """
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
804 options = self.__options[:]
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
805 flags = Utilities.extractFlags(source)
4556
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
806 if "noqa" in flags and isinstance(flags["noqa"], basestring):
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
807 excludeMessages = options[0].strip().rstrip(",")
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
808 if excludeMessages:
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
809 excludeMessages += ","
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
810 excludeMessages += flags["noqa"]
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
811 options[0] = excludeMessages
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
812 return options
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
813
3746
0c1d19eb0ac6 Wrong behavior if more than one file for code style fixes selected fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3656
diff changeset
814 def check(self, codestring=''):
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
815 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3558
diff changeset
816 Public method to start a style check for one file.
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
817
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
818 The results are reported to the __processResult slot.
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3549
diff changeset
819
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
820 @param codestring optional sourcestring
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7600
diff changeset
821 @type str
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
822 """
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
823 if not self.files:
2947
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
824 self.checkProgressLabel.setPath("")
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 self.checkProgress.setMaximum(1)
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 self.checkProgress.setValue(1)
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
827 self.__finish()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
828 return
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
829
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
830 self.filename = self.files.pop(0)
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
831 self.checkProgress.setValue(self.progress)
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
832 self.checkProgressLabel.setPath(self.filename)
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
833 QApplication.processEvents()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
834
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
835 if self.cancelled:
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
836 self.__resort()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
837 return
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
838
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
839 self.__lastFileItem = None
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
840
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
841 if codestring:
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
842 source = codestring.splitlines(True)
4217
38e8903f9c2f Fixed two little issue that could lead to a traceback in the code style checker dialog and Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
843 encoding = Utilities.get_coding(source)
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
844 else:
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
845 try:
4217
38e8903f9c2f Fixed two little issue that could lead to a traceback in the code style checker dialog and Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
846 source, encoding = Utilities.readEncodedFile(
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
847 self.filename)
4217
38e8903f9c2f Fixed two little issue that could lead to a traceback in the code style checker dialog and Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
848 source = source.splitlines(True)
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
849 except (UnicodeError, OSError) as msg:
5290
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
850 self.results = CodeStyleCheckerDialog.hasResults
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
851 self.__createFileErrorItem(self.filename, str(msg))
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
852 self.progress += 1
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
853 # Continue with next file
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
854 self.check()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
855 return
4217
38e8903f9c2f Fixed two little issue that could lead to a traceback in the code style checker dialog and Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
856 if encoding.endswith(
38e8903f9c2f Fixed two little issue that could lead to a traceback in the code style checker dialog and Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
857 ('-selected', '-default', '-guessed', '-ignore')):
38e8903f9c2f Fixed two little issue that could lead to a traceback in the code style checker dialog and Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
858 encoding = encoding.rsplit('-', 1)[0]
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
859
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
860 options = self.__modifyOptions(source)
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
861
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
862 errors = []
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
863 self.__itms = []
3746
0c1d19eb0ac6 Wrong behavior if more than one file for code style fixes selected fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3656
diff changeset
864 for error, itm in self.__onlyFixes.pop(self.filename, []):
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
865 errors.append(error)
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
866 self.__itms.append(itm)
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
867
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
868 eol = self.__getEol(self.filename)
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4509
diff changeset
869 args = options + [
3549
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
870 errors, eol, encoding, Preferences.getEditor("CreateBackupFile")
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
871 ]
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
872 self.__finished = False
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
873 self.styleCheckService.styleCheck(
4217
38e8903f9c2f Fixed two little issue that could lead to a traceback in the code style checker dialog and Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
874 None, self.filename, source, args)
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
875
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
876 def checkBatch(self):
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
877 """
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
878 Public method to start a style check batch job.
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
879
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
880 The results are reported to the __processResult slot.
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
881 """
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
882 self.__lastFileItem = None
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
883
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
884 self.checkProgressLabel.setPath(self.tr("Preparing files..."))
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
885
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
886 argumentsList = []
8213
4cdfe4fbdd26 CodeStyleCheckerDialog: fixed an issue causing some messages being supressed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8206
diff changeset
887 for progress, filename in enumerate(self.files, start=1):
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
888 self.checkProgress.setValue(progress)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
889 QApplication.processEvents()
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
890
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
891 try:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
892 source, encoding = Utilities.readEncodedFile(
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
893 filename)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
894 source = source.splitlines(True)
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
895 except (UnicodeError, OSError) as msg:
5290
174dae2b91c3 Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5289
diff changeset
896 self.results = CodeStyleCheckerDialog.hasResults
7610
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
897 self.__createFileErrorItem(filename, str(msg))
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
898 continue
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
899
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
900 if encoding.endswith(
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
901 ('-selected', '-default', '-guessed', '-ignore')):
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4217
diff changeset
902 encoding = encoding.rsplit('-', 1)[0]
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach&#