Changeset 79102 in webkit


Ignore:
Timestamp:
Feb 18, 2011 10:52:15 PM (13 years ago)
Author:
levin@chromium.org
Message:

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.
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r79096 r79102  
     12011-02-18  David Levin  <levin@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        check-webkit-style: Misses brace style error when the line with the { has a } in it.
     6        https://bugs.webkit.org/show_bug.cgi?id=54769
     7
     8        * Scripts/webkitpy/style/checkers/cpp.py: Fixed the check for the close brace
     9          to only look after the last open brace, so that the open brace in this line
     10          "} else {" will still be able to trigger the error.
     11        * Scripts/webkitpy/style/checkers/cpp_unittest.py: Added related unit tests.
     12
    1132011-02-18  Zan Dobersek  <zandobersek@gmail.com>
    214
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r79095 r79102  
    21282128        # one line control statement was previous.
    21292129        previous_line = clean_lines.elided[line_number - 2]
    2130         if (previous_line.find('{') > 0 and previous_line.find('}') < 0
     2130        last_open_brace = previous_line.rfind('{')
     2131        if (last_open_brace != -1 and previous_line.find('}', last_open_brace) == -1
    21312132            and search(r'\b(if|for|foreach|while|else)\b', previous_line)):
    21322133            error(line_number, 'whitespace/braces', 4,
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r79095 r79102  
    36173617             'One line control clauses should not use braces.  [whitespace/braces] [4]'])
    36183618        self.assert_multi_line_lint(
     3619            'if (condition)\n'
     3620            '    doSomething();\n'
     3621            'else {\n'
     3622            '    doSomethingElse();\n'
     3623            '}\n',
     3624            'One line control clauses should not use braces.  [whitespace/braces] [4]')
     3625        self.assert_multi_line_lint(
     3626            'if (condition) {\n'
     3627            '    doSomething1();\n'
     3628            '    doSomething2();\n'
     3629            '} else {\n'
     3630            '    doSomethingElse();\n'
     3631            '}\n',
     3632            'One line control clauses should not use braces.  [whitespace/braces] [4]')
     3633        self.assert_multi_line_lint(
    36193634            'void func()\n'
    36203635            '{\n'
Note: See TracChangeset for help on using the changeset viewer.