Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: utils/run_pylint.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python -u 1 #!/usr/bin/python -u
2 2
3 import os, sys, fnmatch 3 import os, sys, fnmatch
4 import common 4 import common
5 5
6 # do a basic check to see if pylint is even installed 6 # do a basic check to see if pylint is even installed
7 try: 7 try:
8 import pylint 8 import pylint
9 from pylint.__pkginfo__ import version as pylint_version
9 except ImportError: 10 except ImportError:
10 print "Unable to import pylint, it may need to be installed" 11 print "Unable to import pylint, it may need to be installed"
11 sys.exit(1) 12 sys.exit(1)
12 13
14 major, minor, release = pylint_version.split('.')
15 pylint_version = float("%s.%s" % (major, minor))
13 pylintrc_path = os.path.expanduser('~/.pylintrc') 16 pylintrc_path = os.path.expanduser('~/.pylintrc')
14 if not os.path.exists(pylintrc_path): 17 if not os.path.exists(pylintrc_path):
15 open(pylintrc_path, 'w').close() 18 open(pylintrc_path, 'w').close()
16 19
17 20
18 # patch up the logilab module lookup tools to understand autotest_lib.* trash 21 # patch up the logilab module lookup tools to understand autotest_lib.* trash
19 import logilab.common.modutils 22 import logilab.common.modutils
20 _ffm = logilab.common.modutils.file_from_modpath 23 _ffm = logilab.common.modutils.file_from_modpath
21 def file_from_modpath(modpath, path=None, context_file=None): 24 def file_from_modpath(modpath, path=None, context_file=None):
22 if modpath[0] == "autotest_lib": 25 if modpath[0] == "autotest_lib":
(...skipping 24 matching lines...) Expand all
47 imports.ImportsChecker = CustomImportsChecker 50 imports.ImportsChecker = CustomImportsChecker
48 51
49 # some files make pylint blow up, so make sure we ignore them 52 # some files make pylint blow up, so make sure we ignore them
50 blacklist = ['/contrib/*', '/frontend/afe/management.py'] 53 blacklist = ['/contrib/*', '/frontend/afe/management.py']
51 54
52 # only show errors 55 # only show errors
53 # there are two major sources of E1101/E1103 false positives: 56 # there are two major sources of E1101/E1103 false positives:
54 # * common_lib.enum.Enum objects 57 # * common_lib.enum.Enum objects
55 # * DB model objects (scheduler models are the worst, but Django models also 58 # * DB model objects (scheduler models are the worst, but Django models also
56 # generate some errors) 59 # generate some errors)
57 pylint_base_opts = ['--disable-msg-cat=warning,refactor,convention', 60 if pylint_version >= 0.21:
58 '--disable-msg=E1101,E1103', 61 pylint_base_opts = ['--disable=W,R,C,E1101,E1103']
59 '--reports=no', 62 else:
60 '--include-ids=y'] 63 pylint_base_opts = ['--disable-msg-cat=warning,refactor,convention',
64 '--disable-msg=E1101,E1103']
65 pylint_base_opts += ['--reports=no',
66 '--include-ids=y']
61 67
62 file_list = sys.argv[1:] 68 file_list = sys.argv[1:]
63 if '--' in file_list: 69 if '--' in file_list:
64 index = file_list.index('--') 70 index = file_list.index('--')
65 pylint_base_opts.extend(file_list[index+1:]) 71 pylint_base_opts.extend(file_list[index+1:])
66 file_list = file_list[:index] 72 file_list = file_list[:index]
67 73
68 74
69 def check_file(file_path): 75 def check_file(file_path):
70 if not file_path.endswith('.py'): 76 if not file_path.endswith('.py'):
(...skipping 15 matching lines...) Expand all
86 92
87 93
88 if len(file_list) > 0: 94 if len(file_list) > 0:
89 for path in file_list: 95 for path in file_list:
90 if os.path.isdir(path): 96 if os.path.isdir(path):
91 check_dir(path) 97 check_dir(path)
92 else: 98 else:
93 check_file(path) 99 check_file(path)
94 else: 100 else:
95 check_dir('.') 101 check_dir('.')
OLDNEW
« cli/job.py ('K') | « utils/external_packages.py ('k') | utils/test_importer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698