vigiboard / pylint_vigiboard.py @ c49defb8
History | View | Annotate | Download (2.26 KB)
1 |
#!/usr/bin/python
|
---|---|
2 |
"""
|
3 |
custom script that calls pylint with a special set of parameters.
|
4 |
"""
|
5 |
import sys |
6 |
import os |
7 |
|
8 |
# check if pylint is installed and import it
|
9 |
try:
|
10 |
from pylint import lint |
11 |
except ImportError: |
12 |
print "Can't import module pylint. Did you install it?" |
13 |
sys.exit(-1)
|
14 |
|
15 |
# either use the files given on the command line or all '*.py' files
|
16 |
# located in and beyond the working directory
|
17 |
if len(sys.argv) >1: |
18 |
#may add some parsing for --switches?
|
19 |
FILES = sys.argv[1:]
|
20 |
else:
|
21 |
FILES = [] |
22 |
for dirpath, dirnames, filenames in os.walk(os.getcwd()): |
23 |
FILES.extend( |
24 |
os.path.join(dirpath, filename) |
25 |
for filename in filenames |
26 |
if ".py" == filename[-3:] |
27 |
) |
28 |
|
29 |
# A list of messages that should not be printed by pylint.
|
30 |
SUPRESSED_MESSAGES = [ |
31 |
# 'I0011', # Used when an inline option disable a message or a messages category
|
32 |
'F0401', # Used when pylint has been unable to import a module. |
33 |
# If you decided to globally switch of a certain message instead of doing so
|
34 |
# in file or scope where its generated then you can just uncomment it here.
|
35 |
# Or add it if its not in the list.
|
36 |
# 'E1101', # Used when a class is accessed for an unexistant member.
|
37 |
# 'E0602', # Used when an undefined variable is accessed.
|
38 |
# 'W0232', # Used when a class has no __init__ method, neither its parent
|
39 |
# # classes.
|
40 |
# 'W0401', # Used when `from module import *` is detected.
|
41 |
'E0611', # Used when a name cannot be found in a module. |
42 |
# 'W0611', # Used when an imported module or variable is not used.
|
43 |
'R0201', # Used when a method doesn't use its bound instance, and so could |
44 |
# be written as a function.
|
45 |
# 'W0102', # Used when a mutable value as list or dictionary is detected in a default
|
46 |
# value for an argument.
|
47 |
'W0142', # Used when a function or method is called using *args or **kwargs to |
48 |
# dispatch arguments. This doesn't improve readility and should be
|
49 |
# used with care.
|
50 |
'R0801', # Indicates that a set of similar lines has been detected among |
51 |
# multiple file.
|
52 |
] |
53 |
|
54 |
PARAMS = [ |
55 |
#'--reports=n',
|
56 |
'--include-ids=y',
|
57 |
'--const-rgx=(([a-z_][a-z0-9_]*)|(__.*__))$',
|
58 |
'--disable-msg=%s' % ",".join(SUPRESSED_MESSAGES), |
59 |
] |
60 |
PARAMS.extend(FILES) |
61 |
lint.Run(PARAMS) |