diff options
author | Conley Owens <cco3@android.com> | 2012-10-25 09:51:06 -0700 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2012-10-25 09:51:07 -0700 |
commit | e4ed8f65f376009f70fab0e7978fdfc223f23a76 (patch) | |
tree | 00a9118857c613eefdd967d330bc5230ced01555 | |
parent | fdb44479f8b99e7795021f1b8588a677dcf5fd51 (diff) | |
parent | 4f7bdea9d24c4eb52f83ada2b67b88ad67cb57a7 (diff) | |
download | git-repo-e4ed8f65f376009f70fab0e7978fdfc223f23a76.tar.gz |
Merge "Add pylint configuration and instructions"
-rw-r--r-- | .pylintrc | 301 | ||||
-rw-r--r-- | SUBMITTING_PATCHES | 12 | ||||
-rw-r--r-- | command.py | 4 | ||||
-rw-r--r-- | manifest_xml.py | 2 | ||||
-rw-r--r-- | subcmds/forall.py | 4 |
5 files changed, 316 insertions, 7 deletions
diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..9f81ee15 --- /dev/null +++ b/.pylintrc | |||
@@ -0,0 +1,301 @@ | |||
1 | # lint Python modules using external checkers. | ||
2 | # | ||
3 | # This is the main checker controling the other ones and the reports | ||
4 | # generation. It is itself both a raw checker and an astng checker in order | ||
5 | # to: | ||
6 | # * handle message activation / deactivation at the module level | ||
7 | # * handle some basic but necessary stats'data (number of classes, methods...) | ||
8 | # | ||
9 | [MASTER] | ||
10 | |||
11 | # Specify a configuration file. | ||
12 | #rcfile= | ||
13 | |||
14 | # Python code to execute, usually for sys.path manipulation such as | ||
15 | # pygtk.require(). | ||
16 | #init-hook= | ||
17 | |||
18 | # Profiled execution. | ||
19 | profile=no | ||
20 | |||
21 | # Add <file or directory> to the black list. It should be a base name, not a | ||
22 | # path. You may set this option multiple times. | ||
23 | ignore=SVN | ||
24 | |||
25 | # Pickle collected data for later comparisons. | ||
26 | persistent=yes | ||
27 | |||
28 | # Set the cache size for astng objects. | ||
29 | cache-size=500 | ||
30 | |||
31 | # List of plugins (as comma separated values of python modules names) to load, | ||
32 | # usually to register additional checkers. | ||
33 | load-plugins= | ||
34 | |||
35 | |||
36 | [MESSAGES CONTROL] | ||
37 | |||
38 | # Enable only checker(s) with the given id(s). This option conflicts with the | ||
39 | # disable-checker option | ||
40 | #enable-checker= | ||
41 | |||
42 | # Enable all checker(s) except those with the given id(s). This option | ||
43 | # conflicts with the enable-checker option | ||
44 | #disable-checker= | ||
45 | |||
46 | # Enable all messages in the listed categories. | ||
47 | #enable-msg-cat= | ||
48 | |||
49 | # Disable all messages in the listed categories. | ||
50 | #disable-msg-cat= | ||
51 | |||
52 | # Enable the message(s) with the given id(s). | ||
53 | enable=RP0004 | ||
54 | |||
55 | # Disable the message(s) with the given id(s). | ||
56 | disable=R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,C0323,C0322,C0324,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,W0311,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801 | ||
57 | |||
58 | [REPORTS] | ||
59 | |||
60 | # set the output format. Available formats are text, parseable, colorized, msvs | ||
61 | # (visual studio) and html | ||
62 | output-format=text | ||
63 | |||
64 | # Include message's id in output | ||
65 | include-ids=yes | ||
66 | |||
67 | # Put messages in a separate file for each module / package specified on the | ||
68 | # command line instead of printing them on stdout. Reports (if any) will be | ||
69 | # written in a file name "pylint_global.[txt|html]". | ||
70 | files-output=no | ||
71 | |||
72 | # Tells whether to display a full report or only the messages | ||
73 | reports=yes | ||
74 | |||
75 | # Python expression which should return a note less than 10 (10 is the highest | ||
76 | # note).You have access to the variables errors warning, statement which | ||
77 | # respectivly contain the number of errors / warnings messages and the total | ||
78 | # number of statements analyzed. This is used by the global evaluation report | ||
79 | # (R0004). | ||
80 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) | ||
81 | |||
82 | # Add a comment according to your evaluation note. This is used by the global | ||
83 | # evaluation report (R0004). | ||
84 | comment=no | ||
85 | |||
86 | # checks for | ||
87 | # * unused variables / imports | ||
88 | # * undefined variables | ||
89 | # * redefinition of variable from builtins or from an outer scope | ||
90 | # * use of variable before assigment | ||
91 | # | ||
92 | [VARIABLES] | ||
93 | |||
94 | # Tells whether we should check for unused import in __init__ files. | ||
95 | init-import=no | ||
96 | |||
97 | # A regular expression matching names used for dummy variables (i.e. not used). | ||
98 | dummy-variables-rgx=_|dummy | ||
99 | |||
100 | # List of additional names supposed to be defined in builtins. Remember that | ||
101 | # you should avoid to define new builtins when possible. | ||
102 | additional-builtins= | ||
103 | |||
104 | |||
105 | # try to find bugs in the code using type inference | ||
106 | # | ||
107 | [TYPECHECK] | ||
108 | |||
109 | # Tells whether missing members accessed in mixin class should be ignored. A | ||
110 | # mixin class is detected if its name ends with "mixin" (case insensitive). | ||
111 | ignore-mixin-members=yes | ||
112 | |||
113 | # List of classes names for which member attributes should not be checked | ||
114 | # (useful for classes with attributes dynamicaly set). | ||
115 | ignored-classes=SQLObject | ||
116 | |||
117 | # When zope mode is activated, consider the acquired-members option to ignore | ||
118 | # access to some undefined attributes. | ||
119 | zope=no | ||
120 | |||
121 | # List of members which are usually get through zope's acquisition mecanism and | ||
122 | # so shouldn't trigger E0201 when accessed (need zope=yes to be considered). | ||
123 | acquired-members=REQUEST,acl_users,aq_parent | ||
124 | |||
125 | |||
126 | # checks for : | ||
127 | # * doc strings | ||
128 | # * modules / classes / functions / methods / arguments / variables name | ||
129 | # * number of arguments, local variables, branchs, returns and statements in | ||
130 | # functions, methods | ||
131 | # * required module attributes | ||
132 | # * dangerous default values as arguments | ||
133 | # * redefinition of function / method / class | ||
134 | # * uses of the global statement | ||
135 | # | ||
136 | [BASIC] | ||
137 | |||
138 | # Required attributes for module, separated by a comma | ||
139 | required-attributes= | ||
140 | |||
141 | # Regular expression which should only match functions or classes name which do | ||
142 | # not require a docstring | ||
143 | no-docstring-rgx=_main|__.*__ | ||
144 | |||
145 | # Regular expression which should only match correct module names | ||
146 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ | ||
147 | |||
148 | # Regular expression which should only match correct module level names | ||
149 | const-rgx=(([A-Z_][A-Z1-9_]*)|(__.*__))|(log)$ | ||
150 | |||
151 | # Regular expression which should only match correct class names | ||
152 | class-rgx=[A-Z_][a-zA-Z0-9]+$ | ||
153 | |||
154 | # Regular expression which should only match correct function names | ||
155 | function-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
156 | |||
157 | # Regular expression which should only match correct method names | ||
158 | method-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
159 | |||
160 | # Regular expression which should only match correct instance attribute names | ||
161 | attr-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
162 | |||
163 | # Regular expression which should only match correct argument names | ||
164 | argument-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
165 | |||
166 | # Regular expression which should only match correct variable names | ||
167 | variable-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
168 | |||
169 | # Regular expression which should only match correct list comprehension / | ||
170 | # generator expression variable names | ||
171 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ | ||
172 | |||
173 | # Good variable names which should always be accepted, separated by a comma | ||
174 | good-names=i,j,k,ex,Run,_,e,d1,d2,v,f,l,d | ||
175 | |||
176 | # Bad variable names which should always be refused, separated by a comma | ||
177 | bad-names=foo,bar,baz,toto,tutu,tata | ||
178 | |||
179 | # List of builtins function names that should not be used, separated by a comma | ||
180 | bad-functions=map,filter,apply,input | ||
181 | |||
182 | |||
183 | # checks for sign of poor/misdesign: | ||
184 | # * number of methods, attributes, local variables... | ||
185 | # * size, complexity of functions, methods | ||
186 | # | ||
187 | [DESIGN] | ||
188 | |||
189 | # Maximum number of arguments for function / method | ||
190 | max-args=5 | ||
191 | |||
192 | # Maximum number of locals for function / method body | ||
193 | max-locals=15 | ||
194 | |||
195 | # Maximum number of return / yield for function / method body | ||
196 | max-returns=6 | ||
197 | |||
198 | # Maximum number of branch for function / method body | ||
199 | max-branchs=12 | ||
200 | |||
201 | # Maximum number of statements in function / method body | ||
202 | max-statements=50 | ||
203 | |||
204 | # Maximum number of parents for a class (see R0901). | ||
205 | max-parents=7 | ||
206 | |||
207 | # Maximum number of attributes for a class (see R0902). | ||
208 | max-attributes=20 | ||
209 | |||
210 | # Minimum number of public methods for a class (see R0903). | ||
211 | min-public-methods=2 | ||
212 | |||
213 | # Maximum number of public methods for a class (see R0904). | ||
214 | max-public-methods=30 | ||
215 | |||
216 | |||
217 | # checks for | ||
218 | # * external modules dependencies | ||
219 | # * relative / wildcard imports | ||
220 | # * cyclic imports | ||
221 | # * uses of deprecated modules | ||
222 | # | ||
223 | [IMPORTS] | ||
224 | |||
225 | # Deprecated modules which should not be used, separated by a comma | ||
226 | deprecated-modules=regsub,string,TERMIOS,Bastion,rexec | ||
227 | |||
228 | # Create a graph of every (i.e. internal and external) dependencies in the | ||
229 | # given file (report R0402 must not be disabled) | ||
230 | import-graph= | ||
231 | |||
232 | # Create a graph of external dependencies in the given file (report R0402 must | ||
233 | # not be disabled) | ||
234 | ext-import-graph= | ||
235 | |||
236 | # Create a graph of internal dependencies in the given file (report R0402 must | ||
237 | # not be disabled) | ||
238 | int-import-graph= | ||
239 | |||
240 | |||
241 | # checks for : | ||
242 | # * methods without self as first argument | ||
243 | # * overridden methods signature | ||
244 | # * access only to existant members via self | ||
245 | # * attributes not defined in the __init__ method | ||
246 | # * supported interfaces implementation | ||
247 | # * unreachable code | ||
248 | # | ||
249 | [CLASSES] | ||
250 | |||
251 | # List of interface methods to ignore, separated by a comma. This is used for | ||
252 | # instance to not check methods defines in Zope's Interface base class. | ||
253 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by | ||
254 | |||
255 | # List of method names used to declare (i.e. assign) instance attributes. | ||
256 | defining-attr-methods=__init__,__new__,setUp | ||
257 | |||
258 | |||
259 | # checks for similarities and duplicated code. This computation may be | ||
260 | # memory / CPU intensive, so you should disable it if you experiments some | ||
261 | # problems. | ||
262 | # | ||
263 | [SIMILARITIES] | ||
264 | |||
265 | # Minimum lines number of a similarity. | ||
266 | min-similarity-lines=4 | ||
267 | |||
268 | # Ignore comments when computing similarities. | ||
269 | ignore-comments=yes | ||
270 | |||
271 | # Ignore docstrings when computing similarities. | ||
272 | ignore-docstrings=yes | ||
273 | |||
274 | |||
275 | # checks for: | ||
276 | # * warning notes in the code like FIXME, XXX | ||
277 | # * PEP 263: source code with non ascii character but no encoding declaration | ||
278 | # | ||
279 | [MISCELLANEOUS] | ||
280 | |||
281 | # List of note tags to take in consideration, separated by a comma. | ||
282 | notes=FIXME,XXX,TODO | ||
283 | |||
284 | |||
285 | # checks for : | ||
286 | # * unauthorized constructions | ||
287 | # * strict indentation | ||
288 | # * line length | ||
289 | # * use of <> instead of != | ||
290 | # | ||
291 | [FORMAT] | ||
292 | |||
293 | # Maximum number of characters on a single line. | ||
294 | max-line-length=80 | ||
295 | |||
296 | # Maximum number of lines in a module | ||
297 | max-module-lines=1000 | ||
298 | |||
299 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 | ||
300 | # tab). In repo it is 2 spaces. | ||
301 | indent-string=' ' | ||
diff --git a/SUBMITTING_PATCHES b/SUBMITTING_PATCHES index cba67416..50e2cf77 100644 --- a/SUBMITTING_PATCHES +++ b/SUBMITTING_PATCHES | |||
@@ -2,6 +2,7 @@ Short Version: | |||
2 | 2 | ||
3 | - Make small logical changes. | 3 | - Make small logical changes. |
4 | - Provide a meaningful commit message. | 4 | - Provide a meaningful commit message. |
5 | - Check for coding errors with pylint | ||
5 | - Make sure all code is under the Apache License, 2.0. | 6 | - Make sure all code is under the Apache License, 2.0. |
6 | - Publish your changes for review: | 7 | - Publish your changes for review: |
7 | 8 | ||
@@ -33,7 +34,14 @@ If your description starts to get too long, that's a sign that you | |||
33 | probably need to split up your commit to finer grained pieces. | 34 | probably need to split up your commit to finer grained pieces. |
34 | 35 | ||
35 | 36 | ||
36 | (2) Check the license | 37 | (2) Check for coding errors with pylint |
38 | |||
39 | Run pylint on changed modules using the provided configuration: | ||
40 | |||
41 | pylint --rcfile=.pylintrc file.py | ||
42 | |||
43 | |||
44 | (3) Check the license | ||
37 | 45 | ||
38 | repo is licensed under the Apache License, 2.0. | 46 | repo is licensed under the Apache License, 2.0. |
39 | 47 | ||
@@ -49,7 +57,7 @@ your patch. It is virtually impossible to remove a patch once it | |||
49 | has been applied and pushed out. | 57 | has been applied and pushed out. |
50 | 58 | ||
51 | 59 | ||
52 | (3) Sending your patches. | 60 | (4) Sending your patches. |
53 | 61 | ||
54 | Do not email your patches to anyone. | 62 | Do not email your patches to anyone. |
55 | 63 | ||
@@ -147,7 +147,7 @@ class Command(object): | |||
147 | result.sort(key=_getpath) | 147 | result.sort(key=_getpath) |
148 | return result | 148 | return result |
149 | 149 | ||
150 | # pylint: disable-msg=W0223 | 150 | # pylint: disable=W0223 |
151 | # Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not | 151 | # Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not |
152 | # override method `Execute` which is abstract in `Command`. Since that method | 152 | # override method `Execute` which is abstract in `Command`. Since that method |
153 | # is always implemented in classes derived from `InteractiveCommand` and | 153 | # is always implemented in classes derived from `InteractiveCommand` and |
@@ -166,7 +166,7 @@ class PagedCommand(Command): | |||
166 | def WantPager(self, opt): | 166 | def WantPager(self, opt): |
167 | return True | 167 | return True |
168 | 168 | ||
169 | # pylint: enable-msg=W0223 | 169 | # pylint: enable=W0223 |
170 | 170 | ||
171 | class MirrorSafeCommand(object): | 171 | class MirrorSafeCommand(object): |
172 | """Command permits itself to run within a mirror, | 172 | """Command permits itself to run within a mirror, |
diff --git a/manifest_xml.py b/manifest_xml.py index a2a56e92..71dbdc7d 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -336,7 +336,7 @@ class XmlManifest(object): | |||
336 | raise ManifestParseError("no <manifest> in %s" % (path,)) | 336 | raise ManifestParseError("no <manifest> in %s" % (path,)) |
337 | 337 | ||
338 | nodes = [] | 338 | nodes = [] |
339 | for node in manifest.childNodes: # pylint:disable-msg=W0631 | 339 | for node in manifest.childNodes: # pylint:disable=W0631 |
340 | # We only get here if manifest is initialised | 340 | # We only get here if manifest is initialised |
341 | if node.nodeName == 'include': | 341 | if node.nodeName == 'include': |
342 | name = self._reqatt(node, 'name') | 342 | name = self._reqatt(node, 'name') |
diff --git a/subcmds/forall.py b/subcmds/forall.py index 2ece95ed..b633b7d4 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -143,14 +143,14 @@ terminal and are not redirected. | |||
143 | break | 143 | break |
144 | else: | 144 | else: |
145 | cn = None | 145 | cn = None |
146 | # pylint: disable-msg=W0631 | 146 | # pylint: disable=W0631 |
147 | if cn and cn in _CAN_COLOR: | 147 | if cn and cn in _CAN_COLOR: |
148 | class ColorCmd(Coloring): | 148 | class ColorCmd(Coloring): |
149 | def __init__(self, config, cmd): | 149 | def __init__(self, config, cmd): |
150 | Coloring.__init__(self, config, cmd) | 150 | Coloring.__init__(self, config, cmd) |
151 | if ColorCmd(self.manifest.manifestProject.config, cn).is_on: | 151 | if ColorCmd(self.manifest.manifestProject.config, cn).is_on: |
152 | cmd.insert(cmd.index(cn) + 1, '--color') | 152 | cmd.insert(cmd.index(cn) + 1, '--color') |
153 | # pylint: enable-msg=W0631 | 153 | # pylint: enable=W0631 |
154 | 154 | ||
155 | mirror = self.manifest.IsMirror | 155 | mirror = self.manifest.IsMirror |
156 | out = ForallColoring(self.manifest.manifestProject.config) | 156 | out = ForallColoring(self.manifest.manifestProject.config) |