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

Side by Side Diff: Tools/Scripts/webkitpy/style/checkers/cpp.py

Issue 1184413003: Relax the braces style checker to allow either {} or { }. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pinned
Patch Set: Relax the {} check. Created 5 years, 6 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 | Tools/Scripts/webkitpy/style/checkers/cpp_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 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # 2 #
3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved.
4 # Copyright (C) 2009 Torch Mobile Inc. 4 # Copyright (C) 2009 Torch Mobile Inc.
5 # Copyright (C) 2009 Apple Inc. All rights reserved. 5 # Copyright (C) 2009 Apple Inc. All rights reserved.
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
7 # 7 #
8 # Redistribution and use in source and binary forms, with or without 8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are 9 # modification, are permitted provided that the following conditions are
10 # met: 10 # met:
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 if search(r'}else', line): 2070 if search(r'}else', line):
2071 error(line_number, 'whitespace/braces', 5, 2071 error(line_number, 'whitespace/braces', 5,
2072 'Missing space before else') 2072 'Missing space before else')
2073 2073
2074 # You shouldn't have spaces before your brackets, except maybe after 2074 # You shouldn't have spaces before your brackets, except maybe after
2075 # 'delete []' or 'new char * []'. 2075 # 'delete []' or 'new char * []'.
2076 if search(r'\w\s+\[', line) and not search(r'delete\s+\[', line): 2076 if search(r'\w\s+\[', line) and not search(r'delete\s+\[', line):
2077 error(line_number, 'whitespace/braces', 5, 2077 error(line_number, 'whitespace/braces', 5,
2078 'Extra space before [') 2078 'Extra space before [')
2079 2079
2080 # There should always be a single space in between braces on the same line. 2080 # There should always be zero or one space in between braces on the same lin e.
2081 if search(r'\{\}', line):
2082 error(line_number, 'whitespace/braces', 5, 'Missing space inside { }.')
2083 if search(r'\{\s\s+\}', line): 2081 if search(r'\{\s\s+\}', line):
2084 error(line_number, 'whitespace/braces', 5, 'Too many spaces inside { }.' ) 2082 error(line_number, 'whitespace/braces', 5, 'Too many spaces inside { }.' )
2085 2083
2086 # You shouldn't have a space before a semicolon at the end of the line. 2084 # You shouldn't have a space before a semicolon at the end of the line.
2087 # There's a special case for "for" since the style guide allows space before 2085 # There's a special case for "for" since the style guide allows space before
2088 # the semicolon there. 2086 # the semicolon there.
2089 if search(r':\s*;\s*$', line): 2087 if search(r':\s*;\s*$', line):
2090 error(line_number, 'whitespace/semicolon', 5, 2088 error(line_number, 'whitespace/semicolon', 5,
2091 'Semicolon defining empty statement. Use { } instead.') 2089 'Semicolon defining empty statement. Use { } instead.')
2092 elif search(r'^\s*;\s*$', line): 2090 elif search(r'^\s*;\s*$', line):
(...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after
4087 4085
4088 def check(self, lines): 4086 def check(self, lines):
4089 _process_lines(self.file_path, self.file_extension, lines, 4087 _process_lines(self.file_path, self.file_extension, lines,
4090 self.handle_style_error, self.min_confidence) 4088 self.handle_style_error, self.min_confidence)
4091 4089
4092 4090
4093 # FIXME: Remove this function (requires refactoring unit tests). 4091 # FIXME: Remove this function (requires refactoring unit tests).
4094 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): 4092 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None):
4095 checker = CppChecker(filename, file_extension, error, min_confidence, fs) 4093 checker = CppChecker(filename, file_extension, error, min_confidence, fs)
4096 checker.check(lines) 4094 checker.check(lines)
OLDNEW
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698