Commit b7b288c9 authored by levin@chromium.org's avatar levin@chromium.org

2011-02-18 David Levin <levin@chromium.org>

        Reviewed by Eric Seidel.

        check-webkit-style: Misses brace style error when the line with the { has a } in it.
        https://bugs.webkit.org/show_bug.cgi?id=54769

        * Scripts/webkitpy/style/checkers/cpp.py: Fixed the check for the close brace
          to only look after the last open brace, so that the open brace in this line
          "} else {" will still be able to trigger the error.
        * Scripts/webkitpy/style/checkers/cpp_unittest.py: Added related unit tests.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2342432f
2011-02-18 David Levin <levin@chromium.org>
Reviewed by Eric Seidel.
check-webkit-style: Misses brace style error when the line with the { has a } in it.
https://bugs.webkit.org/show_bug.cgi?id=54769
* Scripts/webkitpy/style/checkers/cpp.py: Fixed the check for the close brace
to only look after the last open brace, so that the open brace in this line
"} else {" will still be able to trigger the error.
* Scripts/webkitpy/style/checkers/cpp_unittest.py: Added related unit tests.
2011-02-18 Zan Dobersek <zandobersek@gmail.com>
Reviewed by Martin Robinson.
......
......@@ -2127,7 +2127,8 @@ def check_braces(clean_lines, line_number, error):
# We check if a closed brace has started a line to see if a
# one line control statement was previous.
previous_line = clean_lines.elided[line_number - 2]
if (previous_line.find('{') > 0 and previous_line.find('}') < 0
last_open_brace = previous_line.rfind('{')
if (last_open_brace != -1 and previous_line.find('}', last_open_brace) == -1
and search(r'\b(if|for|foreach|while|else)\b', previous_line)):
error(line_number, 'whitespace/braces', 4,
'One line control clauses should not use braces.')
......
......@@ -3615,6 +3615,21 @@ class WebKitStyleTest(CppStyleTestBase):
'}\n',
['More than one command on the same line in if [whitespace/parens] [4]',
'One line control clauses should not use braces. [whitespace/braces] [4]'])
self.assert_multi_line_lint(
'if (condition)\n'
' doSomething();\n'
'else {\n'
' doSomethingElse();\n'
'}\n',
'One line control clauses should not use braces. [whitespace/braces] [4]')
self.assert_multi_line_lint(
'if (condition) {\n'
' doSomething1();\n'
' doSomething2();\n'
'} else {\n'
' doSomethingElse();\n'
'}\n',
'One line control clauses should not use braces. [whitespace/braces] [4]')
self.assert_multi_line_lint(
'void func()\n'
'{\n'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment