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 """Presubmit script for Chromium JS resources. | 5 """Presubmit script for Chromium JS resources. |
6 | 6 |
7 See chrome/browser/resources/PRESUBMIT.py | 7 See chrome/browser/PRESUBMIT.py |
8 """ | 8 """ |
9 | 9 |
10 class JSChecker(object): | 10 class JSChecker(object): |
11 def __init__(self, input_api, output_api, file_filter=None): | 11 def __init__(self, input_api, output_api, file_filter=None): |
12 self.input_api = input_api | 12 self.input_api = input_api |
13 self.output_api = output_api | 13 self.output_api = output_api |
14 self.file_filter = file_filter | 14 self.file_filter = file_filter |
15 | 15 |
16 def RegexCheck(self, line_number, line, regex, message): | 16 def RegexCheck(self, line_number, line, regex, message): |
17 """Searches for |regex| in |line| to check for a particular style | 17 """Searches for |regex| in |line| to check for a particular style |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 def _makeErrorOrWarning(self, error_text, filename): | 89 def _makeErrorOrWarning(self, error_text, filename): |
90 """Takes a few lines of text indicating a style violation and turns it into | 90 """Takes a few lines of text indicating a style violation and turns it into |
91 a PresubmitError (if |filename| is in a directory where we've already | 91 a PresubmitError (if |filename| is in a directory where we've already |
92 taken out all the style guide violations) or a PresubmitPromptWarning | 92 taken out all the style guide violations) or a PresubmitPromptWarning |
93 (if it's in a directory where we haven't done that yet). | 93 (if it's in a directory where we haven't done that yet). |
94 """ | 94 """ |
95 # TODO(tbreisacher): Once we've cleaned up the style nits in all of | 95 # TODO(tbreisacher): Once we've cleaned up the style nits in all of |
96 # resources/ we can get rid of this function. | 96 # resources/ we can get rid of this function. |
97 path = self.input_api.os_path | 97 path = self.input_api.os_path |
98 resources = self.input_api.PresubmitLocalPath() | 98 resources = path.join(self.input_api.PresubmitLocalPath(), 'resources') |
99 dirs = ( | 99 dirs = ( |
100 path.join(resources, 'bookmark_manager'), | 100 path.join(resources, 'bookmark_manager'), |
101 path.join(resources, 'extensions'), | 101 path.join(resources, 'extensions'), |
102 path.join(resources, 'file_manager'), | 102 path.join(resources, 'file_manager'), |
103 path.join(resources, 'help'), | 103 path.join(resources, 'help'), |
104 path.join(resources, 'history'), | 104 path.join(resources, 'history'), |
105 path.join(resources, 'memory_internals'), | 105 path.join(resources, 'memory_internals'), |
106 path.join(resources, 'net_export'), | 106 path.join(resources, 'net_export'), |
107 path.join(resources, 'net_internals'), | 107 path.join(resources, 'net_internals'), |
108 path.join(resources, 'network_action_predictor'), | 108 path.join(resources, 'network_action_predictor'), |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 if results: | 247 if results: |
248 results.append(self.output_api.PresubmitNotifyResult( | 248 results.append(self.output_api.PresubmitNotifyResult( |
249 'See the JavaScript style guide at ' | 249 'See the JavaScript style guide at ' |
250 'http://www.chromium.org/developers/web-development-style-guide' | 250 'http://www.chromium.org/developers/web-development-style-guide' |
251 '#TOC-JavaScript and if you have any feedback about the JavaScript ' | 251 '#TOC-JavaScript and if you have any feedback about the JavaScript ' |
252 'PRESUBMIT check, contact tbreisacher@chromium.org or ' | 252 'PRESUBMIT check, contact tbreisacher@chromium.org or ' |
253 'dbeam@chromium.org')) | 253 'dbeam@chromium.org')) |
254 | 254 |
255 return results | 255 return results |
OLD | NEW |