OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
bulach
2012/10/25 08:30:06
nit:
#!/usr/bin/env python
michaelbai
2012/10/25 21:13:26
Done.
| |
2 # | |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 """Runs findbugs, and returns an error code if there are new warnings. | |
8 This runs findbugs with an additional flag to exclude known bugs. | |
9 To update the list of known bugs, do this: | |
10 | |
11 findbugs_diff.py --rebaseline | |
12 | |
13 Note that this is separate from findbugs_exclude.xml. The "exclude" file has | |
14 false positives that we do not plan to fix. The "known bugs" file has real | |
15 bugs that we *do* plan to fix (but haven't done so yet). | |
16 | |
17 Other options | |
18 --only-analyze used to only analyze the class you are interested. | |
bulach
2012/10/25 08:30:06
nit: how about "filter" ? --only-analyze seems tha
michaelbai
2012/10/25 21:13:26
FindBugs calls exclude xml file as filter file, it
| |
19 --release analyze the classes in out/Release directory. | |
bulach
2012/10/25 08:30:06
nit: how about buildtype? then it can have as defa
michaelbai
2012/10/25 21:13:26
I'd like use the --release-build, since there are
| |
20 --findbugs-args used to passin other findbugs's options. | |
21 | |
22 Run | |
23 CHROM_SRC/third_party/findbugs/bin/findbugs -textui for details. | |
bulach
2012/10/25 08:30:06
nit: $CHROME_SRC
michaelbai
2012/10/25 21:13:26
Done.
| |
24 | |
25 """ | |
26 | |
27 import optparse | |
28 import os | |
29 import sys | |
30 | |
31 from pylib import findbugs | |
32 | |
bulach
2012/10/25 08:30:06
nit: need an extra \n
michaelbai
2012/10/25 21:13:26
Done.
| |
33 def main(argv): | |
34 parser = optparse.OptionParser() | |
35 parser.add_option('-r', | |
36 '--rebaseline', | |
37 action='store_true', | |
38 default=False, | |
bulach
2012/10/25 08:30:06
nit: "default=False" can be removed here and 52 an
michaelbai
2012/10/25 21:13:26
Done.
| |
39 dest='rebaseline', | |
40 help='Rebaseline known findbugs issues.') | |
41 | |
42 parser.add_option('-o', | |
43 '--only-analyze', | |
44 action='store', | |
45 default=None, | |
46 dest='only_analyze', | |
47 help='Only analyze the given classes and packages.') | |
48 | |
49 parser.add_option('-l', | |
50 '--release', | |
51 action='store_true', | |
52 default=False, | |
53 dest='release_version', | |
54 help='Whether check release version.') | |
55 | |
56 parser.add_option('-f', | |
57 '--findbug-args', | |
58 action='store', | |
59 default=None, | |
60 dest='findbug_args', | |
61 help='Additoinal findbug arguments.') | |
bulach
2012/10/25 08:30:06
nit: Additional
michaelbai
2012/10/25 21:13:26
Done.
| |
62 | |
63 options, _ = parser.parse_args() | |
64 | |
65 chrome_src = os.getenv('CHROME_SRC') | |
66 | |
67 known_bugs = os.path.join(chrome_src, 'build', 'android', 'findbugs_filter', | |
bulach
2012/10/25 08:30:06
nit: maybe have a "baseline_dir" as option? that w
michaelbai
2012/10/25 21:13:26
I see your point, you want to use the same script
| |
68 'findbugs_known_bugs.txt') | |
69 exclude_filter = os.path.join(chrome_src, 'build', 'android', | |
70 'findbugs_filter', 'findbugs_exclude.xml') | |
71 | |
72 only_analyze = options.only_analyze | |
73 if not only_analyze: | |
74 only_analyze = 'org.chromium.-' | |
75 | |
76 return findbugs.Run(exclude_filter, known_bugs, only_analyze, | |
77 None, options.rebaseline, options.findbug_args, | |
78 options.release_version) | |
79 | |
80 | |
81 if __name__ == '__main__': | |
82 sys.exit(main(sys.argv)) | |
OLD | NEW |