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

Side by Side Diff: presubmit_canned_checks.py

Issue 1394563003: Add long line exception for GEN('#include') in JS browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: gar Created 5 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 import os as _os 7 import os as _os
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) 8 _HERE = _os.path.dirname(_os.path.abspath(__file__))
9 9
10 # Justifications for each filter: 10 # Justifications for each filter:
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 '': maxlen, 335 '': maxlen,
336 } 336 }
337 337
338 # Language specific exceptions to max line length. 338 # Language specific exceptions to max line length.
339 # '.h' is considered an obj-c file extension, since OBJC_EXCEPTIONS are a 339 # '.h' is considered an obj-c file extension, since OBJC_EXCEPTIONS are a
340 # superset of CPP_EXCEPTIONS. 340 # superset of CPP_EXCEPTIONS.
341 CPP_FILE_EXTS = ('c', 'cc') 341 CPP_FILE_EXTS = ('c', 'cc')
342 CPP_EXCEPTIONS = ('#define', '#endif', '#if', '#include', '#pragma') 342 CPP_EXCEPTIONS = ('#define', '#endif', '#if', '#include', '#pragma')
343 JAVA_FILE_EXTS = ('java',) 343 JAVA_FILE_EXTS = ('java',)
344 JAVA_EXCEPTIONS = ('import ', 'package ') 344 JAVA_EXCEPTIONS = ('import ', 'package ')
345 JS_FILE_EXTS = ('js',)
346 JS_EXCEPTIONS = ("GEN('#include",)
345 OBJC_FILE_EXTS = ('h', 'm', 'mm') 347 OBJC_FILE_EXTS = ('h', 'm', 'mm')
346 OBJC_EXCEPTIONS = ('#define', '#endif', '#if', '#import', '#include', 348 OBJC_EXCEPTIONS = ('#define', '#endif', '#if', '#import', '#include',
347 '#pragma') 349 '#pragma')
348 PY_FILE_EXTS = ('py') 350 PY_FILE_EXTS = ('py',)
349 PY_EXCEPTIONS = ('import', 'from') 351 PY_EXCEPTIONS = ('import', 'from')
350 352
351 LANGUAGE_EXCEPTIONS = [ 353 LANGUAGE_EXCEPTIONS = [
352 (CPP_FILE_EXTS, CPP_EXCEPTIONS), 354 (CPP_FILE_EXTS, CPP_EXCEPTIONS),
353 (JAVA_FILE_EXTS, JAVA_EXCEPTIONS), 355 (JAVA_FILE_EXTS, JAVA_EXCEPTIONS),
356 (JS_FILE_EXTS, JS_EXCEPTIONS),
354 (OBJC_FILE_EXTS, OBJC_EXCEPTIONS), 357 (OBJC_FILE_EXTS, OBJC_EXCEPTIONS),
355 (PY_FILE_EXTS, PY_EXCEPTIONS), 358 (PY_FILE_EXTS, PY_EXCEPTIONS),
356 ] 359 ]
357 360
358 def no_long_lines(file_extension, line): 361 def no_long_lines(file_extension, line):
359 # Check for language specific exceptions. 362 # Check for language specific exceptions.
360 if any(file_extension in exts and line.startswith(exceptions) 363 if any(file_extension in exts and line.startswith(exceptions)
361 for exts, exceptions in LANGUAGE_EXCEPTIONS): 364 for exts, exceptions in LANGUAGE_EXCEPTIONS):
362 return True 365 return True
363 366
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 for f in affected_files: 1158 for f in affected_files:
1156 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1159 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1157 rc = gn.main(cmd) 1160 rc = gn.main(cmd)
1158 if rc == 2: 1161 if rc == 2:
1159 warnings.append(output_api.PresubmitPromptWarning( 1162 warnings.append(output_api.PresubmitPromptWarning(
1160 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1163 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1161 f.AbsoluteLocalPath(), f.LocalPath()))) 1164 f.AbsoluteLocalPath(), f.LocalPath())))
1162 # It's just a warning, so ignore other types of failures assuming they'll be 1165 # It's just a warning, so ignore other types of failures assuming they'll be
1163 # caught elsewhere. 1166 # caught elsewhere.
1164 return warnings 1167 return warnings
OLDNEW
« 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