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

Side by Side Diff: build/android/pylib/utils/findbugs.py

Issue 182033002: [Android] Lint pylib/utils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import optparse 5 import optparse
6 import os 6 import os
7 import re 7 import re
8 import shlex 8 import shlex
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 print 55 print
56 else: 56 else:
57 print 'No new FindBugs warnings.' 57 print 'No new FindBugs warnings.'
58 print 58 print
59 return count 59 return count
60 60
61 61
62 def _Rebaseline(current_warnings_set, known_bugs_file): 62 def _Rebaseline(current_warnings_set, known_bugs_file):
63 with file(known_bugs_file, 'w') as known_bugs: 63 with file(known_bugs_file, 'w') as known_bugs:
64 for warning in sorted(current_warnings_set): 64 for warning in sorted(current_warnings_set):
65 print >>known_bugs, warning 65 print >> known_bugs, warning
66 return 0 66 return 0
67 67
68 68
69 def _GetChromeClasses(release_version): 69 def _GetChromeClasses(release_version):
70 version = 'Debug' 70 version = 'Debug'
71 if release_version: 71 if release_version:
72 version = 'Release' 72 version = 'Release'
73 path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version) 73 path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version)
74 cmd = 'find %s -name "*.class"' % path 74 cmd = 'find %s -name "*.class"' % path
75 out = cmd_helper.GetCmdOutput(shlex.split(cmd)) 75 out = cmd_helper.GetCmdOutput(shlex.split(cmd))
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if findbug_args: 135 if findbug_args:
136 cmd = '%s %s ' % (cmd, findbug_args) 136 cmd = '%s %s ' % (cmd, findbug_args)
137 137
138 chrome_classes = _GetChromeClasses(release_version) 138 chrome_classes = _GetChromeClasses(release_version)
139 if not chrome_classes: 139 if not chrome_classes:
140 return 1 140 return 1
141 cmd = '%s %s ' % (cmd, chrome_classes) 141 cmd = '%s %s ' % (cmd, chrome_classes)
142 142
143 proc = subprocess.Popen(shlex.split(cmd), 143 proc = subprocess.Popen(shlex.split(cmd),
144 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 144 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
145 out, err = proc.communicate() 145 out, _err = proc.communicate()
146 current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines()))) 146 current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines())))
147 147
148 if rebaseline: 148 if rebaseline:
149 return _Rebaseline(current_warnings_set, known_bugs) 149 return _Rebaseline(current_warnings_set, known_bugs)
150 else: 150 else:
151 return _DiffKnownWarnings(current_warnings_set, known_bugs) 151 return _DiffKnownWarnings(current_warnings_set, known_bugs)
152 152
153 def Run(options): 153 def Run(options):
154 exclude_file = None 154 exclude_file = None
155 known_bugs_file = None 155 known_bugs_file = None
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 parser.add_option('-b', 223 parser.add_option('-b',
224 '--base-dir', 224 '--base-dir',
225 action='store', 225 action='store',
226 default=None, 226 default=None,
227 dest='base_dir', 227 dest='base_dir',
228 help='Base directory for configuration file.') 228 help='Base directory for configuration file.')
229 229
230 return parser 230 return parser
231 231
232 232
233 def main(argv): 233 def main():
234 parser = GetCommonParser() 234 parser = GetCommonParser()
235 options, _ = parser.parse_args() 235 options, _ = parser.parse_args()
236 236
237 return Run(options) 237 return Run(options)
238 238
239 239
240 if __name__ == '__main__': 240 if __name__ == '__main__':
241 sys.exit(main(sys.argv)) 241 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/utils/emulator.py ('k') | build/android/pylib/utils/flakiness_dashboard_results_uploader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698