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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/android/checkstyle/checkstyle.py » ('j') | tools/android/checkstyle/checkstyle.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 2a96a9b3b986766ab658ea7453bc5b01ace60100..34bf0f68851160a6bb77c32064f35fc903453c1f 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -976,6 +976,21 @@ def _CheckCygwinShell(input_api, output_api):
return []
+def _CheckJavaStyle(input_api, output_api):
+ """Runs checkstyle on changed java files and returns errors if any exist."""
+ original_sys_path = sys.path
+ try:
+ sys.path = sys.path + [input_api.os_path.join(
+ input_api.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
+ import checkstyle
+ finally:
+ # Restore sys.path to what it was before.
+ sys.path = original_sys_path
+
+ return checkstyle.RunCheckstyle(
+ input_api, output_api, 'tools/android/checkstyle/chromium-style-5.0.xml')
+
+
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
@@ -983,7 +998,7 @@ def _CommonChecks(input_api, output_api):
input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
results.extend(_CheckAuthorizedAuthor(input_api, output_api))
results.extend(
- _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
+ _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api))
results.extend(_CheckNoNewWStrings(input_api, output_api))
@@ -1009,6 +1024,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckSpamLogging(input_api, output_api))
results.extend(_CheckForAnonymousVariables(input_api, output_api))
results.extend(_CheckCygwinShell(input_api, output_api))
+ results.extend(_CheckJavaStyle(input_api, output_api))
if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
« 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