Tue, 19 Feb 2019 18:16:45 +0100
Added option to set the documentation line length.
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Mon Feb 18 19:14:05 2019 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Tue Feb 19 18:16:45 2019 +0100 @@ -146,9 +146,9 @@ @type str @param args arguments used by the codeStyleCheck function (list of excludeMessages, includeMessages, repeatMessages, fixCodes, - noFixCodes, fixIssues, maxLineLength, blankLines, hangClosing, - docType, codeComplexityArgs, miscellaneousArgs, errors, eol, - encoding, backup) + noFixCodes, fixIssues, maxLineLength, maxDocLineLength, blankLines, + hangClosing, docType, codeComplexityArgs, miscellaneousArgs, errors, + eol, encoding, backup) @type list of (str, str, bool, str, str, bool, int, list of (int, int), bool, str, dict, dict, list of str, str, str, bool) @return tuple of statistics (dict) and list of results (tuple for each @@ -253,9 +253,9 @@ @type str @param args arguments used by the codeStyleCheck function (list of excludeMessages, includeMessages, repeatMessages, fixCodes, - noFixCodes, fixIssues, maxLineLength, blankLines, hangClosing, - docType, codeComplexityArgs, miscellaneousArgs, errors, eol, - encoding, backup) + noFixCodes, fixIssues, maxLineLength, maxDocLineLength, blankLines, + hangClosing, docType, codeComplexityArgs, miscellaneousArgs, errors, + eol, encoding, backup) @type list of (str, str, bool, str, str, bool, int, list of (int, int), bool, str, dict, dict, list of str, str, str, bool) @return tuple of statistics (dict) and list of results (tuple for each @@ -265,7 +265,7 @@ str)) """ (excludeMessages, includeMessages, repeatMessages, fixCodes, noFixCodes, - fixIssues, maxLineLength, blankLines, hangClosing, docType, + fixIssues, maxLineLength, maxDocLineLength, blankLines, hangClosing, docType, codeComplexityArgs, miscellaneousArgs, errors, eol, encoding, backup) = args @@ -313,6 +313,7 @@ select=select, ignore=ignore, max_line_length=maxLineLength, + max_doc_length=maxDocLineLength, hang_closing=hangClosing, ) report = styleGuide.check_files([filename]) @@ -322,7 +323,7 @@ # check documentation style docStyleChecker = DocStyleChecker( source, filename, select, ignore, [], repeatMessages, - maxLineLength=maxLineLength, docType=docType) + maxLineLength=maxDocLineLength, docType=docType) docStyleChecker.run() stats.update(docStyleChecker.counters) errors += docStyleChecker.errors
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Mon Feb 18 19:14:05 2019 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Tue Feb 19 18:16:45 2019 +0100 @@ -315,6 +315,9 @@ } if "MaxLineLength" not in self.__data: self.__data["MaxLineLength"] = pycodestyle.MAX_LINE_LENGTH + if "MaxDocLineLength" not in self.__data: + # Use MAX_LINE_LENGTH to avoid messages on existing code + self.__data["MaxDocLineLength"] = pycodestyle.MAX_LINE_LENGTH if "BlankLines" not in self.__data: self.__data["BlankLines"] = (2, 1) # top level, method @@ -355,6 +358,7 @@ self.fixIssuesCheckBox.setChecked(self.__data["FixIssues"]) self.ignoredCheckBox.setChecked(self.__data["ShowIgnored"]) self.lineLengthSpinBox.setValue(self.__data["MaxLineLength"]) + self.docLineLengthSpinBox.setValue(self.__data["MaxDocLineLength"]) self.blankBeforeTopLevelSpinBox.setValue(self.__data["BlankLines"][0]) self.blankBeforeMethodSpinBox.setValue(self.__data["BlankLines"][1]) self.hangClosingCheckBox.setChecked(self.__data["HangClosing"]) @@ -445,6 +449,7 @@ self.showIgnored = self.ignoredCheckBox.isChecked() and \ repeatMessages maxLineLength = self.lineLengthSpinBox.value() + maxDocLineLength = self.docLineLengthSpinBox.value() blankLines = ( self.blankBeforeTopLevelSpinBox.value(), self.blankBeforeMethodSpinBox.value() @@ -469,8 +474,8 @@ self.__options = [excludeMessages, includeMessages, repeatMessages, fixCodes, noFixCodes, fixIssues, maxLineLength, - blankLines, hangClosing, docType, - codeComplexityArgs, miscellaneousArgs] + maxDocLineLength, blankLines, hangClosing, + docType, codeComplexityArgs, miscellaneousArgs] # now go through all the files self.progress = 0 @@ -782,6 +787,7 @@ "FixIssues": self.fixIssuesCheckBox.isChecked(), "ShowIgnored": self.ignoredCheckBox.isChecked(), "MaxLineLength": self.lineLengthSpinBox.value(), + "MaxDocLineLength": self.docLineLengthSpinBox.value(), "BlankLines": ( self.blankBeforeTopLevelSpinBox.value(), self.blankBeforeMethodSpinBox.value() @@ -964,6 +970,10 @@ Preferences.Prefs.settings.value("PEP8/ShowIgnored", False))) self.lineLengthSpinBox.setValue(int(Preferences.Prefs.settings.value( "PEP8/MaxLineLength", pycodestyle.MAX_LINE_LENGTH))) + # Use MAX_LINE_LENGTH to avoid messages on existing code + self.docLineLengthSpinBox.setValue(int( + Preferences.Prefs.settings.value( + "PEP8/MaxDocLineLength", pycodestyle.MAX_LINE_LENGTH))) self.blankBeforeTopLevelSpinBox.setValue( int(Preferences.Prefs.settings.value( "PEP8/BlankLinesBeforeTopLevel", 2))) @@ -1021,6 +1031,8 @@ Preferences.Prefs.settings.setValue( "PEP8/MaxLineLength", self.lineLengthSpinBox.value()) Preferences.Prefs.settings.setValue( + "PEP8/MaxDocLineLength", self.docLineLengthSpinBox.value()) + Preferences.Prefs.settings.setValue( "PEP8/BlankLinesBeforeTopLevel", self.blankBeforeTopLevelSpinBox.value()) Preferences.Prefs.settings.setValue( @@ -1065,6 +1077,9 @@ Preferences.Prefs.settings.setValue("PEP8/ShowIgnored", False) Preferences.Prefs.settings.setValue( "PEP8/MaxLineLength", pycodestyle.MAX_LINE_LENGTH) + # Hard reset to pycodestyle preferences + Preferences.Prefs.settings.setValue( + "PEP8/MaxDocLineLength", pycodestyle.MAX_DOC_LENGTH) Preferences.Prefs.settings.setValue( "PEP8/BlankLinesBeforeTopLevel", 2) Preferences.Prefs.settings.setValue( @@ -1083,6 +1098,8 @@ "str": ["unicode", ], "chr": ["unichr", ], }) + # Update UI with default values + self.on_loadDefaultButton_clicked() @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button):
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.ui Mon Feb 18 19:14:05 2019 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.ui Tue Feb 19 18:16:45 2019 +0100 @@ -258,8 +258,8 @@ <rect> <x>0</x> <y>0</y> - <width>549</width> - <height>883</height> + <width>561</width> + <height>743</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -270,15 +270,15 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> <string>Max. Line Length:</string> </property> </widget> </item> - <item> + <item row="0" column="1"> <widget class="QSpinBox" name="lineLengthSpinBox"> <property name="toolTip"> <string>Enter the maximum allowed line length (PEP-8: 79 characters)</string> @@ -297,7 +297,33 @@ </property> </widget> </item> - <item> + <item row="1" column="0"> + <widget class="QLabel" name="label_17"> + <property name="text"> + <string>Max. Documentation Line Length:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="docLineLengthSpinBox"> + <property name="toolTip"> + <string>Enter the maximum allowed line length (PEP-8: 79 characters)</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="minimum"> + <number>60</number> + </property> + <property name="maximum"> + <number>119</number> + </property> + <property name="value"> + <number>79</number> + </property> + </widget> + </item> + <item row="0" column="2"> <spacer name="horizontalSpacer_3"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -903,7 +929,6 @@ <tabstop>fixIssuesCheckBox</tabstop> <tabstop>ignoredCheckBox</tabstop> <tabstop>scrollArea</tabstop> - <tabstop>lineLengthSpinBox</tabstop> <tabstop>blankBeforeTopLevelSpinBox</tabstop> <tabstop>blankBeforeMethodSpinBox</tabstop> <tabstop>hangClosingCheckBox</tabstop>