diff options
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/style')
6 files changed, 43 insertions, 3 deletions
diff --git a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py index 9e4240c..62f40ea 100644 --- a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py +++ b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py @@ -2451,6 +2451,9 @@ def check_identifier_name_in_declaration(filename, line_number, line, error): line = sub(r'(unsigned|signed) (?=char|short|int|long)', '', line) line = sub(r'\b(inline|using|static|const|volatile|auto|register|extern|typedef|restrict|struct|class|virtual)(?=\W)', '', line) + # Remove "new" and "new (expr)" to simplify, too. + line = sub(r'new\s*(\([^)]*\))?', '', line) + # Remove all template parameters by removing matching < and >. # Loop until no templates are removed to remove nested templates. while True: diff --git a/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py b/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py index c927db6..16b1a3c 100644 --- a/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py +++ b/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py @@ -3715,6 +3715,12 @@ class WebKitStyleTest(CppStyleTestBase): self.assert_lint('unsigned _fillRule : 1;', '_fillRule' + name_underscore_error_message) + # new operators in initialization. + self.assert_lint('OwnPtr<uint32_t> variable(new uint32_t);', '') + self.assert_lint('OwnPtr<uint32_t> variable(new (expr) uint32_t);', '') + self.assert_lint('OwnPtr<uint32_t> under_score(new uint32_t);', + 'under_score' + name_underscore_error_message) + def test_comments(self): # A comment at the beginning of a line is ok. diff --git a/WebKitTools/Scripts/webkitpy/style/filereader.py b/WebKitTools/Scripts/webkitpy/style/filereader.py index 48455b3..1a24cb5 100644 --- a/WebKitTools/Scripts/webkitpy/style/filereader.py +++ b/WebKitTools/Scripts/webkitpy/style/filereader.py @@ -47,6 +47,10 @@ class TextFileReader(object): file_count: The total number of files passed to this instance for processing, including non-text files and files that should be skipped. + delete_only_file_count: The total number of files that are not + processed this instance actually because + the files don't have any modified lines + but should be treated as processed. """ @@ -59,6 +63,7 @@ class TextFileReader(object): """ self._processor = processor self.file_count = 0 + self.delete_only_file_count = 0 def _read_lines(self, file_path): """Read the file at a path, and return its lines. @@ -146,3 +151,12 @@ class TextFileReader(object): self._process_directory(directory=path) else: self.process_file(path) + + def count_delete_only_file(self): + """Count up files that contains only deleted lines. + + Files which has no modified or newly-added lines don't need + to check style, but should be treated as checked. For that + purpose, we just count up the number of such files. + """ + self.delete_only_file_count += 1 diff --git a/WebKitTools/Scripts/webkitpy/style/filereader_unittest.py b/WebKitTools/Scripts/webkitpy/style/filereader_unittest.py index 558ec5a..6328337 100644 --- a/WebKitTools/Scripts/webkitpy/style/filereader_unittest.py +++ b/WebKitTools/Scripts/webkitpy/style/filereader_unittest.py @@ -159,3 +159,8 @@ class TextFileReaderTest(LoggingTestCase): processed = [(['bar'], file_path2, None), (['foo'], file_path1, None)] self._assert_file_reader(processed, 2) + + def test_count_delete_only_file(self): + self._file_reader.count_delete_only_file() + delete_only_file_count = self._file_reader.delete_only_file_count + self.assertEquals(delete_only_file_count, 1) diff --git a/WebKitTools/Scripts/webkitpy/style/patchreader.py b/WebKitTools/Scripts/webkitpy/style/patchreader.py index 7ba2b66..576504a 100644 --- a/WebKitTools/Scripts/webkitpy/style/patchreader.py +++ b/WebKitTools/Scripts/webkitpy/style/patchreader.py @@ -73,3 +73,8 @@ class PatchReader(object): if line_numbers: self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers) + else: + # We don't check the file which contains deleted lines only + # but would like to treat it as to be processed so that + # we count up number of such files. + self._text_file_reader.count_delete_only_file() diff --git a/WebKitTools/Scripts/webkitpy/style/patchreader_unittest.py b/WebKitTools/Scripts/webkitpy/style/patchreader_unittest.py index 10791e4..2453c6b 100644 --- a/WebKitTools/Scripts/webkitpy/style/patchreader_unittest.py +++ b/WebKitTools/Scripts/webkitpy/style/patchreader_unittest.py @@ -45,10 +45,15 @@ class PatchReaderTest(unittest.TestCase): def __init__(self): self.passed_to_process_file = [] """A list of (file_path, line_numbers) pairs.""" + self.delete_only_file_count = 0 + """A number of times count_delete_only_file() called""" def process_file(self, file_path, line_numbers): self.passed_to_process_file.append((file_path, line_numbers)) + def count_delete_only_file(self): + self.delete_only_file_count += 1 + def setUp(self): file_reader = self.MockTextFileReader() self._file_reader = file_reader @@ -57,9 +62,11 @@ class PatchReaderTest(unittest.TestCase): def _call_check_patch(self, patch_string): self._patch_checker.check(patch_string) - def _assert_checked(self, passed_to_process_file): + def _assert_checked(self, passed_to_process_file, delete_only_file_count): self.assertEquals(self._file_reader.passed_to_process_file, passed_to_process_file) + self.assertEquals(self._file_reader.delete_only_file_count, + delete_only_file_count) def test_check_patch(self): # The modified line_numbers array for this patch is: [2]. @@ -71,7 +78,7 @@ index ef65bee..e3db70e 100644 # Required for Python to search this directory for module files +# New line """) - self._assert_checked([("__init__.py", set([2]))]) + self._assert_checked([("__init__.py", set([2]))], 0) def test_check_patch_with_deletion(self): self._call_check_patch("""Index: __init__.py @@ -82,4 +89,4 @@ index ef65bee..e3db70e 100644 -foobar """) # _mock_check_file should not be called for the deletion patch. - self._assert_checked([]) + self._assert_checked([], 1) |