OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Script that is used by PRESUBMIT.py to run style checks on Java files.""" | 5 """Script that is used by PRESUBMIT.py to run style checks on Java files.""" |
6 | 6 |
7 import os | 7 import os |
8 import subprocess | 8 import subprocess |
9 | 9 |
10 | 10 |
11 CHROMIUM_SRC = os.path.normpath( | 11 CHROMIUM_SRC = os.path.normpath( |
12 os.path.join(os.path.dirname(__file__), | 12 os.path.join(os.path.dirname(__file__), |
13 os.pardir, os.pardir, os.pardir)) | 13 os.pardir, os.pardir, os.pardir)) |
14 CHECKSTYLE_ROOT = os.path.join(CHROMIUM_SRC, 'third_party', 'checkstyle', | 14 CHECKSTYLE_ROOT = os.path.join(CHROMIUM_SRC, 'third_party', 'checkstyle', |
15 'checkstyle-5.7-all.jar') | 15 'checkstyle-5.8-all.jar') |
16 | 16 |
17 | 17 |
18 def RunCheckstyle(input_api, output_api, style_file): | 18 def RunCheckstyle(input_api, output_api, style_file): |
19 if not os.path.exists(style_file): | 19 if not os.path.exists(style_file): |
20 file_error = (' Java checkstyle configuration file is missing: ' | 20 file_error = (' Java checkstyle configuration file is missing: ' |
21 + style_file) | 21 + style_file) |
22 return [output_api.PresubmitError(file_error)] | 22 return [output_api.PresubmitError(file_error)] |
23 | 23 |
24 # Filter out non-Java files and files that were deleted. | 24 # Filter out non-Java files and files that were deleted. |
25 java_files = [x.LocalPath() for x in input_api.AffectedFiles(False, False) | 25 java_files = [x.LocalPath() for x in input_api.AffectedFiles(False, False) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return [] | 60 return [] |
61 | 61 |
62 local_path = input_api.PresubmitLocalPath() | 62 local_path = input_api.PresubmitLocalPath() |
63 output = [] | 63 output = [] |
64 for error in errors: | 64 for error in errors: |
65 # Change the full file path to relative path in the output lines | 65 # Change the full file path to relative path in the output lines |
66 full_path, end = error.split(':', 1) | 66 full_path, end = error.split(':', 1) |
67 rel_path = os.path.relpath(full_path, local_path) | 67 rel_path = os.path.relpath(full_path, local_path) |
68 output.append(' %s:%s' % (rel_path, end)) | 68 output.append(' %s:%s' % (rel_path, end)) |
69 return [output_api.PresubmitPromptWarning('\n'.join(output))] | 69 return [output_api.PresubmitPromptWarning('\n'.join(output))] |
OLD | NEW |