Changeset 244688 in webkit


Ignore:
Timestamp:
Apr 26, 2019 9:25:27 AM (5 years ago)
Author:
yoshiaki.jitsukawa@sony.com
Message:

check-webkit-style complains the first block in while loop.
https://bugs.webkit.org/show_bug.cgi?id=197307

The style checker shouldn't complain about an open brace on
its own line if the last non-whitespace character on the previous
non-blank line is another open brace, because it's likely to
indicate the begining of a nested code block.

Reviewed by Alex Christensen.

  • Scripts/webkitpy/style/checkers/cpp.py:

(check_braces):

  • Scripts/webkitpy/style/checkers/cpp_unittest.py:

(WebKitStyleTest.test_braces):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r244687 r244688  
     12019-04-26  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
     2
     3        check-webkit-style complains the first block in while loop.
     4        https://bugs.webkit.org/show_bug.cgi?id=197307
     5
     6        The style checker shouldn't complain about an open brace on
     7        its own line if the last non-whitespace character on the previous
     8        non-blank line is another open brace, because it's likely to
     9        indicate the begining of a nested code block.
     10
     11        Reviewed by Alex Christensen.
     12
     13        * Scripts/webkitpy/style/checkers/cpp.py:
     14        (check_braces):
     15        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
     16        (WebKitStyleTest.test_braces):
     17
    1182019-04-26  Sihui Liu  <sihui_liu@apple.com>
    219
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r243863 r244688  
    25142514        # We also allow '#' for #endif and '=' for array initialization,
    25152515        # and '- (' and '+ (' for Objective-C methods.
     2516        # Also we don't complain if the last non-whitespace character
     2517        # on the previous non-blank line is '{' because it's likely to
     2518        # indicate the begining of a nested code block.
    25162519        previous_line = get_previous_non_blank_line(clean_lines, line_number)[0]
    25172520        if ((not search(r'[;:}{)=]\s*$|\)\s*((const|override|const override|final|const final)\s*)?(->\s*\S+)?\s*$', previous_line)
     
    25202523            and previous_line.find('#') < 0
    25212524            and previous_line.find('- (') != 0
    2522             and previous_line.find('+ (') != 0):
     2525            and previous_line.find('+ (') != 0
     2526            and not search(r'{\s*$', previous_line)):
    25232527            error(line_number, 'whitespace/braces', 4,
    25242528                  'This { should be at the end of the previous line')
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r243411 r244688  
    48924892            '    }\n',
    48934893            '')
     4894        # 6. An open brace on its own line for a nested code block should be allowed.
     4895        self.assert_multi_line_lint(
     4896            '    if (condition) {\n'
     4897            '        {\n'
     4898            '            j = 1;\n'
     4899            '        }\n'
     4900            '    }\n',
     4901            '')
     4902        self.assert_multi_line_lint(
     4903            '    if (condition1\n'
     4904            '        || condition2\n'
     4905            '        && condition3) {\n'
     4906            '        {\n'
     4907            '            j = 1;\n'
     4908            '        }\n'
     4909            '    }\n',
     4910            '')
    48944911
    48954912    def test_null_false_zero(self):
Note: See TracChangeset for help on using the changeset viewer.