Chromium Code Reviews| Index: presubmit_canned_checks.py |
| diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py |
| index 816c7840a4b2bbd290b902853788220337bb9ded..0a8ab822a5b5fc2b6db92f249dfc486c8c27c350 100644 |
| --- a/presubmit_canned_checks.py |
| +++ b/presubmit_canned_checks.py |
| @@ -321,15 +321,28 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None): |
| 'mk': 200, |
| '': maxlen, |
| } |
| - # Note: these are C++ specific but processed on all languages. :( |
| - MACROS = ('#define', '#include', '#import', '#pragma', '#if', '#endif') |
| - # Special java statements. |
| - SPECIAL_JAVA_STARTS = ('package ', 'import ') |
| + # Language specific exceptions to max line length. |
| + # '.h' is considered an obj-c file extension, since OBJC_EXCEPTIONS are a |
| + # superset of CPP_EXCEPTIONS. |
| + CPP_FILE_EXTS = ('c', 'cc') |
| + CPP_EXCEPTIONS = ('#define', '#include', '#pragma', '#if', '#endif') |
|
M-A Ruel
2013/12/03 01:40:56
sort
erikchen2
2013/12/03 01:47:43
Done.
|
| + JAVA_FILE_EXTS = ('java',) |
| + JAVA_EXCEPTIONS = ('import ', 'package ') |
| + OBJC_FILE_EXTS = ('h', 'm', 'mm') |
| + OBJC_EXCEPTIONS = ('#define', '#include', '#import', '#pragma', '#if', |
|
M-A Ruel
2013/12/03 01:40:56
sort
erikchen2
2013/12/03 01:47:43
Done.
|
| + '#endif') |
| + |
| + LANGUAGE_EXCEPTIONS = [ |
| + (CPP_FILE_EXTS, CPP_EXCEPTIONS), |
| + (JAVA_FILE_EXTS, JAVA_EXCEPTIONS), |
| + (OBJC_FILE_EXTS, OBJC_EXCEPTIONS), |
| + ] |
| def no_long_lines(file_extension, line): |
| - # Allow special java statements to be as long as necessary. |
| - if file_extension == 'java' and line.startswith(SPECIAL_JAVA_STARTS): |
| + # Check for language specific exceptions. |
| + if any(file_extension in exts and line.startswith(exceptions) |
| + for exts, exceptions in LANGUAGE_EXCEPTIONS): |
| return True |
| file_maxlen = maxlens.get(file_extension, maxlens['']) |
| @@ -346,7 +359,6 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None): |
| return False |
| return ( |
| - line.startswith(MACROS) or |
| any((url in line) for url in ('http://', 'https://')) or |
| input_api.re.match( |
| r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)) |