Title: [240299] trunk/Tools
Revision
240299
Author
ddkil...@apple.com
Date
2019-01-22 14:51:19 -0800 (Tue, 22 Jan 2019)

Log 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.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (240298 => 240299)


--- trunk/Tools/ChangeLog	2019-01-22 22:31:36 UTC (rev 240298)
+++ trunk/Tools/ChangeLog	2019-01-22 22:51:19 UTC (rev 240299)
@@ -1,3 +1,20 @@
+2019-01-22  David Kilzer  <ddkil...@apple.com>
+
+        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.
+
 2019-01-22  Aakash Jain  <aakash_j...@apple.com>
 
         [build.webkit.org] Unit-test failure after r237113

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (240298 => 240299)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2019-01-22 22:31:36 UTC (rev 240298)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2019-01-22 22:51:19 UTC (rev 240299)
@@ -2104,7 +2104,7 @@
     begin_line = line
     # match the start of initialization list
     if search(r'^(?P<indentation>\s*)((explicit\s+)?[^(\s|\?)]+\([^\?]*\)\s?\:|^(\s|\?)*\:)([^\:]|\Z)[^;]*$', line):
-        if search(r'[^:]\:[^\:\s]+', line):
+        if search(r'[^:]\:[^\:\s]+', line) and not search(r'^\s*:\s\S+', line):
             error(line_number, 'whitespace/init', 4,
                 'Missing spaces around :')
         if (not line.lstrip().startswith(':')) and search(r'[^\s]\(.*\)\s?\:.*[^;]*$', line):

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (240298 => 240299)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2019-01-22 22:31:36 UTC (rev 240298)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2019-01-22 22:51:19 UTC (rev 240299)
@@ -5503,9 +5503,11 @@
         self.assert_lint('explicit MyClass(Document* doc) : MySuperClass() { }',
         'Should be indented on a separate line, with the colon or comma first on that line.'
         '  [whitespace/indent] [4]')
+
         self.assert_lint('MyClass::MyClass(Document* doc) : MySuperClass() { }',
         'Should be indented on a separate line, with the colon or comma first on that line.'
         '  [whitespace/indent] [4]')
+
         self.assert_multi_line_lint((
             'MyClass::MyClass(Document* doc)\n'
             '    : m_myMember(b ? bar() : baz())\n'
@@ -5512,11 +5514,13 @@
             '    , MySuperClass()\n'
             '    , m_doc(0)\n'
             '{ }'), '')
+
         self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc) : MySuperClass()
         { }''',
         'Should be indented on a separate line, with the colon or comma first on that line.'
         '  [whitespace/indent] [4]')
+
         self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc)
         : MySuperClass()
@@ -5523,6 +5527,7 @@
         { }''',
         'Wrong number of spaces before statement. (expected: 12)'
         '  [whitespace/indent] [4]')
+
         self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc) :
             MySuperClass(),
@@ -5532,12 +5537,20 @@
          '  [whitespace/indent] [4]',
          'Comma should be at the beginning of the line in a member initialization list.'
          '  [whitespace/init] [4]'])
+
         self.assert_multi_line_lint('''\
+            MyClass::MyClass(Document* doc): MySuperClass()
+            { }''',
+            'Should be indented on a separate line, with the colon or comma first on that line.'
+            '  [whitespace/indent] [4]')
+
+        self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc) :MySuperClass()
         { }''',
         ['Missing spaces around :  [whitespace/init] [4]',
          'Should be indented on a separate line, with the colon or comma first on that line.'
          '  [whitespace/indent] [4]'])
+
         self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc):MySuperClass()
         { }''',
@@ -5544,6 +5557,7 @@
         ['Missing spaces around :  [whitespace/init] [4]',
          'Should be indented on a separate line, with the colon or comma first on that line.'
          '  [whitespace/indent] [4]'])
+
         self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc) : MySuperClass()
         ,MySuperClass()
@@ -5582,6 +5596,7 @@
             :MySuperClass()
         { }''',
         'Missing spaces around :  [whitespace/init] [4]')
+
         self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc)
             : MySuperClass() ,
@@ -5589,10 +5604,12 @@
         { }''',
         'Comma should be at the beginning of the line in a member initialization list.'
         '  [whitespace/init] [4]')
+
         self.assert_multi_line_lint('''\
         class MyClass : public Goo {
         };''',
         '')
+
         self.assert_multi_line_lint('''\
         class MyClass
         : public Goo
@@ -5599,13 +5616,23 @@
         , public foo {
         };''',
         '')
+
         self.assert_multi_line_lint('''\
         MyClass::MyClass(Document* doc)
             : MySuperClass(doc, doc)
         { }''',
         '')
+
+        self.assert_multi_line_lint('''\
+            PreviewConverter::PreviewConverter(NSData *data, const String& uti, const String& password)
+                : m_platformConverter { adoptNS([allocQLPreviewConverterInstance() initWithData:data name:nil uti:uti options:optionsWithPassword(password)]) }
+            { }''',
+            '')
+
         self.assert_lint('::ShowWindow(m_overlay);', '')
+
         self.assert_lint('o = foo(b ? bar() : baz());', '')
+
         self.assert_lint('MYMACRO(a ? b() : c);', '')
 
     def test_min_versions_of_wk_api_available(self):
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to