check-webkit-style: NS_ERROR_ENUM and NS_OPTIONS should not be handled as function...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Aug 2017 23:25:27 +0000 (23:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Aug 2017 23:25:27 +0000 (23:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175286

Patch by Yoshiaki Jitsukawa <Yoshiaki.Jitsukawa@sony.com> on 2017-08-07
Reviewed by Myles C. Maxfield.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_braces):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest.test_braces.NS_ERROR_ENUM):
(WebKitStyleTest.test_braces):
(WebKitStyleTest.test_braces.NS_OPTIONS):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220367 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/style/checkers/cpp.py
Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

index e50b05d674fa82ced74d999338a35c6677775625..ec2d489b1d35b5955142e9cadb039b8c8d8ff19e 100644 (file)
@@ -1,3 +1,17 @@
+2017-08-07  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
+
+        check-webkit-style: NS_ERROR_ENUM and NS_OPTIONS should not be handled as function definitions.
+        https://bugs.webkit.org/show_bug.cgi?id=175286
+
+        Reviewed by Myles C. Maxfield.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_braces):
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (WebKitStyleTest.test_braces.NS_ERROR_ENUM):
+        (WebKitStyleTest.test_braces):
+        (WebKitStyleTest.test_braces.NS_OPTIONS):
+
 2017-08-07  Brian Burg  <bburg@apple.com>
 
         Remove CANVAS_PATH compilation guard
index 970060e5fa7ab490a0244bbc41acef3ce8c773e9..06ee8ad478c483c12390a06d80ab66bc1840ffa0 100644 (file)
@@ -2431,7 +2431,7 @@ def check_braces(clean_lines, line_number, file_state, error):
         # and '- (' and '+ (' for Objective-C methods.
         previous_line = get_previous_non_blank_line(clean_lines, line_number)[0]
         if ((not search(r'[;:}{)=]\s*$|\)\s*((const|override|const override|final|const final)\s*)?(->\s*\S+)?\s*$', previous_line)
-             or search(r'\b(if|for|while|switch|else|NS_ENUM)\b', previous_line)
+             or search(r'\b(if|for|while|switch|else|NS_ENUM|NS_ERROR_ENUM|NS_OPTIONS)\b', previous_line)
              or regex_for_lambdas_and_blocks(previous_line, line_number, file_state, error))
             and previous_line.find('#') < 0
             and previous_line.find('- (') != 0
@@ -2440,7 +2440,7 @@ def check_braces(clean_lines, line_number, file_state, error):
                   'This { should be at the end of the previous line')
     elif (search(r'\)\s*(((const|override|final)\s*)*\s*)?{\s*$', line)
           and line.count('(') == line.count(')')
-          and not search(r'(\s*(if|for|while|switch|NS_ENUM|@synchronized)|} @catch)\b', line)
+          and not search(r'(\s*(if|for|while|switch|NS_ENUM|NS_ERROR_ENUM|NS_OPTIONS|@synchronized)|} @catch)\b', line)
           and not regex_for_lambdas_and_blocks(line, line_number, file_state, error)
           and line.find("](") < 0
           and not match(r'\s+[A-Z_][A-Z_0-9]+\b', line)):
index 8838561cae56cafdfc23e443434755c744eb3134..4367a738a9a485112945002666b260f4edab087d 100644 (file)
@@ -4503,6 +4503,30 @@ class WebKitStyleTest(CppStyleTestBase):
             '    0,\n'
             '    1\n'
             '};', '')
+        self.assert_multi_line_lint(
+            'typedef NS_ERROR_ENUM(NSInteger, type)\n'
+            '{\n'
+            '    0,\n'
+            '    1\n'
+            '};',
+            'This { should be at the end of the previous line  [whitespace/braces] [4]')
+        self.assert_multi_line_lint(
+            'typedef NS_ERROR_ENUM(NSInteger, type) {\n'
+            '    0,\n'
+            '    1\n'
+            '};', '')
+        self.assert_multi_line_lint(
+            'typedef NS_OPTIONS(NSInteger, type)\n'
+            '{\n'
+            '    0,\n'
+            '    1\n'
+            '};',
+            'This { should be at the end of the previous line  [whitespace/braces] [4]')
+        self.assert_multi_line_lint(
+            'typedef NS_OPTIONS(NSInteger, type) {\n'
+            '    0,\n'
+            '    1\n'
+            '};', '')
         self.assert_multi_line_lint(
             'enum class CPP11EnumClass\n'
             '{\n'