Changeset 240299 in webkit


Ignore:
Timestamp:
Jan 22, 2019 2:51:19 PM (5 years ago)
Author:
ddkilzer@apple.com
Message:

check-webkit-style reports false-positive whitespace/init warning in C++ initialization parameters
<https://webkit.org/b/193676>

Reviewed by Alexey Proskuryakov.

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

(check_member_initialization_list):

  • Don't report missing whitespace around colon if the colon at the start of the line is formatted correctly.
  • Scripts/webkitpy/style/checkers/cpp_unittest.py:

(WebKitStyleTest.test_member_initialization_list):

  • Add a test for a missing permutation of existing tests.
  • Add a test this false-positive.
  • Add blank lines between subtests to make them easier to read.
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r240291 r240299  
     12019-01-22  David Kilzer  <ddkilzer@apple.com>
     2
     3        check-webkit-style reports false-positive whitespace/init warning in C++ initialization parameters
     4        <https://webkit.org/b/193676>
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * Scripts/webkitpy/style/checkers/cpp.py:
     9        (check_member_initialization_list):
     10        - Don't report missing whitespace around colon if the colon at
     11          the start of the line is formatted correctly.
     12        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
     13        (WebKitStyleTest.test_member_initialization_list):
     14        - Add a test for a missing permutation of existing tests.
     15        - Add a test this false-positive.
     16        - Add blank lines between subtests to make them easier to read.
     17
    1182019-01-22  Aakash Jain  <aakash_jain@apple.com>
    219
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r240235 r240299  
    21052105    # match the start of initialization list
    21062106    if search(r'^(?P<indentation>\s*)((explicit\s+)?[^(\s|\?)]+\([^\?]*\)\s?\:|^(\s|\?)*\:)([^\:]|\Z)[^;]*$', line):
    2107         if search(r'[^:]\:[^\:\s]+', line):
     2107        if search(r'[^:]\:[^\:\s]+', line) and not search(r'^\s*:\s\S+', line):
    21082108            error(line_number, 'whitespace/init', 4,
    21092109                'Missing spaces around :')
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r240235 r240299  
    55045504        'Should be indented on a separate line, with the colon or comma first on that line.'
    55055505        '  [whitespace/indent] [4]')
     5506
    55065507        self.assert_lint('MyClass::MyClass(Document* doc) : MySuperClass() { }',
    55075508        'Should be indented on a separate line, with the colon or comma first on that line.'
    55085509        '  [whitespace/indent] [4]')
     5510
    55095511        self.assert_multi_line_lint((
    55105512            'MyClass::MyClass(Document* doc)\n'
     
    55135515            '    , m_doc(0)\n'
    55145516            '{ }'), '')
     5517
    55155518        self.assert_multi_line_lint('''\
    55165519        MyClass::MyClass(Document* doc) : MySuperClass()
     
    55185521        'Should be indented on a separate line, with the colon or comma first on that line.'
    55195522        '  [whitespace/indent] [4]')
     5523
    55205524        self.assert_multi_line_lint('''\
    55215525        MyClass::MyClass(Document* doc)
     
    55245528        'Wrong number of spaces before statement. (expected: 12)'
    55255529        '  [whitespace/indent] [4]')
     5530
    55265531        self.assert_multi_line_lint('''\
    55275532        MyClass::MyClass(Document* doc) :
     
    55335538         'Comma should be at the beginning of the line in a member initialization list.'
    55345539         '  [whitespace/init] [4]'])
     5540
     5541        self.assert_multi_line_lint('''\
     5542            MyClass::MyClass(Document* doc): MySuperClass()
     5543            { }''',
     5544            'Should be indented on a separate line, with the colon or comma first on that line.'
     5545            '  [whitespace/indent] [4]')
     5546
    55355547        self.assert_multi_line_lint('''\
    55365548        MyClass::MyClass(Document* doc) :MySuperClass()
     
    55395551         'Should be indented on a separate line, with the colon or comma first on that line.'
    55405552         '  [whitespace/indent] [4]'])
     5553
    55415554        self.assert_multi_line_lint('''\
    55425555        MyClass::MyClass(Document* doc):MySuperClass()
     
    55455558         'Should be indented on a separate line, with the colon or comma first on that line.'
    55465559         '  [whitespace/indent] [4]'])
     5560
    55475561        self.assert_multi_line_lint('''\
    55485562        MyClass::MyClass(Document* doc) : MySuperClass()
     
    55835597        { }''',
    55845598        'Missing spaces around :  [whitespace/init] [4]')
     5599
    55855600        self.assert_multi_line_lint('''\
    55865601        MyClass::MyClass(Document* doc)
     
    55905605        'Comma should be at the beginning of the line in a member initialization list.'
    55915606        '  [whitespace/init] [4]')
     5607
    55925608        self.assert_multi_line_lint('''\
    55935609        class MyClass : public Goo {
    55945610        };''',
    55955611        '')
     5612
    55965613        self.assert_multi_line_lint('''\
    55975614        class MyClass
     
    56005617        };''',
    56015618        '')
     5619
    56025620        self.assert_multi_line_lint('''\
    56035621        MyClass::MyClass(Document* doc)
     
    56055623        { }''',
    56065624        '')
     5625
     5626        self.assert_multi_line_lint('''\
     5627            PreviewConverter::PreviewConverter(NSData *data, const String& uti, const String& password)
     5628                : m_platformConverter { adoptNS([allocQLPreviewConverterInstance() initWithData:data name:nil uti:uti options:optionsWithPassword(password)]) }
     5629            { }''',
     5630            '')
     5631
    56075632        self.assert_lint('::ShowWindow(m_overlay);', '')
     5633
    56085634        self.assert_lint('o = foo(b ? bar() : baz());', '')
     5635
    56095636        self.assert_lint('MYMACRO(a ? b() : c);', '')
    56105637
Note: See TracChangeset for help on using the changeset viewer.