--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Sat Apr 21 17:11:05 2018 +0200 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Sat Apr 21 17:43:41 2018 +0200 @@ -138,18 +138,24 @@ def codeStyleCheck(filename, source, args): """ - Do the code style check and/ or fix found errors. + Do the code style check and/or fix found errors. - @param filename source filename (string) - @param source string containing the code to check (string) + @param filename source filename + @type str + @param source string containing the code to check + @type str @param args arguments used by the codeStyleCheck function (list of - excludeMessages (str), includeMessages (str), repeatMessages - (bool), fixCodes (str), noFixCodes (str), fixIssues (bool), - maxLineLength (int), hangClosing (bool), docType (str), errors - (list of str), eol (str), encoding (str), backup (bool)) - @return tuple of stats (dict) and results (tuple for each found violation - of style (tuple of lineno (int), position (int), text (str), ignored - (bool), fixed (bool), autofixing (bool), fixedMsg (str))) + excludeMessages, includeMessages, repeatMessages, fixCodes, + noFixCodes, fixIssues, maxLineLength, 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 + found violation of style (lineno, position, text, ignored, fixed, + autofixing, fixedMsg)) + @rtype tuple of (dict, list of tuples of (int, int, str, bool, bool, bool, + str)) """ return __checkCodeStyle(filename, source, args) @@ -241,22 +247,27 @@ Private module function to perform the code style check and/or fix found errors. - @param filename source filename (string) - @param source string containing the code to check (string) + @param filename source filename + @type str + @param source string containing the code to check + @type str @param args arguments used by the codeStyleCheck function (list of - excludeMessages (str), includeMessages (str), repeatMessages - (bool), fixCodes (str), noFixCodes (str), fixIssues (bool), - maxLineLength (int), hangClosing (bool), docType (str), dictionary - with arguments for the code complexity checker (dict), dictionary - with arguments for the miscellaneous checker (dict), errors (list - of str), eol (str), encoding (str), backup (bool)) - @return tuple of statistics (dict) and results (tuple for each found - violation of style (tuple of lineno (int), position (int), text (str), - ignored (bool), fixed (bool), autofixing (bool), fixedMsg (str))) + excludeMessages, includeMessages, repeatMessages, fixCodes, + noFixCodes, fixIssues, maxLineLength, 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 + found violation of style (lineno, position, text, ignored, fixed, + autofixing, fixedMsg)) + @rtype tuple of (dict, list of tuples of (int, int, str, bool, bool, bool, + str)) """ (excludeMessages, includeMessages, repeatMessages, fixCodes, noFixCodes, - fixIssues, maxLineLength, hangClosing, docType, codeComplexityArgs, - miscellaneousArgs, errors, eol, encoding, backup) = args + fixIssues, maxLineLength, blankLines, hangClosing, docType, + codeComplexityArgs, miscellaneousArgs, errors, eol, encoding, + backup) = args stats = {} @@ -264,7 +275,8 @@ from CodeStyleFixer import CodeStyleFixer fixer = CodeStyleFixer( filename, source, fixCodes, noFixCodes, - maxLineLength, True, eol, backup) # always fix in place + maxLineLength, blankLines, True, eol, backup) + # always fix in place else: fixer = None @@ -289,6 +301,12 @@ ignore = [] # check coding style + pycodestyle.BLANK_LINES_CONFIG = { + # Top level class and function. + 'top_level': blankLines[0], + # Methods and nested class and function. + 'method': blankLines[1], + } styleGuide = pycodestyle.StyleGuide( reporter=CodeStyleCheckerReport, repeat=repeatMessages,