eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

Sat, 10 Apr 2021 16:12:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 10 Apr 2021 16:12:29 +0200
changeset 8213
4cdfe4fbdd26
parent 8206
adf11836cfce
child 8218
7c09585bd960
permissions
-rw-r--r--

CodeStyleCheckerDialog: fixed an issue causing some messages being supressed.

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
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
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
15 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
16 from PyQt5.QtGui import QIcon
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
17 from PyQt5.QtWidgets import (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
18 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
19 QHeaderView, QListWidgetItem, QInputDialog, QLineEdit
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
20 )
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from E5Gui.E5Application import e5App
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
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
24 from .Ui_CodeStyleCheckerDialog import Ui_CodeStyleCheckerDialog
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 import UI.PixmapCache
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 import Preferences
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import Utilities
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
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
30 from . import pycodestyle
2863
62171fa4a6a4 Removed some obsolete code and corrected a PEP8 issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2862
diff changeset
31
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
32 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
33 MiscellaneousCheckerDefaultArgs
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
34 )
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
35
4556
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
36 try:
4563
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4556
diff changeset
37 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
38 except Exception:
4556
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
39 basestring = str # define for Python3
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
40
2863
62171fa4a6a4 Removed some obsolete code and corrected a PEP8 issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2862
diff changeset
41
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
42 class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
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
44 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
45 """
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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 argsRole = Qt.ItemDataRole.UserRole + 8
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
55 availableFutures = [
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
56 '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
57 '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
58 'annotations']
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
59
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
60 cryptoBitSelectionsDsaRsa = [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
61 "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
62 ]
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
63 cryptoBitSelectionsEc = [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
64 "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
65 ]
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
66
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
67 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
68 "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
69 "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
70 "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
71 "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
72 "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
73 "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
74 "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
75 "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
76 "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
77 "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
78 "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
79 "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
80 "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
81 "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
82 "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
83 "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
84 "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
85 "Naming"),
8166
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
86 "P": QCoreApplication.translate(
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
87 "CheckerCategories",
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
88 "'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
89 "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
90 "CheckerCategories",
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
91 "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
92 "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
93 "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
94 "Warnings"),
8186
655b658aa7ee Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8166
diff changeset
95 "Y": QCoreApplication.translate(
655b658aa7ee Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8166
diff changeset
96 "CheckerCategories",
655b658aa7ee Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8166
diff changeset
97 "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
98 }
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
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
100 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
101 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
102 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
103
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
104 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
105 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Constructor
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
108 @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
109 @type CodeStyleCheckService
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
110 @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
111 browser level
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
112 @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
113 @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
114 @type QWidget
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
3057
10516539f238 Merge with default branch after shorten the code lines to max. 79 characters.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3056 3004
diff changeset
116 super(CodeStyleCheckerDialog, self).__init__(parent)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 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
118 self.setWindowFlags(Qt.WindowType.Window)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
120 self.__project = project
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
121
5661
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
122 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
123
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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
133 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
134 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
135
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
136 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
137 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
138 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
139 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
140 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
141
5636
709a306baa81 Changed some lists of the style checker to contain checkable items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5625
diff changeset
142 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
143 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
144 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
145 itm.setCheckState(Qt.CheckState.Unchecked)
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
146
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
147 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
148 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
149 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
150 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
151 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
152 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
153 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
154 CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
155 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
156 CodeStyleCheckerDialog.cryptoBitSelectionsEc)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
157 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
158 CodeStyleCheckerDialog.cryptoBitSelectionsEc)
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
159
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
160 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
161 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
162 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
163 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
164 QDialogButtonBox.StandardButton.Close).setEnabled(False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 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
167 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
168 0, Qt.SortOrder.AscendingOrder)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
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
170 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
171 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
172 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
173 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
174
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
175 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
176 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
177
2947
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
178 self.checkProgress.setVisible(False)
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
179 self.checkProgressLabel.setVisible(False)
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
180 self.checkProgressLabel.setMaximumWidth(600)
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
181
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
182 self.styleCheckService = styleCheckService
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
183 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
184 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
185 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
186 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
187
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
188 self.results = CodeStyleCheckerDialog.noResults
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.cancelled = False
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 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
191 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
192 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
193 self.__errorItem = None
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.__fileOrFileList = ""
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self.__project = None
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.__forProject = False
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.__data = {}
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
199 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
200 self.__onlyFixes = {}
4437
b9cc331a4576 Some little fixes to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4434
diff changeset
201 self.__noFixCodesList = []
8199
f6db89b067e7 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8195
diff changeset
202 self.__detectedCodes = []
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 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
205
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 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
207 self.optionsTabWidget.setCurrentWidget(self.globalOptionsTab)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
209 def __defaultStatistics(self):
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
210 """
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
211 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
212
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
213 @return dictionary with default statistics entry
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
214 @rtype dict
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
215 """
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
216 return {
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
217 "total": 0,
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
218 "ignored": 0,
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
219 }
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
220
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 def __resort(self):
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 Private method to resort the tree.
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
225 self.resultList.sortItems(self.resultList.sortColumn(),
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 self.resultList.header().sortIndicatorOrder()
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
227 )
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
229 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
230 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
231 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
232
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
233 @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
234 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
235 @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
236 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
237 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
238 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
239 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
240 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
241 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
242 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
243
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
244 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
245 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
246 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
247 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
248 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
249 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
250
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
251 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
252 """
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 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
254
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 @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
256 @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
257 @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
258 @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
259 """
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 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
261 "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
262 "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
263 "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
264 "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
265 "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
266 "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
267 "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
268 "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
269 "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
270 }
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 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
272
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 def __createResultItem(self, filename, result):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 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
276
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
277 @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
278 @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
279 @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
280 @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
281 @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
282 @rtype QTreeWidgetItem
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 """
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
284 from .CodeStyleFixer import FixableCodeStyleIssues
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
285
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 if self.__lastFileItem is None:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 # 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
288 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
289 self.__project.getRelativePath(filename)])
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self.__lastFileItem.setFirstColumnSpanned(True)
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 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
292 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
293
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
294 msgCode = result["code"].split(".", 1)[0]
8199
f6db89b067e7 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8195
diff changeset
295 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
296
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
297 fixable = False
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
298 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
299 self.__lastFileItem, [
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
300 "{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
301 msgCode,
7614
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
302 result["display"]
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
303 ]
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
304 )
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
305 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
306 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
307 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
308 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
309 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
310 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError"))
8166
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
311 elif msgCode.startswith("P"):
bd5cd5858503 Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
312 itm.setIcon(1, UI.PixmapCache.getIcon("dirClosed"))
8188
bfa6c0969acf Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8186
diff changeset
313 elif msgCode.startswith("Y"):
bfa6c0969acf Code Style Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8186
diff changeset
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323 else:
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
324 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
325 else:
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
326 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
327 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
328 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
329 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
330 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
331 elif (
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
332 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
333 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
334 msgCode not in self.__noFixCodesList
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
335 ):
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
336 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
337 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
338
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
339 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
340 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
341
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
342 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
343 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
344 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
345
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354
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
355 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
356 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
357 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
358 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
359 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
360
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 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
362
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
363 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
364 """
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 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
366 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
367
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
368 @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
369 @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
370 @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
371 @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
372 """
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
373 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
374 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
375 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
376
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
377 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
378 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
379 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
380 itm.setData(0, self.fixableRole, False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381
7615
ca2949b1a29a Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7614
diff changeset
382 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
383 """
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 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
385
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 @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
387 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
388 @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
389 @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
390 @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
391 @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
392 @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
393 @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
394 @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
395 """
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 self.__statistics["_FilesCount"] += 1
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
397 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
398 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
399 self.__statistics["_FilesIssues"] += 1
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
400 for key in stats:
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
401 self.__statistics[key]["total"] += statistics[key]
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
402 for key in ignoredErrors:
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
403 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
404 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
405 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
406
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
407 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
408 """
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 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
410
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
411 @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
412 @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
413 """
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
414 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
415
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
416 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
417 """
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 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
419 """
8206
adf11836cfce Code Style Checker: improved the statistics handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
420 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
421 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
422 self.__statistics["_FilesIssues"] = 0
853
ec7dd115e26b Continued implementing a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 849
diff changeset
423 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
424 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
425
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 def prepare(self, fileList, project):
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 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
429
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
430 @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
431 @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
432 @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
433 @type Project
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 self.__fileOrFileList = fileList[:]
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 self.__project = project
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 self.__forProject = True
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438
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
439 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
440 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
441 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
442 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
443 self.cancelButton.setEnabled(False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 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
446 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
447 self.__data is None or
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
448 len(self.__data) < 6
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
449 ):
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 # initialize the data structure
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 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
452 "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
453 "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
454 "IncludeMessages": "",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
455 "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
456 "FixCodes": "",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
457 "FixIssues": False,
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 }
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
459 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
460 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
461 CodeStyleCheckerDialog.checkCategories.keys())
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
462 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
463 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
464 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
465 # 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
466 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
467 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
468 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
469 # top level, method
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
470 if "HangClosing" not in self.__data:
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
471 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
472 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
473 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
474 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
475 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
476 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
477 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
478 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
479 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
480 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
481 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
482 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
483 self.__data["LineComplexityScore"] = 10
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
484 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
485 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
486 MiscellaneousCheckerDefaultArgs["CodingChecker"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
487 )
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
488 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
489 "CopyrightMinFileSize" not in self.__data or
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
490 "CopyrightAuthor" not in self.__data
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
491 ):
7980
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
492 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
493 MiscellaneousCheckerDefaultArgs[
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
494 "CopyrightChecker"]["MinFilesize"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
495 )
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
496 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
497 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
498 )
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
499 if "FutureChecker" not in self.__data:
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
500 self.__data["FutureChecker"] = ""
5619
ab999dc48132 Made the built-ins checker configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
501 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
502 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
503 MiscellaneousCheckerDefaultArgs["BuiltinsChecker"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
504 )
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
505
7040
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
506 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
507 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
508 MiscellaneousCheckerDefaultArgs["CommentedCodeChecker"]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
509 )
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
510 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
511 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
512 MiscellaneousCheckerDefaultArgs[
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
513 "CommentedCodeChecker"]["WhiteList"][:]
2c3f14a3c595 CodeStyleCheckerDialog: added a commented code whitelist patterns to the Miscellaneous Checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7978
diff changeset
514 )
7978
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
515
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
516 if "AnnotationsChecker" not in self.__data:
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
517 self.__data["AnnotationsChecker"] = {
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
518 "MinimumCoverage": 75,
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
519 "MaximumComplexity": 3,
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
520 }
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
521
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
522 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
523 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
524 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
525 "HardcodedTmpDirectories":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
526 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
527 "InsecureHashes":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
528 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
529 "InsecureSslProtocolVersions":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
530 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
531 "WeakKeySizeDsaHigh":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
532 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
533 "WeakKeySizeDsaMedium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
534 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
535 "WeakKeySizeRsaHigh":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
536 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
537 "WeakKeySizeRsaMedium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
538 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
539 "WeakKeySizeEcHigh":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
540 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
541 "WeakKeySizeEcMedium":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
542 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
543 "CheckTypedException":
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
544 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
545 }
7614
646742c260bd Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7611
diff changeset
546
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
547 self.__initCategoriesList(self.__data["EnabledCheckerCategories"])
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"])
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"])
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 self.includeMessagesEdit.setText(self.__data["IncludeMessages"])
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 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
552 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
553 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
554 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
555 self.ignoredCheckBox.setChecked(self.__data["ShowIgnored"])
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
556 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
557 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
558 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
559 self.blankBeforeMethodSpinBox.setValue(self.__data["BlankLines"][1])
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
560 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
561 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
562 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
563 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
564 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
565 self.lineComplexityScoreSpinBox.setValue(
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
566 self.__data["LineComplexityScore"])
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
567 self.encodingsEdit.setText(self.__data["ValidEncodings"])
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
568 self.copyrightFileSizeSpinBox.setValue(
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
569 self.__data["CopyrightMinFileSize"])
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
570 self.copyrightAuthorEdit.setText(self.__data["CopyrightAuthor"])
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
571 self.__initFuturesList(self.__data["FutureChecker"])
5619
ab999dc48132 Made the built-ins checker configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
572 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
573 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
574 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
575 self.__initCommentedCodeCheckerWhiteList(
1e391f977124 CodeStyleCheckerDialog: added configuration entry for commented code whitelist patterns.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
576 self.__data["CommentedCodeChecker"]["WhiteList"])
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
577 self.minAnnotationsCoverageSpinBox.setValue(
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
578 self.__data["AnnotationsChecker"]["MinimumCoverage"])
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
579 self.maxAnnotationsComplexitySpinBox.setValue(
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
580 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
581
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
582 # security
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
583 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
584 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
585 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
586 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
587 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
588 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
589 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
590 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
591 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
592 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
593 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
594 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
595 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
596 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
597 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
598 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
599 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
600 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
601 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
602 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
603
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
604 self.__cleanupData()
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605
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
606 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
607 """
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 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
609 """
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 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
611 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
612 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
613 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
614 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
615 if len(self.files) > 1:
7632
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
616 if self.__project:
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
617 self.progressList.addItems([
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
618 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
619 for f in self.files
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
620 ])
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
621 else:
7ac16bf7695b CodeStyleCheckerDialog: further improvements to the progress tab.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7631
diff changeset
622 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
623
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 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
625
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 940
diff changeset
626 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
627 """
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
628 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
629
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 @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
631 @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
632 @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
633 @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
634 @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
635 @type None or bool
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 if self.__project is None:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 self.__project = e5App().getObject("Project")
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639
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
640 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
641
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 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
643 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
644 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
645 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
646 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
647 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
648 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
649 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
650 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
651 self.restartButton.setEnabled(False)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 if repeat is not None:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 self.repeatCheckBox.setChecked(repeat)
2947
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
654 self.checkProgress.setVisible(True)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 QApplication.processEvents()
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 if save:
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 self.__fileOrFileList = fn
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 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
661 self.files = fn[:]
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 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
663 self.files = []
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7632
diff changeset
664 extensions = set(Preferences.getPython("Python3Extensions"))
2607
e5115553185a Fixes and consolidation for PEP8-checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
665 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
666 self.files.extend(Utilities.direntries(
3065
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
667 fn, True, '*{0}'.format(ext), 0))
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 else:
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
669 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
670
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 # 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
672 if self.files:
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 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
674 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
675 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
676 for fileFilter in filterList:
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
677 self.files = [
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
678 f for f in self.files
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
679 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
680 ]
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
681
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
682 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
683 self.__resetStatistics()
3456
96232974dcdb Merge with BgService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3178 3413
diff changeset
684 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
685 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
686 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
687
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
688 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
689 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
690 "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
691
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 # 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
693 excludeMessages = self.__assembleExcludeMessages()
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 includeMessages = self.includeMessagesEdit.text()
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 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
696 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
697 noFixCodes = self.noFixIssuesEdit.text()
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
698 self.__noFixCodesList = [
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
699 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
700 ]
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 847
diff changeset
701 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
702 self.showIgnored = (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
703 self.ignoredCheckBox.isChecked() and repeatMessages
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7247
diff changeset
704 )
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
705 maxLineLength = self.lineLengthSpinBox.value()
6786
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
706 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
707 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
708 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
709 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
710 )
2866
c77e08c38a5c Extended the PEP-8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2864
diff changeset
711 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
712 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
713 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
714 codeComplexityArgs = {
ae4f5cdc3d00 Added a line complexity checker to the code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5636
diff changeset
715 "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
716 "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
717 "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
718 }
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
719 miscellaneousArgs = {
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
720 "CodingChecker": self.encodingsEdit.text(),
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
721 "CopyrightChecker": {
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
722 "MinFilesize": self.copyrightFileSizeSpinBox.value(),
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
723 "Author": self.copyrightAuthorEdit.text(),
4509
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
724 },
7797ee4a45f9 Redid the future imports checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4506
diff changeset
725 "FutureChecker": self.__getSelectedFutureImports(),
5619
ab999dc48132 Made the built-ins checker configurable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
726 "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
727 "CommentedCodeChecker": {
f89952e5fc11 Code Style Checker: added check for commented code that should be removed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
728 "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
729 "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
730 }
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
731 }
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
732 annotationArgs = {
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
733 "MinimumCoverage":
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
734 self.minAnnotationsCoverageSpinBox.value(),
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
735 "MaximumComplexity":
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
736 self.maxAnnotationsComplexitySpinBox.value(),
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
737 }
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738
7619
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
739 securityArgs = {
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
740 "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
741 t.strip()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
742 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
743 ],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
744 "insecure_hashes": [
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
745 h.strip()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
746 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
747 ],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
748 "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
749 p.strip()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
750 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
751 .splitlines()
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
752 ],
ef2b5af23ce7 Code Style Checker: continued to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7615
diff changeset
753 "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
754 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
755 "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
756 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
757 "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
758 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
759 "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
760 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
761 "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
762 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
763 "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
764 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
765 "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
766 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
767 }
7611
d546c4e72f52 Code Style Checker: started to implement checker for security related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
768
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
769 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
770 fixCodes, noFixCodes, fixIssues, maxLineLength,
6786
701b511ba8f5 Added option to set the documentation line length.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6645
diff changeset
771 maxDocLineLength, blankLines, hangClosing,
7247
bf9379f964f3 Code Style Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
772 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
773 annotationArgs, securityArgs]
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
774
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
775 # 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
776 self.progress = 0
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
777 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
778 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
779 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
780 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
781 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
782 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
783 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
784 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
785 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
786 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
787 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
788 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
789
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 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
791 """
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 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
793
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
794 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
795 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
796 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
797
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
798 @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
799 @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
800 @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
801 @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
802 """
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 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
804 flags = Utilities.extractFlags(source)
4556
25d1fa006bf0 Process noqa under Python2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4514
diff changeset
805 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
806 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
807 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
808 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 += 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
810 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
811 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
812
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
813 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
814 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3558
diff changeset
815 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
816
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
817 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
818
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
819 @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
820 @type str
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
821 """
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
822 if not self.files:
2947
bd95f61c4f96 Some enhancements to the coding style checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2929
diff changeset
823 self.checkProgressLabel.setPath("")
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 self.checkProgress.setMaximum(1)
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 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
826 self.__finish()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
827 return
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
828
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
829 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
830 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
831 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
832 QApplication.processEvents()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
833
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
834 if self.cancelled:
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
835 self.__resort()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
836 return
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
837
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
838 self.__lastFileItem = None
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
839
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
840 if codestring:
4506
57666e501a42 Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
841 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
842 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
843 else:
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
844 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
845 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
846 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
847 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
848 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
849 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
850 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
851 self.progress += 1
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
852 # 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
853 self.check()
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
854 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
855 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
856 ('-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
857 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
858
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
859 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
860
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
861 errors = []
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
862 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
863 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
864 errors.append(error)
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
865 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
866
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
867 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
868 args = options + [
3549
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
869 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
870 ]
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
871 self.__finished = False
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
872 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
873 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
874
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 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
876 """
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 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
878
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 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
880 """
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 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
882
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 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
884
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 argumentsList = []
8213
4cdfe4fbdd26 CodeStyleCheckerDialog: fixed an issue causing some messages being supressed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8206
diff changeset
886 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
887 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
888 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
889
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 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
891 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
892 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
893 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
894 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
895 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
896 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
897 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
898
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 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
900 ('-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
901 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 <detlev@die-offenbachs.de>
parents: 4217
diff changeset
902
4514
e410e76d6538 Added capability to disable code style checks using an eflags: comment like 'eflags: noqa = M601, M702'.
Detlev