| 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 | 10 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 """Checks that there aren't any lines longer than maxlen characters in any of | 316 """Checks that there aren't any lines longer than maxlen characters in any of |
| 317 the text files to be submitted. | 317 the text files to be submitted. |
| 318 """ | 318 """ |
| 319 maxlens = { | 319 maxlens = { |
| 320 'java': 100, | 320 'java': 100, |
| 321 '': maxlen, | 321 '': maxlen, |
| 322 } | 322 } |
| 323 # Note: these are C++ specific but processed on all languages. :( | 323 # Note: these are C++ specific but processed on all languages. :( |
| 324 MACROS = ('#define', '#include', '#import', '#pragma', '#if', '#endif') | 324 MACROS = ('#define', '#include', '#import', '#pragma', '#if', '#endif') |
| 325 | 325 |
| 326 # Special java statements. |
| 327 SPECIAL_JAVA_STARTS = ('package ', 'import ') |
| 328 |
| 326 def no_long_lines(file_extension, line): | 329 def no_long_lines(file_extension, line): |
| 330 # Allow special java statements to be as long as neccessary. |
| 331 if file_extension == 'java' and line.startswith(SPECIAL_JAVA_STARTS): |
| 332 return True |
| 333 |
| 327 file_maxlen = maxlens.get(file_extension, maxlens['']) | 334 file_maxlen = maxlens.get(file_extension, maxlens['']) |
| 328 # Stupidly long symbols that needs to be worked around if takes 66% of line. | 335 # Stupidly long symbols that needs to be worked around if takes 66% of line. |
| 329 long_symbol = file_maxlen * 2 / 3 | 336 long_symbol = file_maxlen * 2 / 3 |
| 330 # Hard line length limit at 50% more. | 337 # Hard line length limit at 50% more. |
| 331 extra_maxlen = file_maxlen * 3 / 2 | 338 extra_maxlen = file_maxlen * 3 / 2 |
| 332 | 339 |
| 333 line_len = len(line) | 340 line_len = len(line) |
| 334 if line_len <= file_maxlen: | 341 if line_len <= file_maxlen: |
| 335 return True | 342 return True |
| 336 | 343 |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 966 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
| 960 input_api, output_api)) | 967 input_api, output_api)) |
| 961 snapshot("checking license") | 968 snapshot("checking license") |
| 962 results.extend(input_api.canned_checks.CheckLicense( | 969 results.extend(input_api.canned_checks.CheckLicense( |
| 963 input_api, output_api, license_header, source_file_filter=sources)) | 970 input_api, output_api, license_header, source_file_filter=sources)) |
| 964 snapshot("checking was uploaded") | 971 snapshot("checking was uploaded") |
| 965 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 972 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
| 966 input_api, output_api)) | 973 input_api, output_api)) |
| 967 snapshot("done") | 974 snapshot("done") |
| 968 return results | 975 return results |
| OLD | NEW |