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 """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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 extra_maxlen = file_maxlen * 3 / 2 | 364 extra_maxlen = file_maxlen * 3 / 2 |
365 | 365 |
366 line_len = len(line) | 366 line_len = len(line) |
367 if line_len <= file_maxlen: | 367 if line_len <= file_maxlen: |
368 return True | 368 return True |
369 | 369 |
370 # Allow long URLs of any length. | 370 # Allow long URLs of any length. |
371 if any((url in line) for url in ('file://', 'http://', 'https://')): | 371 if any((url in line) for url in ('file://', 'http://', 'https://')): |
372 return True | 372 return True |
373 | 373 |
374 # If 'line-too-long' is explictly suppressed for the line, any length is | 374 # If 'line-too-long' is explicitly suppressed for the line, any length is |
375 # acceptable. | 375 # acceptable. |
376 if 'pylint: disable=line-too-long' in line and file_extension == 'py': | 376 if 'pylint: disable=line-too-long' in line and file_extension == 'py': |
377 return True | 377 return True |
378 | 378 |
379 if line_len > extra_maxlen: | 379 if line_len > extra_maxlen: |
380 return False | 380 return False |
381 | 381 |
382 if 'url(' in line and file_extension == 'css': | 382 if 'url(' in line and file_extension == 'css': |
383 return True | 383 return True |
384 | 384 |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 for f in affected_files: | 1176 for f in affected_files: |
1177 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] | 1177 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] |
1178 rc = gn.main(cmd) | 1178 rc = gn.main(cmd) |
1179 if rc == 2: | 1179 if rc == 2: |
1180 warnings.append(output_api.PresubmitPromptWarning( | 1180 warnings.append(output_api.PresubmitPromptWarning( |
1181 '%s requires formatting. Please run:\n gn format %s' % ( | 1181 '%s requires formatting. Please run:\n gn format %s' % ( |
1182 f.AbsoluteLocalPath(), f.LocalPath()))) | 1182 f.AbsoluteLocalPath(), f.LocalPath()))) |
1183 # It's just a warning, so ignore other types of failures assuming they'll be | 1183 # It's just a warning, so ignore other types of failures assuming they'll be |
1184 # caught elsewhere. | 1184 # caught elsewhere. |
1185 return warnings | 1185 return warnings |
OLD | NEW |