Changeset 51619 in webkit
- Timestamp:
- Dec 2, 2009 9:08:59 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r51618 r51619 1 2009-12-02 David Levin <levin@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 check-webkit-style is too noisy about namespace indenting issues. 6 https://bugs.webkit.org/show_bug.cgi?id=32096 7 8 * Scripts/modules/cpp_style.py: 9 Added a _FileState object to be able to track file level information. In this 10 case, it simply tracks whether the error has already been given, so that it isn't 11 done again. 12 * Scripts/modules/cpp_style_unittest.py: 13 Modified test cases to pass in the _FileState object and fix a test that expected 14 to see the namespace error twice (now it only occurs once). No new tests because 15 existing tests cover the change in functionality. 16 1 17 2009-12-01 Kevin Ollivier <kevino@theolliviers.com> 2 18 -
trunk/WebKitTools/Scripts/modules/cpp_style.py
r51570 r51619 1120 1120 1121 1121 1122 class _FileState(object): 1123 def __init__(self): 1124 self._did_inside_namespace_indent_warning = False 1125 1126 def set_did_inside_namespace_indent_warning(self): 1127 self._did_inside_namespace_indent_warning = True 1128 1129 def did_inside_namespace_indent_warning(self): 1130 return self._did_inside_namespace_indent_warning 1131 1122 1132 def check_for_non_standard_constructs(filename, clean_lines, line_number, 1123 1133 class_state, error): … … 1676 1686 1677 1687 1678 def check_namespace_indentation(filename, clean_lines, line_number, file_extension, error):1688 def check_namespace_indentation(filename, clean_lines, line_number, file_extension, file_state, error): 1679 1689 """Looks for indentation errors inside of namespaces. 1680 1690 … … 1684 1694 line_number: The number of the line to check. 1685 1695 file_extension: The extension (dot not included) of the file. 1696 file_state: A _FileState instance which maintains information about 1697 the state of things in the file. 1686 1698 error: The function to call with any errors found. 1687 1699 """ … … 1695 1707 current_indentation_level = len(namespace_match.group('namespace_indentation')) 1696 1708 if current_indentation_level > 0: 1697 error(filename, line_number, 'whitespace/indent', 4, 1698 'namespace should never be indented.') 1709 # Don't warn about an indented namespace if we already warned about indented code. 1710 if not file_state.did_inside_namespace_indent_warning(): 1711 error(filename, line_number, 'whitespace/indent', 4, 1712 'namespace should never be indented.') 1699 1713 return 1700 1714 looking_for_semicolon = False; … … 1707 1721 if not current_indentation_level: 1708 1722 if not (in_preprocessor_directive or looking_for_semicolon): 1709 if not match(r'\S', current_line): 1723 if not match(r'\S', current_line) and not file_state.did_inside_namespace_indent_warning(): 1724 file_state.set_did_inside_namespace_indent_warning() 1710 1725 error(filename, line_number + line_offset, 'whitespace/indent', 4, 1711 1726 'Code inside a namespace should not be indented.') … … 2125 2140 2126 2141 2127 def check_style(filename, clean_lines, line_number, file_extension, error):2142 def check_style(filename, clean_lines, line_number, file_extension, file_state, error): 2128 2143 """Checks rules from the 'C++ style rules' section of cppguide.html. 2129 2144 … … 2137 2152 line_number: The number of the line to check. 2138 2153 file_extension: The extension (without the dot) of the filename. 2154 file_state: A _FileState instance which maintains information about 2155 the state of things in the file. 2139 2156 error: The function to call with any errors found. 2140 2157 """ … … 2204 2221 2205 2222 # Some more style checks 2206 check_namespace_indentation(filename, clean_lines, line_number, file_extension, error)2223 check_namespace_indentation(filename, clean_lines, line_number, file_extension, file_state, error) 2207 2224 check_using_std(filename, clean_lines, line_number, error) 2208 2225 check_max_min_macros(filename, clean_lines, line_number, error) … … 2915 2932 def process_line(filename, file_extension, 2916 2933 clean_lines, line, include_state, function_state, 2917 class_state, error):2934 class_state, file_state, error): 2918 2935 """Processes a single line in the file. 2919 2936 … … 2928 2945 class_state: A _ClassState instance which maintains information about 2929 2946 the current stack of nested class declarations being parsed. 2947 file_state: A _FileState instance which maintains information about 2948 the state of things in the file. 2930 2949 error: A callable to which errors are reported, which takes 4 arguments: 2931 2950 filename, line number, error level, and message … … 2937 2956 return 2938 2957 check_for_multiline_comments_and_strings(filename, clean_lines, line, error) 2939 check_style(filename, clean_lines, line, file_extension, error)2958 check_style(filename, clean_lines, line, file_extension, file_state, error) 2940 2959 check_language(filename, clean_lines, line, file_extension, include_state, 2941 2960 error) … … 2962 2981 function_state = _FunctionState() 2963 2982 class_state = _ClassState() 2983 file_state = _FileState() 2964 2984 2965 2985 check_for_copyright(filename, lines, error) … … 2972 2992 for line in xrange(clean_lines.num_lines()): 2973 2993 process_line(filename, file_extension, clean_lines, line, 2974 include_state, function_state, class_state, error)2994 include_state, function_state, class_state, file_state, error) 2975 2995 class_state.check_finished(filename, error) 2976 2996 -
trunk/WebKitTools/Scripts/modules/cpp_style_unittest.py
r51570 r51619 121 121 ext = file_name[file_name.rfind('.') + 1:] 122 122 class_state = cpp_style._ClassState() 123 file_state = cpp_style._FileState() 123 124 cpp_style.process_line(file_name, ext, clean_lines, 0, 124 125 include_state, function_state, 125 class_state, error_collector)126 class_state, file_state, error_collector) 126 127 # Single-line lint tests are allowed to fail the 'unlintable function' 127 128 # check. … … 138 139 ext = file_name[file_name.rfind('.') + 1:] 139 140 class_state = cpp_style._ClassState() 141 file_state = cpp_style._FileState() 140 142 for i in xrange(lines.num_lines()): 141 cpp_style.check_style(file_name, lines, i, ext, error_collector)143 cpp_style.check_style(file_name, lines, i, ext, file_state, error_collector) 142 144 cpp_style.check_for_non_standard_constructs(file_name, lines, i, class_state, 143 145 error_collector) … … 2835 2837 '};\n' 2836 2838 '}', 2837 ['Code inside a namespace should not be indented. [whitespace/indent] [4]', 'namespace should never be indented. [whitespace/indent] [4]'], 2839 'Code inside a namespace should not be indented. [whitespace/indent] [4]', 2840 'foo.h') 2841 self.assert_multi_line_lint( 2842 'namespace OuterNamespace {\n' 2843 ' class Document {\n' 2844 ' namespace InnerNamespace {\n' 2845 '};\n' 2846 '};\n' 2847 '}', 2848 'Code inside a namespace should not be indented. [whitespace/indent] [4]', 2838 2849 'foo.h') 2839 2850 self.assert_multi_line_lint(
Note: See TracChangeset
for help on using the changeset viewer.