Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:master commit in: /, bin/
Date: Tue, 06 Oct 2015 18:03:52
Message-Id: 1444154595.cdfa003b267c02828291c0228d33ea845cb79946.vapier@gentoo
1 commit: cdfa003b267c02828291c0228d33ea845cb79946
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Tue Oct 6 03:19:43 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 6 18:03:15 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=cdfa003b
7
8 pylint: add a helper for linting code
9
10 A bunch of warnings are left disabled because there's too many violations
11 in the current code base. Hopefully we can get to a point where everyone
12 uses this though and we can start enabling more and more.
13
14 The code base is "clean" right now in the sense that running pylint will
15 not produce any output. But we should start removing violations one by
16 one and re-enable the warning class as we go.
17
18 .pylintrc | 249 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 bin/pylint | 31 ++++++++
20 2 files changed, 280 insertions(+)
21
22 diff --git a/.pylintrc b/.pylintrc
23 new file mode 100644
24 index 0000000..b3327cf
25 --- /dev/null
26 +++ b/.pylintrc
27 @@ -0,0 +1,249 @@
28 +[MASTER]
29 +
30 +# Profiled execution.
31 +profile=no
32 +
33 +# Add files or directories to the blacklist. They should be base names, not
34 +# paths.
35 +ignore=
36 +
37 +# Pickle collected data for later comparisons.
38 +persistent=yes
39 +
40 +# List of plugins (as comma separated values of python modules names) to load,
41 +# usually to register additional checkers.
42 +load-plugins=
43 +
44 +
45 +[MESSAGES CONTROL]
46 +
47 +# Enable the message, report, category or checker with the given id(s). You can
48 +# either give multiple identifier separated by comma (,) or put this option
49 +# multiple time.
50 +#enable=
51 +
52 +# Disable the message, report, category or checker with the given id(s). You
53 +# can either give multiple identifier separated by comma (,) or put this option
54 +# multiple time (only on the command line, not in the configuration file where
55 +# it should appear only once).
56 +# We should clean up things so we can enable:
57 +# missing-docstring -- add lots of docstrings everywhere!
58 +# bad-whitespace -- fix spacing everywhere
59 +# bad-continuation -- might be hard with tab indentation policy
60 +# invalid-name -- need to manage constants better
61 +# line-too-long -- figure out a length and stick to it
62 +# unidiomatic-typecheck -- convert to isinstance
63 +# redefined-outer-name -- clean up code to not do this
64 +# super-init-not-called -- fix the classes __init__ structure
65 +# no-init -- update classes w/missing __init__ functions
66 +disable=missing-docstring, too-many-lines, too-many-branches, too-many-statements, too-few-public-methods, too-many-instance-attributes, too-many-public-methods, too-many-locals, too-many-arguments, locally-enabled, locally-disabled, fixme, broad-except, bad-whitespace, bad-continuation, invalid-name, line-too-long, unidiomatic-typecheck, redefined-outer-name, super-init-not-called, no-init
67 +
68 +
69 +[REPORTS]
70 +
71 +# Set the output format. Available formats are text, parseable, colorized, msvs
72 +# (visual studio) and html
73 +output-format=text
74 +
75 +# Put messages in a separate file for each module / package specified on the
76 +# command line instead of printing them on stdout. Reports (if any) will be
77 +# written in a file name "pylint_global.[txt|html]".
78 +files-output=no
79 +
80 +# Tells whether to display a full report or only the messages
81 +reports=no
82 +
83 +# Python expression which should return a note less than 10 (10 is the highest
84 +# note). You have access to the variables errors warning, statement which
85 +# respectively contain the number of errors / warnings messages and the total
86 +# number of statements analyzed. This is used by the global evaluation report
87 +# (RP0004).
88 +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
89 +
90 +# Add a comment according to your evaluation note. This is used by the global
91 +# evaluation report (RP0004).
92 +comment=no
93 +
94 +
95 +[FORMAT]
96 +
97 +# Maximum number of characters on a single line.
98 +max-line-length=80
99 +
100 +# Maximum number of lines in a module
101 +max-module-lines=1000
102 +
103 +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
104 +# tab).
105 +indent-string='\t'
106 +
107 +
108 +[MISCELLANEOUS]
109 +
110 +# List of note tags to take in consideration, separated by a comma.
111 +notes=FIXME,XXX,TODO
112 +
113 +
114 +[VARIABLES]
115 +
116 +# Tells whether we should check for unused import in __init__ files.
117 +init-import=no
118 +
119 +# A regular expression matching the beginning of the name of dummy variables
120 +# (i.e. not used).
121 +dummy-variables-rgx=_|dummy
122 +
123 +# List of additional names supposed to be defined in builtins. Remember that
124 +# you should avoid to define new builtins when possible.
125 +additional-builtins=
126 +
127 +
128 +[TYPECHECK]
129 +
130 +# Tells whether missing members accessed in mixin class should be ignored. A
131 +# mixin class is detected if its name ends with "mixin" (case insensitive).
132 +ignore-mixin-members=yes
133 +
134 +# List of classes names for which member attributes should not be checked
135 +# (useful for classes with attributes dynamically set).
136 +ignored-classes=SQLObject,twisted.internet.reactor,hashlib,google.appengine.api.memcache
137 +
138 +# When zope mode is activated, add a predefined set of Zope acquired attributes
139 +# to generated-members.
140 +zope=no
141 +
142 +# List of members which are set dynamically and missed by pylint inference
143 +# system, and so shouldn't trigger E0201 when accessed. Python regular
144 +# expressions are accepted.
145 +generated-members=REQUEST,acl_users,aq_parent,multiprocessing.managers.SyncManager
146 +
147 +
148 +[BASIC]
149 +
150 +# Required attributes for module, separated by a comma
151 +required-attributes=
152 +
153 +# List of builtins function names that should not be used, separated by a comma
154 +bad-functions=map,filter,apply,input
155 +
156 +# Regular expression which should only match correct module names
157 +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
158 +
159 +# Regular expression which should only match correct module level names
160 +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
161 +
162 +# Regular expression which should only match correct class names
163 +class-rgx=[A-Z_][a-zA-Z0-9]+$
164 +
165 +# Regular expression which should only match correct function names
166 +function-rgx=[a-z_][a-z0-9_]{2,30}$
167 +
168 +# Regular expression which should only match correct method names
169 +method-rgx=[a-z_][a-z0-9_]{2,30}$
170 +
171 +# Regular expression which should only match correct instance attribute names
172 +attr-rgx=[a-z_][a-z0-9_]{2,30}$
173 +
174 +# Regular expression which should only match correct argument names
175 +argument-rgx=[a-z_][a-z0-9_]{2,30}$
176 +
177 +# Regular expression which should only match correct variable names
178 +variable-rgx=[a-z_][a-z0-9_]{2,30}$
179 +
180 +# Regular expression which should only match correct list comprehension /
181 +# generator expression variable names
182 +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
183 +
184 +# Good variable names which should always be accepted, separated by a comma
185 +good-names=i,j,k,ex,Run,_
186 +
187 +# Bad variable names which should always be refused, separated by a comma
188 +bad-names=foo,bar,baz,toto,tutu,tata
189 +
190 +# Regular expression which should only match functions or classes name which do
191 +# not require a docstring
192 +no-docstring-rgx=__.*__
193 +
194 +
195 +[SIMILARITIES]
196 +
197 +# Minimum lines number of a similarity.
198 +min-similarity-lines=20
199 +
200 +# Ignore comments when computing similarities.
201 +ignore-comments=yes
202 +
203 +# Ignore docstrings when computing similarities.
204 +ignore-docstrings=yes
205 +
206 +
207 +[IMPORTS]
208 +
209 +# Deprecated modules which should not be used, separated by a comma
210 +deprecated-modules=regsub,string,TERMIOS,Bastion,rexec,optparse,getopt
211 +
212 +# Create a graph of every (i.e. internal and external) dependencies in the
213 +# given file (report RP0402 must not be disabled)
214 +import-graph=
215 +
216 +# Create a graph of external dependencies in the given file (report RP0402 must
217 +# not be disabled)
218 +ext-import-graph=
219 +
220 +# Create a graph of internal dependencies in the given file (report RP0402 must
221 +# not be disabled)
222 +int-import-graph=
223 +
224 +
225 +[CLASSES]
226 +
227 +# List of interface methods to ignore, separated by a comma. This is used for
228 +# instance to not check methods defines in Zope's Interface base class.
229 +ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
230 +
231 +# List of method names used to declare (i.e. assign) instance attributes.
232 +defining-attr-methods=__init__,__new__,setUp
233 +
234 +# List of valid names for the first argument in a class method.
235 +valid-classmethod-first-arg=cls
236 +
237 +
238 +[DESIGN]
239 +
240 +# Maximum number of arguments for function / method
241 +max-args=5
242 +
243 +# Argument names that match this expression will be ignored. Default to name
244 +# with leading underscore
245 +ignored-argument-names=_.*
246 +
247 +# Maximum number of locals for function / method body
248 +max-locals=15
249 +
250 +# Maximum number of return / yield for function / method body
251 +max-returns=6
252 +
253 +# Maximum number of branch for function / method body
254 +max-branchs=12
255 +
256 +# Maximum number of statements in function / method body
257 +max-statements=50
258 +
259 +# Maximum number of parents for a class (see R0901).
260 +max-parents=7
261 +
262 +# Maximum number of attributes for a class (see R0902).
263 +max-attributes=7
264 +
265 +# Minimum number of public methods for a class (see R0903).
266 +min-public-methods=2
267 +
268 +# Maximum number of public methods for a class (see R0904).
269 +max-public-methods=20
270 +
271 +
272 +[EXCEPTIONS]
273 +
274 +# Exceptions that will emit a warning when being caught. Defaults to
275 +# "Exception"
276 +overgeneral-exceptions=Exception
277
278 diff --git a/bin/pylint b/bin/pylint
279 new file mode 100755
280 index 0000000..1a50609
281 --- /dev/null
282 +++ b/bin/pylint
283 @@ -0,0 +1,31 @@
284 +#!/usr/bin/python
285 +# Copyright 1999-2015 Gentoo Foundation
286 +# Distributed under the terms of the GNU General Public License v2
287 +
288 +"""Run pylint with the right settings."""
289 +
290 +from __future__ import print_function
291 +
292 +import os
293 +import sys
294 +
295 +
296 +def main(argv):
297 + """The main entry point"""
298 + source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
299 +
300 + pympath = source_root
301 + pythonpath = os.environ.get('PYTHONPATH')
302 + if pythonpath is None:
303 + pythonpath = pympath
304 + else:
305 + pythonpath = pympath + ':' + pythonpath
306 + os.environ['PYTHONPATH'] = pythonpath
307 +
308 + pylintrc = os.path.join(source_root, '.pylintrc')
309 + cmd = ['pylint', '--rcfile', pylintrc]
310 + os.execvp(cmd[0], cmd + argv)
311 +
312 +
313 +if __name__ == '__main__':
314 + main(sys.argv[1:])