Skip to content
Permalink
Browse files
Bug 161165 - check-webkit-style doesn't understand macros containing …
…`else` or labels

https://bugs.webkit.org/show_bug.cgi?id=161165

Patch by JF Bastien <jfbastien@apple.com> on 2016-08-29
Reviewed by Geoffrey Garen.

Fix handling of `else` in a macro. Don't handle labels in a macro:
the checker is already pretty messy in that area and it should be
a rare thing.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_braces):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest.test_else_clause_not_on_same_line_as_else):

Canonical link: https://commits.webkit.org/179509@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205135 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jfbastien authored and webkit-commit-queue committed Aug 29, 2016
1 parent bc1806b commit fb3a823ff2e4fe95ded07df2be8b089cf29d98fd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
@@ -1,3 +1,19 @@
2016-08-29 JF Bastien <jfbastien@apple.com>

Bug 161165 - check-webkit-style doesn't understand macros containing `else` or labels
https://bugs.webkit.org/show_bug.cgi?id=161165

Reviewed by Geoffrey Garen.

Fix handling of `else` in a macro. Don't handle labels in a macro:
the checker is already pretty messy in that area and it should be
a rare thing.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_braces):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest.test_else_clause_not_on_same_line_as_else):

2016-08-29 Alex Christensen <achristensen@webkit.org>

API test URLParserTest.ParserFailures failing ASSERT_NOT_REACHED
@@ -2507,7 +2507,9 @@ def check_braces(clean_lines, line_number, file_state, error):
'An else should appear on the same line as the preceding }')

# Likewise, an else should never have the else clause on the same line
if search(r'\belse [^\s{]', line) and not search(r'\belse if\b', line):
if (search(r'\belse [^\s{]', line)
and not search(r'\belse if\b', line)
and not search(r'\belse\s*\\$', line)):
error(line_number, 'whitespace/newline', 4,
'Else clause should never be on same line as else (use 2 lines)')

@@ -2271,6 +2271,7 @@ def test_else_clause_not_on_same_line_as_else(self):
'(use 2 lines) [whitespace/newline] [4]')
self.assert_lint(' else if (blah) {', '')
self.assert_lint(' variable_ends_in_else = true;', '')
self.assert_lint(' else \\', '')

def test_comma(self):
self.assert_lint('a = f(1,2);',

0 comments on commit fb3a823

Please sign in to comment.