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

Side by Side Diff: PRESUBMIT.py

Issue 110773002: Adding Java style presubmit check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved checkstyle to a separate directory so it could be used from other repos Created 7 years 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 # 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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 cygwin_shell.append(f.LocalPath()) 969 cygwin_shell.append(f.LocalPath())
970 break 970 break
971 971
972 if cygwin_shell: 972 if cygwin_shell:
973 return [output_api.PresubmitError( 973 return [output_api.PresubmitError(
974 'These files should not use msvs_cygwin_shell (the default is 0):', 974 'These files should not use msvs_cygwin_shell (the default is 0):',
975 items=cygwin_shell)] 975 items=cygwin_shell)]
976 return [] 976 return []
977 977
978 978
979 def _CheckJavaStyle(input_api, output_api):
980 """Runs checkstyle on changed java files and returns errors if any exist."""
981 original_sys_path = sys.path
982 try:
983 sys.path = sys.path + [input_api.os_path.join(
984 input_api.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
985 import checkstyle
986 finally:
987 # Restore sys.path to what it was before.
988 sys.path = original_sys_path
989
990 return checkstyle.RunCheckstyle(
991 input_api, output_api, 'tools/android/checkstyle/chromium-style-5.0.xml')
992
993
979 def _CommonChecks(input_api, output_api): 994 def _CommonChecks(input_api, output_api):
980 """Checks common to both upload and commit.""" 995 """Checks common to both upload and commit."""
981 results = [] 996 results = []
982 results.extend(input_api.canned_checks.PanProjectChecks( 997 results.extend(input_api.canned_checks.PanProjectChecks(
983 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) 998 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
984 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) 999 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
985 results.extend( 1000 results.extend(
986 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) 1001 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
987 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) 1002 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
988 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) 1003 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api))
989 results.extend(_CheckNoNewWStrings(input_api, output_api)) 1004 results.extend(_CheckNoNewWStrings(input_api, output_api))
990 results.extend(_CheckNoDEPSGIT(input_api, output_api)) 1005 results.extend(_CheckNoDEPSGIT(input_api, output_api))
991 results.extend(_CheckNoBannedFunctions(input_api, output_api)) 1006 results.extend(_CheckNoBannedFunctions(input_api, output_api))
992 results.extend(_CheckNoPragmaOnce(input_api, output_api)) 1007 results.extend(_CheckNoPragmaOnce(input_api, output_api))
993 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) 1008 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api))
994 results.extend(_CheckUnwantedDependencies(input_api, output_api)) 1009 results.extend(_CheckUnwantedDependencies(input_api, output_api))
995 results.extend(_CheckFilePermissions(input_api, output_api)) 1010 results.extend(_CheckFilePermissions(input_api, output_api))
996 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) 1011 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api))
997 results.extend(_CheckIncludeOrder(input_api, output_api)) 1012 results.extend(_CheckIncludeOrder(input_api, output_api))
998 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) 1013 results.extend(_CheckForVersionControlConflicts(input_api, output_api))
999 results.extend(_CheckPatchFiles(input_api, output_api)) 1014 results.extend(_CheckPatchFiles(input_api, output_api))
1000 results.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api)) 1015 results.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api))
1001 results.extend(_CheckNoAbbreviationInPngFileName(input_api, output_api)) 1016 results.extend(_CheckNoAbbreviationInPngFileName(input_api, output_api))
1002 results.extend(_CheckForInvalidOSMacros(input_api, output_api)) 1017 results.extend(_CheckForInvalidOSMacros(input_api, output_api))
1003 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) 1018 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api))
1004 results.extend( 1019 results.extend(
1005 input_api.canned_checks.CheckChangeHasNoTabs( 1020 input_api.canned_checks.CheckChangeHasNoTabs(
1006 input_api, 1021 input_api,
1007 output_api, 1022 output_api,
1008 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) 1023 source_file_filter=lambda x: x.LocalPath().endswith('.grd')))
1009 results.extend(_CheckSpamLogging(input_api, output_api)) 1024 results.extend(_CheckSpamLogging(input_api, output_api))
1010 results.extend(_CheckForAnonymousVariables(input_api, output_api)) 1025 results.extend(_CheckForAnonymousVariables(input_api, output_api))
1011 results.extend(_CheckCygwinShell(input_api, output_api)) 1026 results.extend(_CheckCygwinShell(input_api, output_api))
1027 results.extend(_CheckJavaStyle(input_api, output_api))
1012 1028
1013 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): 1029 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
1014 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( 1030 results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
1015 input_api, output_api, 1031 input_api, output_api,
1016 input_api.PresubmitLocalPath(), 1032 input_api.PresubmitLocalPath(),
1017 whitelist=[r'^PRESUBMIT_test\.py$'])) 1033 whitelist=[r'^PRESUBMIT_test\.py$']))
1018 return results 1034 return results
1019 1035
1020 1036
1021 def _CheckSubversionConfig(input_api, output_api): 1037 def _CheckSubversionConfig(input_api, output_api):
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 trybots += ['cros_x86'] 1245 trybots += ['cros_x86']
1230 1246
1231 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it 1247 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1232 # unless they're .gyp(i) files as changes to those files can break the gyp 1248 # unless they're .gyp(i) files as changes to those files can break the gyp
1233 # step on that bot. 1249 # step on that bot.
1234 if (not all(re.search('^chrome', f) for f in files) or 1250 if (not all(re.search('^chrome', f) for f in files) or
1235 any(re.search('\.gypi?$', f) for f in files)): 1251 any(re.search('\.gypi?$', f) for f in files)):
1236 trybots += ['android_aosp'] 1252 trybots += ['android_aosp']
1237 1253
1238 return trybots 1254 return trybots
OLDNEW
« no previous file with comments | « no previous file | tools/android/checkstyle/checkstyle.py » ('j') | tools/android/checkstyle/checkstyle.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698