Changeset 152719 in webkit
- Timestamp:
- Jul 16, 2013 6:05:24 AM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r152718 r152719 1 2013-07-16 Brian Holt <brian.holt@samsung.com> 2 3 check-webkit-style: "using namespace foo;" should be flagged as an error in headers 4 https://bugs.webkit.org/show_bug.cgi?id=57241 5 6 Reviewed by Ryosuke Niwa. 7 8 Added check for "using namespace foo" and unit test. 9 10 * Scripts/webkitpy/style/checkers/cpp.py: 11 (check_using_namespace): 12 (check_style): 13 (CppChecker): 14 * Scripts/webkitpy/style/checkers/cpp_unittest.py: 15 (WebKitStyleTest.test_using_namespace): 16 1 17 2013-07-16 Anton Obzhirov <a.obzhirov@samsung.com> 2 18 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r150457 r152719 2162 2162 2163 2163 2164 def check_using_namespace(clean_lines, line_number, file_state, error): 2165 """Looks for 'using namespace foo;' which should be removed. 2166 2167 Args: 2168 clean_lines: A CleansedLines instance containing the file. 2169 line_number: The number of the line to check. 2170 file_state: A _FileState instance which maintains information about 2171 the state of things in the file. 2172 error: The function to call with any errors found. 2173 """ 2174 2175 # This check doesn't apply to C or Objective-C implementation files. 2176 if file_state.is_c_or_objective_c(): 2177 return 2178 2179 line = clean_lines.elided[line_number] # Get rid of comments and strings. 2180 2181 using_namespace_match = match(r'\s*using\s+namespace\s+(?P<method_name>\S+)\s*;\s*$', line) 2182 if not using_namespace_match: 2183 return 2184 2185 method_name = using_namespace_match.group('method_name') 2186 error(line_number, 'build/using_namespace', 4, 2187 "Do not use 'using namespace %s;'." % method_name) 2188 2164 2189 def check_max_min_macros(clean_lines, line_number, file_state, error): 2165 2190 """Looks use of MAX() and MIN() macros that should be replaced with std::max() and std::min(). … … 2646 2671 check_directive_indentation(clean_lines, line_number, file_state, error) 2647 2672 check_using_std(clean_lines, line_number, file_state, error) 2673 check_using_namespace(clean_lines, line_number, file_state, error) 2648 2674 check_max_min_macros(clean_lines, line_number, file_state, error) 2649 2675 check_ctype_functions(clean_lines, line_number, file_state, error) … … 3631 3657 'build/storage_class', 3632 3658 'build/using_std', 3659 'build/using_namespace', 3633 3660 'legal/copyright', 3634 3661 'readability/braces', -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r150457 r152719 4491 4491 'foo.cpp') 4492 4492 4493 def test_using_namespace(self): 4494 self.assert_lint( 4495 'using namespace foo;', 4496 "Do not use 'using namespace foo;'." 4497 " [build/using_namespace] [4]", 4498 'foo.cpp') 4499 4493 4500 def test_max_macro(self): 4494 4501 self.assert_lint(
Note: See TracChangeset
for help on using the changeset viewer.