Changeset 173174 in webkit


Ignore:
Timestamp:
Sep 2, 2014 9:03:41 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

check-webkit-style should complain about C++ comments in Platform.h
https://bugs.webkit.org/show_bug.cgi?id=133802

Patch by Renato Nagy <rnagy@inf.u-szeged.hu> on 2014-09-02
Reviewed by Csaba Osztrogonác.

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

(check_platformh_comments):
(_process_lines):
(CppChecker):

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

(CppStyleTest.test_platformh_comment):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r173170 r173174  
     12014-09-02  Renato Nagy  <rnagy@inf.u-szeged.hu>
     2
     3        check-webkit-style should complain about C++ comments in Platform.h
     4        https://bugs.webkit.org/show_bug.cgi?id=133802
     5
     6        Reviewed by Csaba Osztrogonác.
     7
     8        * Scripts/webkitpy/style/checkers/cpp.py:
     9        (check_platformh_comments):
     10        (_process_lines):
     11        (CppChecker):
     12        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
     13        (CppStyleTest.test_platformh_comment):
     14
    1152014-09-02  Brendan Long  <self@brendanlong.com>
    216
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r171088 r173174  
    36843684
    36853685
     3686def check_platformh_comments(lines, error):
     3687    for line_number, line in enumerate(lines):
     3688        if line_number not in (0, len(lines) - 1):
     3689            if line.find("//") != -1:
     3690                error(line_number, 'build/cpp_comment', 5, 'CPP comments are not allowed in Platform.h, '
     3691                                                           'please use C comments /* ... */')
     3692
    36863693def process_line(filename, file_extension,
    36873694                 clean_lines, line, include_state, function_state,
     
    37663773    if file_extension == 'h':
    37673774        check_for_header_guard(filename, lines, error)
     3775        if filename == 'Source/WTF/wtf/Platform.h':
     3776            check_platformh_comments(lines, error)
    37683777
    37693778    remove_multi_line_comments(lines, error)
     
    38123821        'build/using_std',
    38133822        'build/using_namespace',
     3823        'build/cpp_comment',
    38143824        'legal/copyright',
    38153825        'readability/braces',
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r171088 r173174  
    11411141            2,  # One per line.
    11421142            error_collector.result_list().count(multiline_string_error_message))
     1143
     1144    def test_platformh_comments(self):
     1145        check_platformh_message = (
     1146            'CPP comments are not allowed in Platform.h, '
     1147            'please use C comments /* ... */  [build/cpp_comment] [5]')
     1148
     1149        platformh_file_path = 'Source/WTF/wtf/Platform.h'
     1150
     1151        # CPP comment are not allowed in Platform.h header file.
     1152        error_collector = ErrorCollector(self.assertTrue)
     1153        self.process_file_data(platformh_file_path, 'h',
     1154                               ['// This is a cpp comment.'],
     1155                               error_collector)
     1156        self.assertEqual(
     1157            1,
     1158            error_collector.result_list().count(check_platformh_message))
     1159
     1160        # C comments are allowed in Platform.h
     1161        error_collector = ErrorCollector(self.assertTrue)
     1162        self.process_file_data(platformh_file_path, 'h',
     1163                               ['/* This is a C comment.*/'],
     1164                               error_collector)
     1165        self.assertEqual(
     1166            0,
     1167            error_collector.result_list().count(check_platformh_message))
     1168
     1169        platformh_file_path = 'Source/WTF/wtf/platform.h'
     1170
     1171        # CPP comment are allowed in other header files.
     1172        error_collector = ErrorCollector(self.assertTrue)
     1173        self.process_file_data(platformh_file_path, 'h',
     1174                               ['// This is a cpp comment.'
     1175                                '// The filepath is not'
     1176                                '// Source/WTF/wtf/Platform.h'],
     1177                               error_collector)
     1178        self.assertEqual(
     1179            0,
     1180            error_collector.result_list().count(check_platformh_message))
    11431181
    11441182    # Test non-explicit single-argument constructors
Note: See TracChangeset for help on using the changeset viewer.