OLD | NEW |
1 # Copyright (C) 2009 Google Inc. All rights reserved. | 1 # Copyright (C) 2009 Google Inc. All rights reserved. |
2 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) | 2 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) |
3 # Copyright (C) 2010 ProFUSION embedded systems | 3 # Copyright (C) 2010 ProFUSION embedded systems |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 # PEP8 79 character limit, we ignore the 79-character-limit category | 100 # PEP8 79 character limit, we ignore the 79-character-limit category |
101 # pep8/E501 for now. | 101 # pep8/E501 for now. |
102 # | 102 # |
103 # FIXME: Consider bringing WebKit's Python code base into conformance | 103 # FIXME: Consider bringing WebKit's Python code base into conformance |
104 # with the 79 character limit, or some higher limit that is | 104 # with the 79 character limit, or some higher limit that is |
105 # agreeable to the WebKit project. | 105 # agreeable to the WebKit project. |
106 '-pep8/E501', | 106 '-pep8/E501', |
107 | 107 |
108 # FIXME: Move the pylint rules from the pylintrc to here. This will | 108 # FIXME: Move the pylint rules from the pylintrc to here. This will |
109 # also require us to re-work lint-webkitpy to produce the equivalent output. | 109 # also require us to re-work lint-webkitpy to produce the equivalent output. |
110 ] | 110 ] |
111 | 111 |
112 | 112 |
113 # The path-specific filter rules. | 113 # The path-specific filter rules. |
114 # | 114 # |
115 # This list is order sensitive. Only the first path substring match | 115 # This list is order sensitive. Only the first path substring match |
116 # is used. See the FilterConfiguration documentation in filter.py | 116 # is used. See the FilterConfiguration documentation in filter.py |
117 # for more information on this list. | 117 # for more information on this list. |
118 # | 118 # |
119 # Each string appearing in this nested list should have at least | 119 # Each string appearing in this nested list should have at least |
120 # one associated unit test assertion. These assertions are located, | 120 # one associated unit test assertion. These assertions are located, |
121 # for example, in the test_path_rules_specifier() unit test method of | 121 # for example, in the test_path_rules_specifier() unit test method of |
122 # checker_unittest.py. | 122 # checker_unittest.py. |
123 _PATH_RULES_SPECIFIER = [ | 123 _PATH_RULES_SPECIFIER = [ |
124 # Files in these directories are consumers of the WebKit | 124 # Files in these directories are consumers of the WebKit |
125 # API and therefore do not follow the same header including | 125 # API and therefore do not follow the same header including |
126 # discipline as WebCore. | 126 # discipline as WebCore. |
127 | 127 |
128 ([# There is no clean way to avoid "yy_*" names used by flex. | 128 ([ # There is no clean way to avoid "yy_*" names used by flex. |
129 "Source/core/css/CSSParser-in.cpp"], | 129 "Source/core/css/CSSParser-in.cpp"], |
130 ["-readability/naming"]), | 130 ["-readability/naming"]), |
131 | 131 |
132 # For third-party Python code, keep only the following checks-- | 132 # For third-party Python code, keep only the following checks-- |
133 # | 133 # |
134 # No tabs: to avoid having to set the SVN allow-tabs property. | 134 # No tabs: to avoid having to set the SVN allow-tabs property. |
135 # No trailing white space: since this is easy to correct. | 135 # No trailing white space: since this is easy to correct. |
136 # No carriage-return line endings: since this is easy to correct. | 136 # No carriage-return line endings: since this is easy to correct. |
137 # | 137 # |
138 (["webkitpy/thirdparty/"], | 138 (["webkitpy/thirdparty/"], |
139 ["-", | 139 ["-", |
140 "+pep8/W191", # Tabs | 140 "+pep8/W191", # Tabs |
141 "+pep8/W291", # Trailing white space | 141 "+pep8/W291", # Trailing white space |
142 "+whitespace/carriage_return"]), | 142 "+whitespace/carriage_return"]), |
143 | 143 |
144 ([# Jinja templates: files have .cpp or .h extensions, but contain | 144 ([ # Jinja templates: files have .cpp or .h extensions, but contain |
145 # template code, which can't be handled, so disable tests. | 145 # template code, which can't be handled, so disable tests. |
146 "Source/bindings/templates", | 146 "Source/bindings/templates", |
147 "Source/build/scripts/templates"], | 147 "Source/build/scripts/templates"], |
148 ["-"]), | 148 ["-"]), |
149 | 149 |
150 ([# IDL compiler reference output | 150 ([ # IDL compiler reference output |
151 # Conforming to style significantly increases the complexity of the code | 151 # Conforming to style significantly increases the complexity of the code |
152 # generator and decreases *its* readability, which is of more concern | 152 # generator and decreases *its* readability, which is of more concern |
153 # than style of the machine-generated code itself. | 153 # than style of the machine-generated code itself. |
154 "Source/bindings/tests/results"], | 154 "Source/bindings/tests/results"], |
155 ["-"]), | 155 ["-"]), |
156 ] | 156 ] |
157 | 157 |
158 | 158 |
159 _CPP_FILE_EXTENSIONS = [ | 159 _CPP_FILE_EXTENSIONS = [ |
160 'c', | 160 'c', |
161 'cpp', | 161 'cpp', |
162 'h', | 162 'h', |
163 ] | 163 ] |
164 | 164 |
165 _JSON_FILE_EXTENSION = 'json' | 165 _JSON_FILE_EXTENSION = 'json' |
166 | 166 |
167 _PYTHON_FILE_EXTENSION = 'py' | 167 _PYTHON_FILE_EXTENSION = 'py' |
168 | 168 |
169 _TEXT_FILE_EXTENSIONS = [ | 169 _TEXT_FILE_EXTENSIONS = [ |
170 'cc', | 170 'cc', |
171 'cgi', | 171 'cgi', |
172 'css', | 172 'css', |
173 'gyp', | 173 'gyp', |
174 'gypi', | 174 'gypi', |
175 'html', | 175 'html', |
176 'idl', | 176 'idl', |
177 'in', | 177 'in', |
178 'js', | 178 'js', |
179 'mm', | 179 'mm', |
180 'php', | 180 'php', |
181 'pl', | 181 'pl', |
182 'pm', | 182 'pm', |
183 'rb', | 183 'rb', |
184 'sh', | 184 'sh', |
185 'txt', | 185 'txt', |
186 'xhtml', | 186 'xhtml', |
187 'y', | 187 'y', |
188 ] | 188 ] |
189 | 189 |
190 _XCODEPROJ_FILE_EXTENSION = 'pbxproj' | 190 _XCODEPROJ_FILE_EXTENSION = 'pbxproj' |
191 | 191 |
192 _XML_FILE_EXTENSIONS = [ | 192 _XML_FILE_EXTENSIONS = [ |
193 'vcproj', | 193 'vcproj', |
194 'vsprops', | 194 'vsprops', |
195 ] | 195 ] |
196 | 196 |
197 _PNG_FILE_EXTENSION = 'png' | 197 _PNG_FILE_EXTENSION = 'png' |
198 | 198 |
199 # Files to skip that are less obvious. | 199 # Files to skip that are less obvious. |
200 # | 200 # |
201 # Some files should be skipped when checking style. For example, | 201 # Some files should be skipped when checking style. For example, |
202 # WebKit maintains some files in Mozilla style on purpose to ease | 202 # WebKit maintains some files in Mozilla style on purpose to ease |
203 # future merges. | 203 # future merges. |
204 _SKIPPED_FILES_WITH_WARNING = [ | 204 _SKIPPED_FILES_WITH_WARNING = [ |
205 "Source/WebKit/gtk/tests/", | 205 "Source/WebKit/gtk/tests/", |
206 # All WebKit*.h files in Source/WebKit2/UIProcess/API/gtk, | 206 # All WebKit*.h files in Source/WebKit2/UIProcess/API/gtk, |
207 # except those ending in ...Private.h are GTK+ API headers, | 207 # except those ending in ...Private.h are GTK+ API headers, |
208 # which differ greatly from WebKit coding style. | 208 # which differ greatly from WebKit coding style. |
209 re.compile(r'Source/WebKit2/UIProcess/API/gtk/WebKit(?!.*Private\.h).*\.h$')
, | 209 re.compile(r'Source/WebKit2/UIProcess/API/gtk/WebKit(?!.*Private\.h).*\.h$')
, |
210 re.compile(r'Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKit(?!.*Pri
vate\.h).*\.h$'), | 210 re.compile(r'Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKit(?!.*Pri
vate\.h).*\.h$'), |
211 'Source/WebKit2/UIProcess/API/gtk/webkit2.h', | 211 'Source/WebKit2/UIProcess/API/gtk/webkit2.h', |
212 'Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h'] | 212 'Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h'] |
213 | 213 |
214 # Files to skip that are more common or obvious. | 214 # Files to skip that are more common or obvious. |
215 # | 215 # |
216 # This list should be in addition to files with FileType.NONE. Files | 216 # This list should be in addition to files with FileType.NONE. Files |
217 # with FileType.NONE are automatically skipped without warning. | 217 # with FileType.NONE are automatically skipped without warning. |
218 _SKIPPED_FILES_WITHOUT_WARNING = [ | 218 _SKIPPED_FILES_WITHOUT_WARNING = [ |
219 "LayoutTests" + os.path.sep, | 219 "LayoutTests" + os.path.sep, |
220 "Source/ThirdParty/leveldb" + os.path.sep, | 220 "Source/ThirdParty/leveldb" + os.path.sep, |
221 # Prevents this being recognized as a text file. | 221 # Prevents this being recognized as a text file. |
222 "Source/WebCore/GNUmakefile.features.am.in", | 222 "Source/WebCore/GNUmakefile.features.am.in", |
223 ] | 223 ] |
224 | 224 |
225 # Extensions of files which are allowed to contain carriage returns. | 225 # Extensions of files which are allowed to contain carriage returns. |
226 _CARRIAGE_RETURN_ALLOWED_FILE_EXTENSIONS = [ | 226 _CARRIAGE_RETURN_ALLOWED_FILE_EXTENSIONS = [ |
227 'png', | 227 'png', |
228 'vcproj', | 228 'vcproj', |
229 'vsprops', | 229 'vsprops', |
230 ] | 230 ] |
231 | 231 |
232 # The maximum number of errors to report per file, per category. | 232 # The maximum number of errors to report per file, per category. |
233 # If a category is not a key, then it has no maximum. | 233 # If a category is not a key, then it has no maximum. |
234 _MAX_REPORTS_PER_CATEGORY = { | 234 _MAX_REPORTS_PER_CATEGORY = { |
235 "whitespace/carriage_return": 1 | 235 "whitespace/carriage_return": 1 |
236 } | 236 } |
237 | 237 |
238 | 238 |
239 def _all_categories(): | 239 def _all_categories(): |
240 """Return the set of all categories used by check-webkit-style.""" | 240 """Return the set of all categories used by check-webkit-style.""" |
(...skipping 29 matching lines...) Expand all Loading... |
270 | 270 |
271 | 271 |
272 def check_webkit_style_configuration(options): | 272 def check_webkit_style_configuration(options): |
273 """Return a StyleProcessorConfiguration instance for check-webkit-style. | 273 """Return a StyleProcessorConfiguration instance for check-webkit-style. |
274 | 274 |
275 Args: | 275 Args: |
276 options: A CommandOptionValues instance. | 276 options: A CommandOptionValues instance. |
277 | 277 |
278 """ | 278 """ |
279 filter_configuration = FilterConfiguration( | 279 filter_configuration = FilterConfiguration( |
280 base_rules=_BASE_FILTER_RULES, | 280 base_rules=_BASE_FILTER_RULES, |
281 path_specific=_PATH_RULES_SPECIFIER, | 281 path_specific=_PATH_RULES_SPECIFIER, |
282 user_rules=options.filter_rules) | 282 user_rules=options.filter_rules) |
283 | 283 |
284 return StyleProcessorConfiguration(filter_configuration=filter_configuration
, | 284 return StyleProcessorConfiguration(filter_configuration=filter_configuration
, |
285 max_reports_per_category=_MAX_REPORTS_PER_CATEGORY, | 285 max_reports_per_category=_MAX_REPORTS_PER
_CATEGORY, |
286 min_confidence=options.min_confidence, | 286 min_confidence=options.min_confidence, |
287 output_format=options.output_format, | 287 output_format=options.output_format, |
288 stderr_write=sys.stderr.write) | 288 stderr_write=sys.stderr.write) |
289 | 289 |
290 | 290 |
291 def _create_log_handlers(stream): | 291 def _create_log_handlers(stream): |
292 """Create and return a default list of logging.Handler instances. | 292 """Create and return a default list of logging.Handler instances. |
293 | 293 |
294 Format WARNING messages and above to display the logging level, and | 294 Format WARNING messages and above to display the logging level, and |
295 messages strictly below WARNING not to display it. | 295 messages strictly below WARNING not to display it. |
296 | 296 |
297 Args: | 297 Args: |
298 stream: See the configure_logging() docstring. | 298 stream: See the configure_logging() docstring. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 return os.path.splitext(file_path)[1].lstrip(".") | 401 return os.path.splitext(file_path)[1].lstrip(".") |
402 | 402 |
403 def _should_skip_file_path(self, file_path, skip_array_entry): | 403 def _should_skip_file_path(self, file_path, skip_array_entry): |
404 match = re.search("\s*png$", file_path) | 404 match = re.search("\s*png$", file_path) |
405 if match: | 405 if match: |
406 return False | 406 return False |
407 if isinstance(skip_array_entry, str): | 407 if isinstance(skip_array_entry, str): |
408 if file_path.find(skip_array_entry) >= 0: | 408 if file_path.find(skip_array_entry) >= 0: |
409 return True | 409 return True |
410 elif skip_array_entry.match(file_path): | 410 elif skip_array_entry.match(file_path): |
411 return True | 411 return True |
412 return False | 412 return False |
413 | 413 |
414 def should_skip_with_warning(self, file_path): | 414 def should_skip_with_warning(self, file_path): |
415 """Return whether the given file should be skipped with a warning.""" | 415 """Return whether the given file should be skipped with a warning.""" |
416 for skipped_file in _SKIPPED_FILES_WITH_WARNING: | 416 for skipped_file in _SKIPPED_FILES_WITH_WARNING: |
417 if self._should_skip_file_path(file_path, skipped_file): | 417 if self._should_skip_file_path(file_path, skipped_file): |
418 return True | 418 return True |
419 return False | 419 return False |
420 | 420 |
421 def should_skip_without_warning(self, file_path): | 421 def should_skip_without_warning(self, file_path): |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 checker = self._dispatcher.dispatch(file_path, | 734 checker = self._dispatcher.dispatch(file_path, |
735 style_error_handler, | 735 style_error_handler, |
736 min_confidence) | 736 min_confidence) |
737 | 737 |
738 if checker is None: | 738 if checker is None: |
739 raise AssertionError("File should not be checked: '%s'" % file_path) | 739 raise AssertionError("File should not be checked: '%s'" % file_path) |
740 | 740 |
741 _log.debug("Using class: " + checker.__class__.__name__) | 741 _log.debug("Using class: " + checker.__class__.__name__) |
742 | 742 |
743 checker.check(lines) | 743 checker.check(lines) |
OLD | NEW |