Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2075)

Unified Diff: Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

Issue 145033013: Update the static_cast style check to check for DEFINE_TYPE_CASTS patterns as well. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Corrected the message! Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py b/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
index 6df53dac3bcf6c6d87158bc9baf8dcefc37ee4c2..8caac83b6f6af7a94335a785c6c4fde85401658d 100644
--- a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
+++ b/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
@@ -300,6 +300,7 @@ class CppStyleTestBase(unittest.TestCase):
def perform_avoid_static_cast_of_objects(self, code, filename='foo.cpp', fs=None):
basic_error_rules = ('-',
+ '+security/casting',
'+runtime/casting')
return self.perform_lint(code, filename, basic_error_rules, fs)
@@ -758,6 +759,7 @@ class CppStyleTest(CppStyleTestBase):
self.assert_language_rules_check('foo.h', statement, error_message)
# Tests for static_cast readability.
+ # FIXME: Add cases for testing the DEFINE_TYPE_CASTS usecases also.
def test_static_cast_on_objects_with_toFoo(self):
mock_header_contents = ['inline Foo* toFoo(Bar* bar)']
fs = FileSystem()
@@ -773,7 +775,7 @@ class CppStyleTest(CppStyleTestBase):
filename='casting.cpp',
fs=fs)
self.assertEqual(message, 'static_cast of class objects is not allowed. Use toFoo defined in Foo.h.'
- ' [runtime/casting] [4]')
+ ' [security/casting] [4]')
finally:
fs.read_text_file = orig_read_text_file_fn
@@ -791,7 +793,7 @@ class CppStyleTest(CppStyleTestBase):
'Foo* x = static_cast<Foo*>(bar);',
filename='casting.cpp',
fs=fs)
- self.assertEqual(message, 'static_cast of class objects is not allowed. Add toFoo in Foo.h and use it instead.'
+ self.assertEqual(message, 'static_cast of class objects is not allowed. Define cast macro DEFINE_TYPE_CASTS(Foo) in Foo.h and use it.'
' [runtime/casting] [4]')
finally:
fs.read_text_file = orig_read_text_file_fn
« Tools/Scripts/webkitpy/style/checkers/cpp.py ('K') | « Tools/Scripts/webkitpy/style/checkers/cpp.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698