eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py

Wed, 17 Jun 2020 20:18:54 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 17 Jun 2020 20:18:54 +0200
changeset 7628
f904d0eef264
parent 7610
df7025fe26a3
child 7639
422fd05e9c91
permissions
-rw-r--r--

Checked the reported security related issue reports generated by the new security checker.

849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7256
diff changeset
3 # Copyright (c) 2011 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
2912
9ff696796092 Changed some display and source docu strings in the code style checker to make them more universal because the scope goes beyond PEP-8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2895
diff changeset
7 Module implementing a class to fix certain code style issues.
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3745
4c6f1782f530 Possible exception on fixing code styles fixed (only Python2).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
10 from __future__ import unicode_literals
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
11 try:
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
12 # Python 2
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
13 from StringIO import StringIO # __IGNORE_EXCEPTION__
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
14 except ImportError:
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
15 # Python 3
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
16 from io import StringIO # __IGNORE_WARNING__
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import os
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import re
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
19 import tokenize
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
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
21 # CodeStyleCheckerDialog tries to import FixableCodeStyleIssues which fails
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
22 # under Python3. So ignore it.
3228
f489068e51e8 Bugfixes to work under Python3 and unicode issues for Python2 fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
23 try:
5147
d39dd5cee0c8 Renamed pep8.py to pycodestyle.py in order to track the upstream renaming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4830
diff changeset
24 import pycodestyle
3228
f489068e51e8 Bugfixes to work under Python3 and unicode issues for Python2 fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
25 except ImportError:
f489068e51e8 Bugfixes to work under Python3 and unicode issues for Python2 fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
26 pass
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
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: 2976
diff changeset
28 FixableCodeStyleIssues = [
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: 2976
diff changeset
29 "D111", "D112", "D113", "D121", "D131", "D141",
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: 2976
diff changeset
30 "D142", "D143", "D144", "D145",
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: 2976
diff changeset
31 "D221", "D222", "D231", "D242", "D243", "D244",
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: 2976
diff changeset
32 "D245", "D246", "D247",
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: 2976
diff changeset
33 "E101", "E111", "E121", "E122", "E123", "E124",
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: 2976
diff changeset
34 "E125", "E126", "E127", "E128", "E133", "E201",
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: 2976
diff changeset
35 "E202", "E203", "E211", "E221", "E222", "E223",
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: 2976
diff changeset
36 "E224", "E225", "E226", "E227", "E228", "E231",
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: 2976
diff changeset
37 "E241", "E242", "E251", "E261", "E262", "E271",
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: 2976
diff changeset
38 "E272", "E273", "E274", "E301", "E302", "E303",
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
39 "E304", "E305", "E306", "E307", "E308", "E401",
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
40 "E501", "E502", "E701", "E702", "E703", "E711",
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
41 "E712",
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: 2976
diff changeset
42 "N804", "N805", "N806",
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: 2976
diff changeset
43 "W191", "W291", "W292", "W293", "W391", "W603",
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: 2976
diff changeset
44 ]
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 869
diff changeset
46
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
47 class CodeStyleFixer(object):
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
2912
9ff696796092 Changed some display and source docu strings in the code style checker to make them more universal because the scope goes beyond PEP-8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2895
diff changeset
49 Class implementing a fixer for certain code style issues.
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
51 def __init__(self, filename, sourceLines, fixCodes, noFixCodes,
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
52 maxLineLength, blankLines, inPlace, eol, backup=False):
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 Constructor
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
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
56 @param filename name of the file to be fixed
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
57 @type str
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @param sourceLines list of source lines including eol marker
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
59 @type list of str
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @param fixCodes list of codes to be fixed as a comma separated
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
61 string
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
62 @type str
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: 2875
diff changeset
63 @param noFixCodes list of codes not to be fixed as a comma
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
64 separated string
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
65 @type str
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
66 @param maxLineLength maximum allowed line length
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
67 @type int
6265
56bd09c4c297 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6264
diff changeset
68 @param blankLines tuple containg the number of blank lines before
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
69 a top level class or function and before a method or nested class
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
70 or function
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
71 @type tuple of (int, int)
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
72 @param inPlace flag indicating to modify the file in place
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
73 @type bool
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
74 @param eol end of line character(s)
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
75 @type str
3549
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
76 @param backup flag indicating to create a backup before fixing
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
77 anything
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
78 @type bool
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
3057
10516539f238 Merge with default branch after shorten the code lines to max. 79 characters.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3056 2982
diff changeset
80 super(CodeStyleFixer, self).__init__()
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__filename = filename
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.__origName = ""
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.__source = sourceLines[:] # save a copy
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__fixCodes = [c.strip() for c in fixCodes.split(",") if c.strip()]
2883
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
86 self.__noFixCodes = [
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
87 c.strip() for c in noFixCodes.split(",") if c.strip()]
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: 2875
diff changeset
88 self.__maxLineLength = maxLineLength
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
89 self.__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
90 "toplevel": 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
91 "method": blankLines[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
92 }
853
ec7dd115e26b Continued implementing a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 852
diff changeset
93 self.fixed = 0
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
95 self.__reindenter = None
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
96 self.__indentWord = self.__getIndentWord()
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
97
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
98 if inPlace:
3549
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
99 self.__createBackup = backup
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
100 else:
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__origName = self.__filename
2892
b601ede6dbbf Fixed a few issues in the PEP-8 fixer and made it PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2891
diff changeset
102 self.__filename = os.path.join(
b601ede6dbbf Fixed a few issues in the PEP-8 fixer and made it PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2891
diff changeset
103 os.path.dirname(self.__filename),
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 "fixed_" + os.path.basename(self.__filename))
3549
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
105 self.__createBackup = False
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
106 self.__eol = eol
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
107
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.__fixes = {
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
109 "D111": self.__fixD111,
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
110 "D112": self.__fixD112,
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
111 "D113": self.__fixD112,
2923
01ac1f364b38 Started extending the PEP-8 fixer to correct PEP-257 issues as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2921
diff changeset
112 "D121": self.__fixD121,
01ac1f364b38 Started extending the PEP-8 fixer to correct PEP-257 issues as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2921
diff changeset
113 "D131": self.__fixD131,
01ac1f364b38 Started extending the PEP-8 fixer to correct PEP-257 issues as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2921
diff changeset
114 "D141": self.__fixD141,
01ac1f364b38 Started extending the PEP-8 fixer to correct PEP-257 issues as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2921
diff changeset
115 "D142": self.__fixD142,
01ac1f364b38 Started extending the PEP-8 fixer to correct PEP-257 issues as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2921
diff changeset
116 "D143": self.__fixD143,
01ac1f364b38 Started extending the PEP-8 fixer to correct PEP-257 issues as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2921
diff changeset
117 "D144": self.__fixD144,
01ac1f364b38 Started extending the PEP-8 fixer to correct PEP-257 issues as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2921
diff changeset
118 "D145": self.__fixD145,
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
119 "D221": self.__fixD221,
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
120 "D222": self.__fixD221,
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
121 "D231": self.__fixD131,
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
122 "D242": self.__fixD242,
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
123 "D243": self.__fixD243,
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
124 "D244": self.__fixD242,
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
125 "D245": self.__fixD243,
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
126 "D246": self.__fixD144,
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
127 "D247": self.__fixD247,
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
128 "E101": self.__fixE101,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
129 "E111": self.__fixE101,
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
130 "E121": self.__fixE121,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
131 "E122": self.__fixE122,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
132 "E123": self.__fixE123,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
133 "E124": self.__fixE121,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
134 "E125": self.__fixE125,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
135 "E126": self.__fixE126,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
136 "E127": self.__fixE127,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
137 "E128": self.__fixE127,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
138 "E133": self.__fixE126,
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
139 "E201": self.__fixE201,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
140 "E202": self.__fixE201,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
141 "E203": self.__fixE201,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
142 "E211": self.__fixE201,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
143 "E221": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
144 "E222": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
145 "E223": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
146 "E224": self.__fixE221,
4445
5636dc48e1a0 Own fixer for missing whitespaces around operators (1 pass fix) implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4150
diff changeset
147 "E225": self.__fixE225,
5636dc48e1a0 Own fixer for missing whitespaces around operators (1 pass fix) implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4150
diff changeset
148 "E226": self.__fixE225,
5636dc48e1a0 Own fixer for missing whitespaces around operators (1 pass fix) implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4150
diff changeset
149 "E227": self.__fixE225,
5636dc48e1a0 Own fixer for missing whitespaces around operators (1 pass fix) implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4150
diff changeset
150 "E228": self.__fixE225,
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
151 "E231": self.__fixE231,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
152 "E241": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
153 "E242": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
154 "E251": self.__fixE251,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
155 "E261": self.__fixE261,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
156 "E262": self.__fixE261,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
157 "E271": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
158 "E272": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
159 "E273": self.__fixE221,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
160 "E274": self.__fixE221,
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
161 "E301": self.__fixBlankLinesBefore,
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
162 "E302": self.__fixBlankLinesBefore,
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
163 "E303": self.__fixBlankLinesBefore,
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
164 "E304": self.__fixE304,
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
165 "E305": self.__fixBlankLinesBefore,
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
166 "E306": self.__fixBlankLinesBefore,
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
167 "E307": self.__fixBlankLinesBefore,
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
168 "E308": self.__fixBlankLinesBefore,
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
169 "E401": self.__fixE401,
2882
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
170 "E501": self.__fixE501,
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
171 "E502": self.__fixE502,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
172 "E701": self.__fixE701,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
173 "E702": self.__fixE702,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
174 "E703": self.__fixE702,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
175 "E711": self.__fixE711,
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
176 "E712": self.__fixE711,
2895
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
177 "N804": self.__fixN804,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
178 "N805": self.__fixN804,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
179 "N806": self.__fixN806,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
180 "W191": self.__fixE101,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
181 "W291": self.__fixW291,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
182 "W292": self.__fixW292,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
183 "W293": self.__fixW291,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
184 "W391": self.__fixW391,
4a44d92757f9 Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2894
diff changeset
185 "W603": self.__fixW603,
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 }
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.__modified = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3549
diff changeset
188 self.__stackLogical = []
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3549
diff changeset
189 # These need to be fixed before the file is saved but after all
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3549
diff changeset
190 # other inline fixes. These work with logical lines.
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3549
diff changeset
191 self.__stack = []
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3549
diff changeset
192 # These need to be fixed before the file is saved but after all
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3549
diff changeset
193 # inline fixes.
2882
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
194
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
195 self.__multiLineNumbers = None
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
196 self.__docLineNumbers = None
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
197
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
198 self.__lastID = 0
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 def saveFile(self, encoding):
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 """
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 Public method to save the modified file.
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 @param encoding encoding of the source file (string)
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
205 @return error message on failure (tuple of str)
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 """
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
207 import codecs
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
208
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 if not self.__modified:
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 # no need to write
6891
93f82da09f22 Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
211 return None
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
3549
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
213 if self.__createBackup:
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
214 # create a backup file before writing any changes
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
215 if os.path.islink(self.__filename):
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
216 bfn = '{0}~'.format(os.path.realpath(self.__filename))
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
217 else:
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
218 bfn = '{0}~'.format(self.__filename)
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
219 try:
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
220 os.remove(bfn)
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
221 except EnvironmentError:
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
222 # if there was an error, ignore it
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
223 pass
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
224 try:
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
225 os.rename(self.__filename, bfn)
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
226 except EnvironmentError:
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
227 # if there was an error, ignore it
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
228 pass
96ebf42cd960 Added the file backup functionality in the code style fixer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3546
diff changeset
229
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 txt = "".join(self.__source)
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 try:
3745
4c6f1782f530 Possible exception on fixing code styles fixed (only Python2).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
232 enc = 'utf-8' if encoding == 'utf-8-bom' else encoding
4c6f1782f530 Possible exception on fixing code styles fixed (only Python2).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
233 txt = txt.encode(enc)
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
234 if encoding == 'utf-8-bom':
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
235 txt = codecs.BOM_UTF8 + txt
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
236
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
237 with open(self.__filename, "wb") as fp:
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
238 fp.write(txt)
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
239 except (IOError, UnicodeError) as err:
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
240 # Could not save the file! Skipping it. Reason: {0}
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
241 return ("FIXWRITE_ERROR", [str(err)])
6891
93f82da09f22 Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
242
93f82da09f22 Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
243 return None
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
2878
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
245 def __codeMatch(self, code):
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
246 """
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
247 Private method to check, if the code should be fixed.
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
248
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
249 @param code to check (string)
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
250 @return flag indicating it should be fixed (boolean)
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
251 """
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
252 def mutualStartswith(a, b):
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
253 """
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
254 Local helper method to compare the beginnings of two strings
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
255 against each other.
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
256
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
257 @return flag indicating that one string starts with the other
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
258 (boolean)
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
259 """
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
260 return b.startswith(a) or a.startswith(b)
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
261
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
262 if self.__noFixCodes:
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
263 for noFixCode in [c.strip() for c in self.__noFixCodes]:
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
264 if mutualStartswith(code.lower(), noFixCode.lower()):
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
265 return False
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
266
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
267 if self.__fixCodes:
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
268 for fixCode in [c.strip() for c in self.__fixCodes]:
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
269 if mutualStartswith(code.lower(), fixCode.lower()):
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
270 return True
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
271 return False
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
272
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
273 return True
61042247f793 Added a button to the PEP-8 dialog to reset the default values.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2876
diff changeset
274
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
275 def fixIssue(self, line, pos, code):
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 Public method to fix the fixable issues.
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
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 line line number of the issue
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 int
df7025fe26a3 Code Style Checker: reworked the API between frontend and backend to get some more flexibility for the future.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7609
diff changeset
281 @param pos position inside 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
282 @type int
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
283 @param code code of the issue
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
284 @type str
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
285 @return value indicating an applied/deferred fix (-1, 0, 1),
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
286 a message code for the fix, arguments list for the 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
287 and an ID for a deferred fix
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
288 @rtype tuple of (int, str, list, int)
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 """
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
290 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
291 line <= len(self.__source) and
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
292 self.__codeMatch(code) and
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
293 code in self.__fixes
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
294 ):
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 res = self.__fixes[code](code, line, pos)
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
296 if res[0] == 1:
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.__modified = True
853
ec7dd115e26b Continued implementing a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 852
diff changeset
298 self.fixed += 1
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 else:
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
300 res = (0, "", [], 0)
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 return res
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
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
304 def finalize(self):
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
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
306 Public method to apply all deferred fixes.
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
307
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
308 @return dictionary containing the fix results
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 """
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
310 results = {}
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
311
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
312 # step 1: do fixes operating on logical lines first
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
313 for id_, code, line, pos in self.__stackLogical:
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
314 res, msg, args, _ = self.__fixes[code](code, line, pos, apply=True)
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
315 if res == 1:
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
316 self.__modified = True
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
317 self.fixed += 1
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
318 results[id_] = (res, msg, args)
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
319
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
320 # step 2: do fixes that change the number of lines
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
321 for id_, code, line, pos in reversed(self.__stack):
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
322 res, msg, args, _ = self.__fixes[code](code, line, pos, apply=True)
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
323 if res == 1:
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
324 self.__modified = True
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
325 self.fixed += 1
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
326 results[id_] = (res, msg, args)
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
327
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
328 return results
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
329
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
330 def __getID(self):
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
331 """
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
332 Private method to get the ID for a deferred fix.
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
333
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
334 @return ID for a deferred fix (integer)
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
335 """
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
336 self.__lastID += 1
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
337 return self.__lastID
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
339 def __findLogical(self):
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
340 """
2883
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
341 Private method to extract the index of all the starts and ends of
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
342 lines.
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
343
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
344 @return tuple containing two lists of integer with start and end tuples
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
345 of lines
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
346 """
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
347 logical_start = []
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
348 logical_end = []
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
349 last_newline = True
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
350 sio = StringIO("".join(self.__source))
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
351 parens = 0
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
352 for t in tokenize.generate_tokens(sio.readline):
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
353 if t[0] in [tokenize.COMMENT, tokenize.DEDENT,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
354 tokenize.INDENT, tokenize.NL,
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
355 tokenize.ENDMARKER]:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
356 continue
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
357 if not parens and t[0] in [tokenize.NEWLINE, tokenize.SEMI]:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
358 last_newline = True
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
359 logical_end.append((t[3][0] - 1, t[2][1]))
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
360 continue
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
361 if last_newline and not parens:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
362 logical_start.append((t[2][0] - 1, t[2][1]))
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
363 last_newline = False
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
364 if t[0] == tokenize.OP:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
365 if t[1] in '([{':
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
366 parens += 1
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
367 elif t[1] in '}])':
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
368 parens -= 1
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
369 return logical_start, logical_end
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
370
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
371 def __getLogical(self, line, pos):
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
372 """
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
373 Private method to get the logical line corresponding to the given
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
374 position.
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
375
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
376 @param line line number of the issue (integer)
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
377 @param pos position inside line (integer)
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
378 @return tuple of a tuple of two integers giving the start of the
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
379 logical line, another tuple of two integers giving the end
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
380 of the logical line and a list of strings with the original
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
381 source lines
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
382 """
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
383 try:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
384 (logical_start, logical_end) = self.__findLogical()
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
385 except (SyntaxError, tokenize.TokenError):
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
386 return None
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
387
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
388 line = line - 1
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
389 ls = None
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
390 le = None
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
391 for i in range(0, len(logical_start)):
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
392 x = logical_end[i]
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
393 if x[0] > line or (x[0] == line and x[1] > pos):
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
394 le = x
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
395 ls = logical_start[i]
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
396 break
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
397 if ls is None:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
398 return None
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
399
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
400 original = self.__source[ls[0]:le[0] + 1]
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
401 return ls, le, original
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
402
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
403 def __getIndentWord(self):
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
404 """
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
405 Private method to determine the indentation type.
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
407 @return string to be used for an indentation (string)
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
408 """
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
409 sio = StringIO("".join(self.__source))
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
410 indentWord = " " # default in case of failure
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
411 try:
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
412 for token in tokenize.generate_tokens(sio.readline):
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
413 if token[0] == tokenize.INDENT:
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
414 indentWord = token[1]
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
415 break
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
416 except (SyntaxError, tokenize.TokenError):
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
417 pass
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
418 return indentWord
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
419
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
420 def __getIndent(self, line):
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
421 """
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
422 Private method to get the indentation string.
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
423
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
424 @param line line to determine the indentation string from (string)
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
425 @return indentation string (string)
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
426 """
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
427 return line.replace(line.lstrip(), "")
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
428
2882
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
429 def __multilineStringLines(self):
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
430 """
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
431 Private method to determine the line numbers that are within multi line
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
432 strings and these which are part of a documentation string.
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
433
2883
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
434 @return tuple of a set of line numbers belonging to a multi line
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
435 string and a set of line numbers belonging to a multi line
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
436 documentation string (tuple of two set of integer)
2882
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
437 """
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
438 if self.__multiLineNumbers is None:
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
439 source = "".join(self.__source)
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
440 sio = StringIO(source)
2882
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
441 self.__multiLineNumbers = set()
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
442 self.__docLineNumbers = set()
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
443 previousTokenType = ''
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
444 try:
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
445 for t in tokenize.generate_tokens(sio.readline):
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
446 tokenType = t[0]
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
447 startRow = t[2][0]
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
448 endRow = t[3][0]
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
449
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
450 if (tokenType == tokenize.STRING and startRow != endRow):
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
451 if previousTokenType != tokenize.INDENT:
2883
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
452 self.__multiLineNumbers |= set(
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
453 range(startRow, 1 + endRow))
2882
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
454 else:
2883
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
455 self.__docLineNumbers |= set(
3c99a1db1506 Finished the PEP-8 line shortener.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2882
diff changeset
456 range(startRow, 1 + endRow))
2882
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
457
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
458 previousTokenType = tokenType
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
459 except (SyntaxError, tokenize.TokenError):
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
460 pass
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
461
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
462 return self.__multiLineNumbers, self.__docLineNumbers
9b97bc92fdda Continued implementing the PEP-8 line shortener class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2880
diff changeset
463
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
464 def __fixReindent(self, line, pos, logical):
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
465 """
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
466 Private method to fix a badly indented line.
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
467
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
468 This is done by adding or removing from its initial indent only.
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
469
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
470 @param line line number of the issue (integer)
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
471 @param pos position inside line (integer)
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
472 @param logical logical line structure
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
473 @return flag indicating a change was done (boolean)
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
474 @exception ValueError raised to indicate a bad 'logical' parameter
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
475 """
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
476 if not logical:
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
477 raise ValueError("Bad value for 'logical' parameter.")
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7610
diff changeset
478
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
479 ls, _, original = logical
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
480
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: 2976
diff changeset
481 rewrapper = IndentationWrapper(original)
2875
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
482 valid_indents = rewrapper.pep8Expected()
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
483 if not rewrapper.rel_indent:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
484 return False
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
485
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
486 if line > ls[0]:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
487 # got a valid continuation line number
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
488 row = line - ls[0] - 1
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
489 # always pick the first option for this
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
490 valid = valid_indents[row]
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
491 got = rewrapper.rel_indent[row]
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
492 else:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
493 return False
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
494
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
495 line1 = ls[0] + row
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
496 # always pick the expected indent, for now.
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
497 indent_to = valid[0]
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
498
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
499 if got != indent_to:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
500 orig_line = self.__source[line1]
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
501 new_line = ' ' * (indent_to) + orig_line.lstrip()
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
502 if new_line == orig_line:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
503 return False
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
504 else:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
505 self.__source[line1] = new_line
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
506 return True
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
507 else:
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
508 return False
1267f0663801 Continued implementing PEP-8 fixer methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2868
diff changeset
509
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
510 def __fixWhitespace(self, line, offset, replacement):
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
511 """
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
512 Private method to correct whitespace at the given offset.
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
513
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
514 @param line line to be corrected (string)
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
515 @param offset offset within line (integer)
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
516 @param replacement replacement string (string)
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
517 @return corrected line
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
518 """
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
519 left = line[:offset].rstrip(" \t")
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
520 right = line[offset:].lstrip(" \t")
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
521 if right.startswith("#"):
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
522 return line
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 else:
2868
8d30ec21e9c7 Extended the PEP8 fixer and adjusted it to the updated PEP8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
524 return left + replacement + right
849
996367a89673 Started to implement a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
526 def __fixD111(self, code, line, pos):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
527 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
528 Private method to fix docstring enclosed in wrong quotes.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
529
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
530 Codes: D111
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
531
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
532 @param code code of the issue
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
533 @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
534 @param line line number of the issue
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
535 @type int
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
536 @param pos position inside 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
537 @type int
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
538 @return value indicating an applied/deferred fix (-1, 0, 1),
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
539 a message code for the fix, a list of arguments for the
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
540 message and an ID for a deferred fix
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
541 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
542 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
543 line = line - 1
4150
a0cece581ad0 Fixed an issue in the code style fixer related to docstrings enclosed in ' or " quotes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
544 quotes = re.match(r"""\s*[ru]?('''|'|\")""",
a0cece581ad0 Fixed an issue in the code style fixer related to docstrings enclosed in ' or " quotes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
545 self.__source[line]).group(1)
a0cece581ad0 Fixed an issue in the code style fixer related to docstrings enclosed in ' or " quotes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
546 left, right = self.__source[line].split(quotes, 1)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
547 self.__source[line] = left + '"""' + right
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
548 while line < len(self.__source):
4150
a0cece581ad0 Fixed an issue in the code style fixer related to docstrings enclosed in ' or " quotes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
549 if self.__source[line].rstrip().endswith(quotes):
a0cece581ad0 Fixed an issue in the code style fixer related to docstrings enclosed in ' or " quotes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
550 left, right = self.__source[line].rsplit(quotes, 1)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
551 self.__source[line] = left + '"""' + right
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
552 break
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
553 line += 1
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
554
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
555 # Triple single quotes converted to triple double quotes.
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
556 return (1, "FIXD111", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
557
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
558 def __fixD112(self, code, line, pos):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
559 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
560 Private method to fix docstring 'r' or 'u' in leading quotes.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
561
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
562 Codes: D112, D113
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
563
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
564 @param code code of the issue
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
565 @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
566 @param line line number of the issue
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
567 @type int
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
568 @param pos position inside 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
569 @type int
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
570 @return value indicating an applied/deferred fix (-1, 0, 1),
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
571 a message code for the fix, a list of arguments for the
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
572 message and an ID for a deferred fix
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
573 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
574 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
575 line = line - 1
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
576 if code == "D112":
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
577 insertChar = "r"
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
578 elif code == "D113":
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
579 insertChar = "u"
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
580 else:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
581 return (0, "", 0)
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
582
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
583 newText = (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
584 self.__getIndent(self.__source[line]) +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
585 insertChar +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
586 self.__source[line].lstrip()
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
587 )
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
588 self.__source[line] = newText
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
589 # Introductory quotes corrected to be {0}"""
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
590 return (1, 'FIXD112', [insertChar], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
591
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
592 def __fixD121(self, code, line, pos, apply=False):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
593 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
594 Private method to fix a single line docstring on multiple lines.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
595
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
596 Codes: D121
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
597
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
598 @param code code of the issue
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
599 @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
600 @param line line number of the issue
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
601 @type int
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
602 @param pos position inside 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
603 @type int
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
604 @param apply flag indicating, that the fix should be applied
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
605 @type bool
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
606 @return value indicating an applied/deferred fix (-1, 0, 1),
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
607 a message code for the fix, a list of arguments for the
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
608 message and an ID for a deferred fix
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
609 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
610 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
611 if apply:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
612 line = line - 1
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
613 if not self.__source[line].lstrip().startswith(
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
614 ('"""', 'r"""', 'u"""')):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
615 # only correctly formatted docstrings will be fixed
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
616 return (0, "", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
617
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
618 docstring = (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
619 self.__source[line].rstrip() +
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
620 self.__source[line + 1].strip()
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
621 )
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
622 if docstring.endswith('"""'):
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
623 docstring += self.__eol
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
624 else:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
625 docstring += self.__source[line + 2].lstrip()
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
626 self.__source[line + 2] = ""
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
627
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
628 self.__source[line] = docstring
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
629 self.__source[line + 1] = ""
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
630 # Single line docstring put on one line.
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
631 return (1, "FIXD121", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
632 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
633 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
634 self.__stack.append((fixId, code, line, pos))
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
635 return (-1, "", [], fixId)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
636
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
637 def __fixD131(self, code, line, pos):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
638 """
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
639 Private method to fix a docstring summary not ending with a
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
640 period.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
641
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
642 Codes: D131
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
643
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
644 @param code code of the issue
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
645 @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
646 @param line line number of the issue
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
647 @type int
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
648 @param pos position inside 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
649 @type int
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
650 @return value indicating an applied/deferred fix (-1, 0, 1),
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
651 a message code for the fix, a list of arguments for the
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
652 message and an ID for a deferred fix
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
653 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
654 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
655 line = line - 1
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
656 newText = ""
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
657 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
658 self.__source[line].rstrip().endswith(('"""', "'''")) and
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
659 self.__source[line].lstrip().startswith(('"""', 'r"""', 'u"""'))
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
660 ):
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
661 # it is a one-liner
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
662 newText = (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
663 self.__source[line].rstrip()[:-3].rstrip() +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
664 "." +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
665 self.__source[line].rstrip()[-3:] +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
666 self.__eol
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
667 )
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
668 else:
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
669 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
670 line < len(self.__source) - 1 and
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
671 (not self.__source[line + 1].strip() or
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
672 self.__source[line + 1].lstrip().startswith("@") or
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
673 (self.__source[line + 1].strip() in ('"""', "'''") and
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
674 not self.__source[line].lstrip().startswith("@")))
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
675 ):
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
676 newText = self.__source[line].rstrip() + "." + self.__eol
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
677
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
678 if newText:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
679 self.__source[line] = newText
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
680 # Period added to summary line.
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
681 return (1, "FIXD131", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
682 else:
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
683 return (0, "", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
684
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
685 def __fixD141(self, code, line, pos, apply=False):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
686 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
687 Private method to fix a function/method docstring preceded by a
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
688 blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
689
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
690 Codes: D141
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
691
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
692 @param code code of the issue
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
693 @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
694 @param line line number of the issue
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
695 @type int
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
696 @param pos position inside 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
697 @type int
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
698 @param apply flag indicating, that the fix should be applied
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
699 @type bool
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
700 @return value indicating an applied/deferred fix (-1, 0, 1),
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
701 a message code for the fix, a list of arguments for the
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
702 message and an ID for a deferred fix
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
703 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
704 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
705 if apply:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
706 line = line - 1
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
707 self.__source[line - 1] = ""
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
708 # Blank line before function/method docstring removed.
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
709 return (1, "FIXD141", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
710 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
711 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
712 self.__stack.append((fixId, code, line, pos))
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
713 return (-1, "", [], fixId)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
714
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
715 def __fixD142(self, code, line, pos, apply=False):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
716 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
717 Private method to fix a class docstring not preceded by a
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
718 blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
719
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
720 Codes: D142
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
721
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
722 @param code code of the issue
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
723 @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
724 @param line line number of the issue
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
725 @type int
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
726 @param pos position inside 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
727 @type int
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
728 @param apply flag indicating, that the fix should be applied
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
729 @type bool
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
730 @return value indicating an applied/deferred fix (-1, 0, 1),
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
731 a message code for the fix, a list of arguments for the
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
732 message and an ID for a deferred fix
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
733 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
734 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
735 if apply:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
736 line = line - 1
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
737 self.__source[line] = self.__eol + self.__source[line]
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
738 # Blank line inserted before class docstring.
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
739 return (1, "FIXD142", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
740 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
741 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
742 self.__stack.append((fixId, code, line, pos))
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
743 return (-1, "", [], fixId)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
744
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
745 def __fixD143(self, code, line, pos, apply=False):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
746 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
747 Private method to fix a class docstring not followed by a
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
748 blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
749
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
750 Codes: D143
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
751
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
752 @param code code of the issue
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
753 @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
754 @param line line number of the issue
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
755 @type int
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
756 @param pos position inside 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
757 @type int
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
758 @param apply flag indicating, that the fix should be applied
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
759 @type bool
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
760 @return value indicating an applied/deferred fix (-1, 0, 1),
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
761 a message code for the fix, a list of arguments for the
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
762 message and an ID for a deferred fix
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
763 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
764 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
765 if apply:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
766 line = line - 1
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
767 self.__source[line] += self.__eol
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
768 # Blank line inserted after class docstring.
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
769 return (1, "FIXD143", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
770 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
771 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
772 self.__stack.append((fixId, code, line, pos))
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
773 return (-1, "", [], fixId)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
774
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
775 def __fixD144(self, code, line, pos, apply=False):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
776 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
777 Private method to fix a docstring summary not followed by a
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
778 blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
779
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
780 Codes: D144
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
781
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
782 @param code code of the issue
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
783 @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
784 @param line line number of the issue
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
785 @type int
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
786 @param pos position inside 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
787 @type int
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
788 @param apply flag indicating, that the fix should be applied
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
789 @type bool
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
790 @return value indicating an applied/deferred fix (-1, 0, 1),
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
791 a message code for the fix, a list of arguments for the
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
792 message and an ID for a deferred fix
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
793 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
794 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
795 if apply:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
796 line = line - 1
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
797 if not self.__source[line].rstrip().endswith("."):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
798 # only correct summary lines can be fixed here
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
799 return (0, "", 0)
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
800
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
801 self.__source[line] += self.__eol
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
802 # Blank line inserted after docstring summary.
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
803 return (1, "FIXD144", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
804 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
805 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
806 self.__stack.append((fixId, code, line, pos))
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
807 return (-1, "", [], fixId)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
808
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
809 def __fixD145(self, code, line, pos, apply=False):
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
810 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
811 Private method to fix the last paragraph of a multi-line docstring
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
812 not followed by a blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
813
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
814 Codes: D143
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
815
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
816 @param code code of the issue
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
817 @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
818 @param line line number of the issue
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
819 @type int
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
820 @param pos position inside 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
821 @type int
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
822 @param apply flag indicating, that the fix should be applied
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
823 @type bool
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
824 @return value indicating an applied/deferred fix (-1, 0, 1),
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
825 a message code for the fix, a list of arguments for the
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
826 message and an ID for a deferred fix
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
827 @rtype tuple of (int, str, list or int, int)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
828 """
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
829 if apply:
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
830 line = line - 1
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
831 self.__source[line] = self.__eol + self.__source[line]
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
832 # Blank line inserted after last paragraph of docstring.
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
833 return (1, "FIXD145", [], 0)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
834 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
835 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
836 self.__stack.append((fixId, code, line, pos))
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
837 return (-1, "", [], fixId)
2925
04896af1b0e1 Completed the PEP-257 fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2923
diff changeset
838
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
839 def __fixD221(self, code, line, pos, apply=False):
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
840 """
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
841 Private method to fix leading and trailing quotes of docstring
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
842 not on separate lines.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
843
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
844 Codes: D221, D222
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
845
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
846 @param code code of the issue
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
847 @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
848 @param line line number of the issue
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
849 @type int
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 @param pos position inside 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
851 @type int
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
852 @param apply flag indicating, that the fix should be applied
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
853 @type bool
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
854 @return value indicating an applied/deferred fix (-1, 0, 1),
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
855 a message code for the fix, a list of arguments for the
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
856 message and an ID for a deferred fix
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
857 @rtype tuple of (int, str, list or int, int)
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
858 """
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
859 if apply:
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
860 line = line - 1
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
861 indent = self.__getIndent(self.__source[line])
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
862 source = self.__source[line].strip()
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
863 if code == "D221":
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
864 # leading
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
865 if source.startswith(("r", "u")):
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
866 first, second = source[:4], source[4:].strip()
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
867 else:
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
868 first, second = source[:3], source[3:].strip()
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
869 else:
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
870 # trailing
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
871 first, second = source[:-3].strip(), source[-3:]
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
872 newText = (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
873 indent +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
874 first +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
875 self.__eol +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
876 indent +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
877 second +
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
878 self.__eol
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
879 )
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
880 self.__source[line] = newText
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
881 if code == "D221":
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
882 # Leading quotes put on separate line.
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
883 msg = "FIXD221"
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
884 else:
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
885 # Trailing quotes put on separate line.
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
886 msg = "FIXD222"
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
887 return (1, msg, [], 0)
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
888 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
889 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
890 self.__stack.append((fixId, code, line, pos))
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
891 return (-1, "", [], fixId)
2937
de26bc76d6ee Finished implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2936
diff changeset
892
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
893 def __fixD242(self, code, line, pos, apply=False):
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
894 """
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
895 Private method to fix a class or function/method docstring preceded
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
896 by a blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
897
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
898 Codes: D242, D244
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
899
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
900 @param code code of the issue
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
901 @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
902 @param line line number of the issue
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
903 @type int
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
904 @param pos position inside 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
905 @type int
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
906 @param apply flag indicating, that the fix should be applied
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
907 @type bool
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
908 @return value indicating an applied/deferred fix (-1, 0, 1),
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
909 a message code for the fix, a list of arguments for the
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
910 message and an ID for a deferred fix
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
911 @rtype tuple of (int, str, list or int, int)
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
912 """
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
913 if apply:
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
914 line = line - 1
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
915 self.__source[line - 1] = ""
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
916 if code == "D242":
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
917 # Blank line before class docstring removed.
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
918 msg = "FIXD242"
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
919 else:
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
920 # Blank line before function/method docstring removed.
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
921 msg = "FIXD244"
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
922 return (1, msg, [], 0)
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
923 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
924 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
925 self.__stack.append((fixId, code, line, pos))
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
926 return (-1, "", [], fixId)
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
927
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
928 def __fixD243(self, code, line, pos, apply=False):
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
929 """
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
930 Private method to fix a class or function/method docstring followed
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
931 by a blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
932
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
933 Codes: D243, D245
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
934
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
935 @param code code of the issue
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
936 @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
937 @param line line number of the issue
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
938 @type int
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
939 @param pos position inside 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
940 @type int
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
941 @param apply flag indicating, that the fix should be applied
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
942 @type bool
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
943 @return value indicating an applied/deferred fix (-1, 0, 1),
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
944 a message code for the fix, a list of arguments for the
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
945 message and an ID for a deferred fix
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
946 @rtype tuple of (int, str, list or int, int)
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
947 """
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
948 if apply:
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
949 line = line - 1
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
950 self.__source[line + 1] = ""
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
951 if code == "D243":
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
952 # Blank line after class docstring removed.
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
953 msg = "FIXD243"
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
954 else:
3413
5e63f809732a Code style checker: Translations extracted and refactored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3228
diff changeset
955 # Blank line after function/method docstring removed.
7609
d5aff4fd0ef8 Code Style Checker: changed the dialog to allow the selection of checker categories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
956 msg = "FIXD245"
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
957 return (1, msg, [], 0)
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
958 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
959 fixId = self.__getID()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
960 self.__stack.append((fixId, code, line, pos))
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
961 return (-1, "", [], fixId)
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
962
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
963 def __fixD247(self, code, line, pos, apply=False):
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
964 """
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
965 Private method to fix a last paragraph of a docstring followed
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
966 by a blank line.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
967
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2937
diff changeset
968 Codes: D247
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
969
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
970 @param code code of the issue
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
971 @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
972 @param line line number of the issue
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
973 @type int
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
974 @param pos position inside 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
975 @type int
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
976 @param apply flag indicating, that the fix should be applied
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
977 @type bool
2936
2ff273068a10 Started implementing fixer method for eric style docstring issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2925
diff changeset
978 @return value indicating an applied/deferred fix (-1, 0, 1),
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
979 a message code for the fix, a list of arguments for the
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
980 message and an ID for a deferred fix
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
981 @rtype tuple of (int, str, list or int, int)