Changeset 160319 in webkit
- Timestamp:
- Dec 9, 2013 11:01:09 AM (10 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r160318 r160319 1 2013-12-09 Brian J. Burg <burg@cs.washington.edu> 2 3 check-webkit-style should check for extra newlines at EOF 4 https://bugs.webkit.org/show_bug.cgi?id=125424 5 6 Reviewed by Darin Adler. 7 8 Report a style violation if extraneous newlines are added 9 to the end of a C++ file. There should only be one newline at EOF. 10 11 * Scripts/webkitpy/style/checkers/cpp.py: 12 (check_for_missing_new_line_at_eof): Renamed from check_for_new_line_at_eof. 13 (check_for_extra_new_line_at_eof): Added. 14 (_process_lines): Added new check and renamed existing EOF check. 15 * Scripts/webkitpy/style/checkers/cpp_unittest.py: 16 (CppStyleTest.test_extra_newlines_at_eof): Added. 17 (CppStyleTest.test_extra_newlines_at_eof.do_test): Added. 18 1 19 2013-12-09 Laszlo Vidacs <lac@inf.u-szeged.hu> 2 20 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r160318 r160319 958 958 959 959 960 def check_for_ new_line_at_eof(lines, error):961 """Logs an error if there is no newline char at the end of the file.960 def check_for_missing_new_line_at_eof(lines, error): 961 """Logs an error if there is not a newline character at the end of the file. 962 962 963 963 Args: … … 973 973 error(len(lines) - 2, 'whitespace/ending_newline', 5, 974 974 'Could not find a newline character at the end of the file.') 975 976 977 def check_for_extra_new_line_at_eof(lines, error): 978 """Logs an error if there is not a single newline at the end of the file. 979 980 Args: 981 lines: An array of strings, each representing a line of the file. 982 error: The function to call with any errors found. 983 """ 984 # The array lines() was created by adding two newlines to the 985 # original file (go figure), then splitting on \n. 986 if len(lines) > 3 and not lines[-3]: 987 error(len(lines) - 2, 'whitespace/ending_newline', 5, 988 'There was more than one newline at the end of the file.') 975 989 976 990 … … 3636 3650 check_for_unicode_replacement_characters(lines, error) 3637 3651 3638 check_for_new_line_at_eof(lines, error) 3652 check_for_missing_new_line_at_eof(lines, error) 3653 check_for_extra_new_line_at_eof(lines, error) 3639 3654 3640 3655 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r160318 r160319 1938 1938 do_test(self, '// No newline\n// at EOF', True) 1939 1939 1940 def test_extra_newlines_at_eof(self): 1941 def do_test(self, data, too_many_newlines): 1942 error_collector = ErrorCollector(self.assertTrue) 1943 self.process_file_data('foo.cpp', 'cpp', data.split('\n'), 1944 error_collector) 1945 # The warning appears only once. 1946 self.assertEqual( 1947 int(too_many_newlines), 1948 error_collector.results().count( 1949 'There was more than one newline at the end of the file.' 1950 ' [whitespace/ending_newline] [5]')) 1951 1952 do_test(self, '// No Newline\n// at EOF', False) 1953 do_test(self, '// One Newline\n// at EOF\n', False) 1954 do_test(self, '// Two Newlines\n// at EOF\n\n', True) 1955 do_test(self, '// Three Newlines\n// at EOF\n\n\n', True) 1956 1940 1957 def test_invalid_utf8(self): 1941 1958 def do_test(self, raw_bytes, has_invalid_utf8):
Note: See TracChangeset
for help on using the changeset viewer.