OLD | NEW |
---|---|
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 """Top-level presubmit script for Chromium. | 5 """Top-level presubmit script for Chromium. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 files.append(f) | 370 files.append(f) |
371 | 371 |
372 if files: | 372 if files: |
373 return [output_api.PresubmitError( | 373 return [output_api.PresubmitError( |
374 'Do not use #pragma once in header files.\n' | 374 'Do not use #pragma once in header files.\n' |
375 'See http://www.chromium.org/developers/coding-style#TOC-File-headers', | 375 'See http://www.chromium.org/developers/coding-style#TOC-File-headers', |
376 files)] | 376 files)] |
377 return [] | 377 return [] |
378 | 378 |
379 | 379 |
380 def _CheckNoTrinaryTrueFalse(input_api, output_api): | |
381 """Checks to make sure we don't introduce use of foo ? true : false.""" | |
382 problems = [] | |
383 for f in input_api.AffectedFiles(): | |
384 if not f.LocalPath().endswith(('.cc', '.h')): | |
M-A Ruel
2012/09/18 10:20:40
.mm, .m, .inl
Lei Zhang
2012/09/18 18:45:18
Done.
| |
385 continue | |
386 | |
387 for line_num, line in f.ChangedContents(): | |
388 if '? true : false' in line or '? false : true' in line: | |
M-A Ruel
2012/09/18 10:20:40
I'd use a regexp so whitespaces are ignored. e.g.
Lei Zhang
2012/09/18 18:45:18
Done.
| |
389 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | |
390 | |
391 if not problems: | |
392 return [] | |
393 return [output_api.PresubmitPromptWarning( | |
394 'Please consider avoiding the "? true : false" pattern if possible.\n' + | |
395 '\n'.join(problems))] | |
396 | |
397 | |
380 def _CheckUnwantedDependencies(input_api, output_api): | 398 def _CheckUnwantedDependencies(input_api, output_api): |
381 """Runs checkdeps on #include statements added in this | 399 """Runs checkdeps on #include statements added in this |
382 change. Breaking - rules is an error, breaking ! rules is a | 400 change. Breaking - rules is an error, breaking ! rules is a |
383 warning. | 401 warning. |
384 """ | 402 """ |
385 # We need to wait until we have an input_api object and use this | 403 # We need to wait until we have an input_api object and use this |
386 # roundabout construct to import checkdeps because this file is | 404 # roundabout construct to import checkdeps because this file is |
387 # eval-ed and thus doesn't have __file__. | 405 # eval-ed and thus doesn't have __file__. |
388 original_sys_path = sys.path | 406 original_sys_path = sys.path |
389 try: | 407 try: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) | 477 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) |
460 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 478 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
461 results.extend( | 479 results.extend( |
462 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 480 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
463 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 481 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
464 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) | 482 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) |
465 results.extend(_CheckNoNewWStrings(input_api, output_api)) | 483 results.extend(_CheckNoNewWStrings(input_api, output_api)) |
466 results.extend(_CheckNoDEPSGIT(input_api, output_api)) | 484 results.extend(_CheckNoDEPSGIT(input_api, output_api)) |
467 results.extend(_CheckNoBannedFunctions(input_api, output_api)) | 485 results.extend(_CheckNoBannedFunctions(input_api, output_api)) |
468 results.extend(_CheckNoPragmaOnce(input_api, output_api)) | 486 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
487 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) | |
469 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 488 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
470 results.extend(_CheckFilePermissions(input_api, output_api)) | 489 results.extend(_CheckFilePermissions(input_api, output_api)) |
471 return results | 490 return results |
472 | 491 |
473 | 492 |
474 def _CheckSubversionConfig(input_api, output_api): | 493 def _CheckSubversionConfig(input_api, output_api): |
475 """Verifies the subversion config file is correctly setup. | 494 """Verifies the subversion config file is correctly setup. |
476 | 495 |
477 Checks that autoprops are enabled, returns an error otherwise. | 496 Checks that autoprops are enabled, returns an error otherwise. |
478 """ | 497 """ |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 # Same for ash and chromeos. | 614 # Same for ash and chromeos. |
596 if any(re.search('[/_](ash|aura)', f) for f in files): | 615 if any(re.search('[/_](ash|aura)', f) for f in files): |
597 trybots += ['linux_chromeos', 'linux_chromeos_clang:compile', 'win_aura', | 616 trybots += ['linux_chromeos', 'linux_chromeos_clang:compile', 'win_aura', |
598 'linux_chromeos_asan'] | 617 'linux_chromeos_asan'] |
599 else: | 618 else: |
600 if any(re.search('[/_]chromeos', f) for f in files): | 619 if any(re.search('[/_]chromeos', f) for f in files): |
601 trybots += ['linux_chromeos', 'linux_chromeos_clang:compile', | 620 trybots += ['linux_chromeos', 'linux_chromeos_clang:compile', |
602 'linux_chromeos_asan'] | 621 'linux_chromeos_asan'] |
603 | 622 |
604 return trybots | 623 return trybots |
OLD | NEW |