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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 def _makeErrorOrWarning(self, error_text, filename): | 83 def _makeErrorOrWarning(self, error_text, filename): |
84 """Takes a few lines of text indicating a style violation and turns it into | 84 """Takes a few lines of text indicating a style violation and turns it into |
85 a PresubmitError (if |filename| is in a directory where we've already | 85 a PresubmitError (if |filename| is in a directory where we've already |
86 taken out all the style guide violations) or a PresubmitPromptWarning | 86 taken out all the style guide violations) or a PresubmitPromptWarning |
87 (if it's in a directory where we haven't done that yet). | 87 (if it's in a directory where we haven't done that yet). |
88 """ | 88 """ |
89 # TODO(tbreisacher): Once we've cleaned up the style nits in all of | 89 # TODO(tbreisacher): Once we've cleaned up the style nits in all of |
90 # resources/ we can get rid of this function. | 90 # resources/ we can get rid of this function. |
91 path = self.input_api.os_path | 91 path = self.input_api.os_path |
92 resources = self.input_api.PresubmitLocalPath() | 92 resources = path.join(self.input_api.PresubmitLocalPath(), 'resources') |
93 dirs = ( | 93 dirs = ( |
94 path.join(resources, 'bookmark_manager'), | 94 path.join(resources, 'bookmark_manager'), |
95 path.join(resources, 'extensions'), | 95 path.join(resources, 'extensions'), |
96 path.join(resources, 'file_manager'), | 96 path.join(resources, 'file_manager'), |
97 path.join(resources, 'help'), | 97 path.join(resources, 'help'), |
98 path.join(resources, 'history'), | 98 path.join(resources, 'history'), |
99 path.join(resources, 'memory_internals'), | 99 path.join(resources, 'memory_internals'), |
100 path.join(resources, 'net_export'), | 100 path.join(resources, 'net_export'), |
101 path.join(resources, 'net_internals'), | 101 path.join(resources, 'net_internals'), |
102 path.join(resources, 'network_action_predictor'), | 102 path.join(resources, 'network_action_predictor'), |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 if results: | 241 if results: |
242 results.append(self.output_api.PresubmitNotifyResult( | 242 results.append(self.output_api.PresubmitNotifyResult( |
243 'See the JavaScript style guide at ' | 243 'See the JavaScript style guide at ' |
244 'http://www.chromium.org/developers/web-development-style-guide' | 244 'http://www.chromium.org/developers/web-development-style-guide' |
245 '#TOC-JavaScript and if you have any feedback about the JavaScript ' | 245 '#TOC-JavaScript and if you have any feedback about the JavaScript ' |
246 'PRESUBMIT check, contact tbreisacher@chromium.org or ' | 246 'PRESUBMIT check, contact tbreisacher@chromium.org or ' |
247 'dbeam@chromium.org')) | 247 'dbeam@chromium.org')) |
248 | 248 |
249 return results | 249 return results |
OLD | NEW |