Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: presubmit_canned_checks.py

Issue 100163002: Allow obj-c import statements to be as long as necessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: The alphabet is confusing. Sort correctly. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 816c7840a4b2bbd290b902853788220337bb9ded..5cbefcb0546ce22a2111210df304c4c2bc3195bc 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', '#endif', '#if', '#include', '#pragma')
+ JAVA_FILE_EXTS = ('java',)
+ JAVA_EXCEPTIONS = ('import ', 'package ')
+ OBJC_FILE_EXTS = ('h', 'm', 'mm')
+ OBJC_EXCEPTIONS = ('#define', '#endif', '#if', '#import', '#include',
+ '#pragma')
+
+ 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))
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698