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

Side by Side Diff: tools/presubmit.py

Issue 1600873002: [formatting] Remove the formatting requirement for 2 empty lines between declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 | « .clang-format ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2012 the V8 project authors. All rights reserved. 3 # Copyright 2012 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 lines.append(str(line)) 347 lines.append(str(line))
348 linenumbers = ', '.join(lines) 348 linenumbers = ', '.join(lines)
349 if len(lines) > 1: 349 if len(lines) > 1:
350 print "%s has trailing whitespaces in lines %s." % (name, linenumbers) 350 print "%s has trailing whitespaces in lines %s." % (name, linenumbers)
351 else: 351 else:
352 print "%s has trailing whitespaces in line %s." % (name, linenumbers) 352 print "%s has trailing whitespaces in line %s." % (name, linenumbers)
353 result = False 353 result = False
354 if not contents.endswith('\n') or contents.endswith('\n\n'): 354 if not contents.endswith('\n') or contents.endswith('\n\n'):
355 print "%s does not end with a single new line." % name 355 print "%s does not end with a single new line." % name
356 result = False 356 result = False
357 # Check two empty lines between declarations.
358 if name.endswith(".cc"):
359 line = 0
360 lines = []
361 parts = contents.split('\n')
362 while line < len(parts) - 2:
363 if self.EndOfDeclaration(parts[line]):
364 if self.StartOfDeclaration(parts[line + 1]):
365 lines.append(str(line + 1))
366 line += 1
367 elif parts[line + 1] == "" and \
368 self.StartOfDeclaration(parts[line + 2]):
369 lines.append(str(line + 1))
370 line += 2
371 line += 1
372 if len(lines) >= 1:
373 linenumbers = ', '.join(lines)
374 if len(lines) > 1:
375 print "%s does not have two empty lines between declarations " \
376 "in lines %s." % (name, linenumbers)
377 else:
378 print "%s does not have two empty lines between declarations " \
379 "in line %s." % (name, linenumbers)
380 result = False
381 # Sanitize flags for fuzzer. 357 # Sanitize flags for fuzzer.
382 if "mjsunit" in name: 358 if "mjsunit" in name:
383 match = FLAGS_LINE.search(contents) 359 match = FLAGS_LINE.search(contents)
384 if match: 360 if match:
385 print "%s Flags should use '-' (not '_')" % name 361 print "%s Flags should use '-' (not '_')" % name
386 result = False 362 result = False
387 return result 363 return result
388 364
389 def ProcessFiles(self, files, path): 365 def ProcessFiles(self, files, path):
390 success = True 366 success = True
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 success &= CheckExternalReferenceRegistration(workspace) 487 success &= CheckExternalReferenceRegistration(workspace)
512 success &= CheckStatusFiles(workspace) 488 success &= CheckStatusFiles(workspace)
513 if success: 489 if success:
514 return 0 490 return 0
515 else: 491 else:
516 return 1 492 return 1
517 493
518 494
519 if __name__ == '__main__': 495 if __name__ == '__main__':
520 sys.exit(Main()) 496 sys.exit(Main())
OLDNEW
« no previous file with comments | « .clang-format ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698