- Revision
- 183567
- Author
- [email protected]
- Date
- 2015-04-29 12:32:54 -0700 (Wed, 29 Apr 2015)
Log Message
check-webkit-style: Don't complain about returning value from Objective-C method call in header
<http://webkit.org/b/144395>
Reviewed by Andy Estes.
* Scripts/webkitpy/style/checkers/cpp.py:
(check_spacing): Update regex so 'return' is ignored if it
precedes the whitespace and bracket. Change category name to
'whitespace/brackets'. Add period to error message.
(CppChecker): Add 'whitespace/brackets' as a category.
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(ErrorCollector.__call__): Replace 'STYLE_CATEGORIES' with
'CppChecker.categories' since that's where the list lives now.
(CppStyleTest.test_spacing_before_brackets): Add tests for
'whitespace/brackets' issues and non-issues.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (183566 => 183567)
--- trunk/Tools/ChangeLog 2015-04-29 19:23:04 UTC (rev 183566)
+++ trunk/Tools/ChangeLog 2015-04-29 19:32:54 UTC (rev 183567)
@@ -1,3 +1,21 @@
+2015-04-29 David Kilzer <[email protected]>
+
+ check-webkit-style: Don't complain about returning value from Objective-C method call in header
+ <http://webkit.org/b/144395>
+
+ Reviewed by Andy Estes.
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (check_spacing): Update regex so 'return' is ignored if it
+ precedes the whitespace and bracket. Change category name to
+ 'whitespace/brackets'. Add period to error message.
+ (CppChecker): Add 'whitespace/brackets' as a category.
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+ (ErrorCollector.__call__): Replace 'STYLE_CATEGORIES' with
+ 'CppChecker.categories' since that's where the list lives now.
+ (CppStyleTest.test_spacing_before_brackets): Add tests for
+ 'whitespace/brackets' issues and non-issues.
+
2015-04-29 Alex Christensen <[email protected]>
Fix WinCairo bot.
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (183566 => 183567)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2015-04-29 19:23:04 UTC (rev 183566)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2015-04-29 19:32:54 UTC (rev 183567)
@@ -2005,9 +2005,9 @@
# 'delete []' or 'new char * []'. Objective-C can't follow this rule
# because of method calls.
if file_extension != 'mm' and file_extension != 'm':
- if search(r'\w\s+\[', line) and not search(r'delete\s+\[', line):
- error(line_number, 'whitespace/braces', 5,
- 'Extra space before [')
+ if search(r'\w\s+\[', line) and not search(r'(delete|return)\s+\[', line):
+ error(line_number, 'whitespace/brackets', 5,
+ 'Extra space before [.')
# There should always be a single space in between braces on the same line.
if search(r'\{\}', line):
@@ -3895,6 +3895,7 @@
'runtime/wtf_move',
'whitespace/blank_line',
'whitespace/braces',
+ 'whitespace/brackets',
'whitespace/colon',
'whitespace/comma',
'whitespace/comments',
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (183566 => 183567)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2015-04-29 19:23:04 UTC (rev 183566)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2015-04-29 19:32:54 UTC (rev 183567)
@@ -46,7 +46,7 @@
# This class works as an error collector and replaces cpp_style.Error
# function for the unit tests. We also verify each category we see
-# is in STYLE_CATEGORIES, to help keep that list up to date.
+# is in CppChecker.categories, to help keep that list up to date.
class ErrorCollector:
_all_style_categories = CppChecker.categories
# This is a list including all categories seen in any unit test.
@@ -65,7 +65,7 @@
def __call__(self, line_number, category, confidence, message):
self._assert_fn(category in self._all_style_categories,
'Message "%s" has category "%s",'
- ' which is not in STYLE_CATEGORIES' % (message, category))
+ ' which is not in CppChecker.categories' % (message, category))
if self._lines_to_check and not line_number in self._lines_to_check:
return False
@@ -1730,6 +1730,14 @@
self.assert_lint(' {}', 'Missing space inside { }. [whitespace/braces] [5]')
self.assert_lint(' { }', 'Too many spaces inside { }. [whitespace/braces] [5]')
+ def test_spacing_before_brackets(self):
+ self.assert_lint('delete [] base;', '')
+ # See SOFT_LINK_CLASS_FOR_HEADER() macro in SoftLinking.h.
+ self.assert_lint(' return [get_##framework##_##className##Class() alloc]; \\', '')
+ self.assert_lint(' m_taskFunction = [callee, method, arguments...] {', '')
+ self.assert_lint('int main(int argc, char* agrv [])', 'Extra space before [. [whitespace/brackets] [5]')
+ self.assert_lint(' str [strLength] = \'\\0\';', 'Extra space before [. [whitespace/brackets] [5]')
+
def test_spacing_around_else(self):
self.assert_lint('}else {', 'Missing space before else'
' [whitespace/braces] [5]')