Commit 94a56c45 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Make "using namespace" a PRESUBMIT error.

Bug: 82078
Change-Id: Ibc9405d903008c5bebf04f558e1b2c42ba5ced4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879997Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709655}
parent f92c3377
......@@ -500,6 +500,16 @@ _BANNED_CPP_FUNCTIONS = (
False,
(),
),
(
r'/\busing namespace ',
(
'Using directives ("using namespace x") are banned by the Google Style',
'Guide ( http://google.github.io/styleguide/cppguide.html#Namespaces ).',
'Explicitly qualify symbols or use using declarations ("using x::foo").',
),
True,
[_THIRD_PARTY_EXCEPT_BLINK], # Don't warn in third_party folders.
),
# Make sure that gtest's FRIEND_TEST() macro is not used; the
# FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
# used instead since that allows for FLAKY_ and DISABLED_ prefixes.
......
......@@ -1918,6 +1918,20 @@ class ServiceManifestOwnerTest(unittest.TestCase):
class BannedTypeCheckTest(unittest.TestCase):
def testBannedCppFunctions(self):
input_api = MockInputApi()
input_api.files = [
MockFile('some/cpp/problematic/file.cc',
['using namespace std;']),
MockFile('some/cpp/ok/file.cc',
['using std::string;']),
]
errors = PRESUBMIT._CheckNoBannedFunctions(input_api, MockOutputApi())
self.assertEqual(1, len(errors))
self.assertTrue('some/cpp/problematic/file.c' in errors[0].message)
self.assertTrue('some/cpp/ok/file.cc' not in errors[0].message)
def testBannedIosObjcFunctions(self):
input_api = MockInputApi()
input_api.files = [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment