138 fixable = False |
138 fixable = False |
139 code, message = message.split(None, 1) |
139 code, message = message.split(None, 1) |
140 itm = QTreeWidgetItem( |
140 itm = QTreeWidgetItem( |
141 self.__lastFileItem, |
141 self.__lastFileItem, |
142 ["{0:6}".format(line), code, message]) |
142 ["{0:6}".format(line), code, message]) |
143 if code.startswith(("W", "-")): |
143 if code.startswith(("W", "-", "C")): |
144 itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) |
144 itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) |
145 elif code.startswith("N"): |
145 elif code.startswith("N"): |
146 itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png")) |
146 itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png")) |
147 elif code.startswith("D"): |
147 elif code.startswith("D"): |
148 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png")) |
148 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png")) |
270 self.__data["NoFixCodes"] = "E501" |
270 self.__data["NoFixCodes"] = "E501" |
271 if "DocstringType" not in self.__data: |
271 if "DocstringType" not in self.__data: |
272 self.__data["DocstringType"] = "pep257" |
272 self.__data["DocstringType"] = "pep257" |
273 if "ShowIgnored" not in self.__data: |
273 if "ShowIgnored" not in self.__data: |
274 self.__data["ShowIgnored"] = False |
274 self.__data["ShowIgnored"] = False |
|
275 if "MaxCodeComplexity" not in self.__data: |
|
276 self.__data["MaxCodeComplexity"] = 10 |
275 |
277 |
276 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
278 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
277 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
279 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
278 self.includeMessagesEdit.setText(self.__data["IncludeMessages"]) |
280 self.includeMessagesEdit.setText(self.__data["IncludeMessages"]) |
279 self.repeatCheckBox.setChecked(self.__data["RepeatMessages"]) |
281 self.repeatCheckBox.setChecked(self.__data["RepeatMessages"]) |
283 self.ignoredCheckBox.setChecked(self.__data["ShowIgnored"]) |
285 self.ignoredCheckBox.setChecked(self.__data["ShowIgnored"]) |
284 self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"]) |
286 self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"]) |
285 self.hangClosingCheckBox.setChecked(self.__data["HangClosing"]) |
287 self.hangClosingCheckBox.setChecked(self.__data["HangClosing"]) |
286 self.docTypeComboBox.setCurrentIndex( |
288 self.docTypeComboBox.setCurrentIndex( |
287 self.docTypeComboBox.findData(self.__data["DocstringType"])) |
289 self.docTypeComboBox.findData(self.__data["DocstringType"])) |
|
290 self.complexitySpinBox.setValue(self.__data["MaxCodeComplexity"]) |
288 |
291 |
289 def start(self, fn, save=False, repeat=None): |
292 def start(self, fn, save=False, repeat=None): |
290 """ |
293 """ |
291 Public slot to start the code style check. |
294 Public slot to start the code style check. |
292 |
295 |
358 repeatMessages |
361 repeatMessages |
359 maxLineLength = self.lineLengthSpinBox.value() |
362 maxLineLength = self.lineLengthSpinBox.value() |
360 hangClosing = self.hangClosingCheckBox.isChecked() |
363 hangClosing = self.hangClosingCheckBox.isChecked() |
361 docType = self.docTypeComboBox.itemData( |
364 docType = self.docTypeComboBox.itemData( |
362 self.docTypeComboBox.currentIndex()) |
365 self.docTypeComboBox.currentIndex()) |
|
366 maxCodeComplexity = self.complexitySpinBox.value() |
363 |
367 |
364 self.__options = [excludeMessages, includeMessages, repeatMessages, |
368 self.__options = [excludeMessages, includeMessages, repeatMessages, |
365 fixCodes, noFixCodes, fixIssues, maxLineLength, |
369 fixCodes, noFixCodes, fixIssues, maxLineLength, |
366 hangClosing, docType] |
370 hangClosing, docType, maxCodeComplexity] |
367 |
371 |
368 # now go through all the files |
372 # now go through all the files |
369 self.progress = 0 |
373 self.progress = 0 |
370 self.files.sort() |
374 self.files.sort() |
371 if len(self.files) == 1: |
375 if len(self.files) == 1: |
625 "ShowIgnored": self.ignoredCheckBox.isChecked(), |
629 "ShowIgnored": self.ignoredCheckBox.isChecked(), |
626 "MaxLineLength": self.lineLengthSpinBox.value(), |
630 "MaxLineLength": self.lineLengthSpinBox.value(), |
627 "HangClosing": self.hangClosingCheckBox.isChecked(), |
631 "HangClosing": self.hangClosingCheckBox.isChecked(), |
628 "DocstringType": self.docTypeComboBox.itemData( |
632 "DocstringType": self.docTypeComboBox.itemData( |
629 self.docTypeComboBox.currentIndex()), |
633 self.docTypeComboBox.currentIndex()), |
|
634 "MaxCodeComplexity": self.complexitySpinBox.value(), |
630 } |
635 } |
631 if data != self.__data: |
636 if data != self.__data: |
632 self.__data = data |
637 self.__data = data |
633 self.__project.setData("CHECKERSPARMS", "Pep8Checker", |
638 self.__project.setData("CHECKERSPARMS", "Pep8Checker", |
634 self.__data) |
639 self.__data) |
791 "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH))) |
796 "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH))) |
792 self.hangClosingCheckBox.setChecked(Preferences.toBool( |
797 self.hangClosingCheckBox.setChecked(Preferences.toBool( |
793 Preferences.Prefs.settings.value("PEP8/HangClosing"))) |
798 Preferences.Prefs.settings.value("PEP8/HangClosing"))) |
794 self.docTypeComboBox.setCurrentIndex(self.docTypeComboBox.findData( |
799 self.docTypeComboBox.setCurrentIndex(self.docTypeComboBox.findData( |
795 Preferences.Prefs.settings.value("PEP8/DocstringType", "pep257"))) |
800 Preferences.Prefs.settings.value("PEP8/DocstringType", "pep257"))) |
|
801 self.complexitySpinBox.setValue(int(Preferences.Prefs.settings.value( |
|
802 "PEP8/MaxCodeComplexity", 10))) |
796 |
803 |
797 @pyqtSlot() |
804 @pyqtSlot() |
798 def on_storeDefaultButton_clicked(self): |
805 def on_storeDefaultButton_clicked(self): |
799 """ |
806 """ |
800 Private slot to store the current configuration values as |
807 Private slot to store the current configuration values as |
821 Preferences.Prefs.settings.setValue( |
828 Preferences.Prefs.settings.setValue( |
822 "PEP8/HangClosing", self.hangClosingCheckBox.isChecked()) |
829 "PEP8/HangClosing", self.hangClosingCheckBox.isChecked()) |
823 Preferences.Prefs.settings.setValue( |
830 Preferences.Prefs.settings.setValue( |
824 "PEP8/DocstringType", self.docTypeComboBox.itemData( |
831 "PEP8/DocstringType", self.docTypeComboBox.itemData( |
825 self.docTypeComboBox.currentIndex())) |
832 self.docTypeComboBox.currentIndex())) |
|
833 Preferences.Prefs.settings.setValue( |
|
834 "PEP8/MaxCodeComplexity", self.complexitySpinBox.value()) |
826 |
835 |
827 @pyqtSlot() |
836 @pyqtSlot() |
828 def on_resetDefaultButton_clicked(self): |
837 def on_resetDefaultButton_clicked(self): |
829 """ |
838 """ |
830 Private slot to reset the configuration values to their default values. |
839 Private slot to reset the configuration values to their default values. |
840 Preferences.Prefs.settings.setValue("PEP8/ShowIgnored", False) |
849 Preferences.Prefs.settings.setValue("PEP8/ShowIgnored", False) |
841 Preferences.Prefs.settings.setValue( |
850 Preferences.Prefs.settings.setValue( |
842 "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH) |
851 "PEP8/MaxLineLength", pep8.MAX_LINE_LENGTH) |
843 Preferences.Prefs.settings.setValue("PEP8/HangClosing", False) |
852 Preferences.Prefs.settings.setValue("PEP8/HangClosing", False) |
844 Preferences.Prefs.settings.setValue("PEP8/DocstringType", "pep257") |
853 Preferences.Prefs.settings.setValue("PEP8/DocstringType", "pep257") |
|
854 Preferences.Prefs.settings.setValue("PEP8/MaxCodeComplexity", 10) |
845 |
855 |
846 @pyqtSlot(QAbstractButton) |
856 @pyqtSlot(QAbstractButton) |
847 def on_buttonBox_clicked(self, button): |
857 def on_buttonBox_clicked(self, button): |
848 """ |
858 """ |
849 Private slot called by a button of the button box clicked. |
859 Private slot called by a button of the button box clicked. |