diff --git a/src/api/hooks.cc b/src/api/hooks.cc index 037bdda6f41c82..2eb4c146a7d723 100644 --- a/src/api/hooks.cc +++ b/src/api/hooks.cc @@ -10,10 +10,10 @@ using v8::HandleScope; using v8::Integer; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Object; using v8::String; using v8::Value; -using v8::NewStringType; void RunAtExit(Environment* env) { env->RunAtExitCallbacks(); diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index a15cd52d239e40..0cf75a37146729 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -14,8 +14,8 @@ namespace node { namespace inspector { namespace { -using v8_inspector::StringView; using v8_inspector::StringBuffer; +using v8_inspector::StringView; template class DeletableWrapper : public Deletable { diff --git a/src/node_report.cc b/src/node_report.cc index c93e03afe63918..e7bfe7fef09d14 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -43,13 +43,11 @@ using v8::HeapSpaceStatistics; using v8::HeapStatistics; using v8::Isolate; using v8::Local; -using v8::Number; using v8::Object; -using v8::StackTrace; using v8::String; using v8::TryCatch; -using v8::Value; using v8::V8; +using v8::Value; namespace per_process = node::per_process; diff --git a/src/quic/node_quic_session.cc b/src/quic/node_quic_session.cc index 041c601a3c3268..8857a56a60d219 100644 --- a/src/quic/node_quic_session.cc +++ b/src/quic/node_quic_session.cc @@ -43,7 +43,6 @@ using crypto::SecureContext; using v8::Array; using v8::ArrayBufferView; using v8::Context; -using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::HandleScope; diff --git a/src/quic/node_quic_socket.cc b/src/quic/node_quic_socket.cc index ae0847d8d27bd9..8005b5d8099e5f 100644 --- a/src/quic/node_quic_socket.cc +++ b/src/quic/node_quic_socket.cc @@ -29,7 +29,6 @@ using crypto::EntropySource; using crypto::SecureContext; using v8::ArrayBufferView; -using v8::Boolean; using v8::Context; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; diff --git a/src/quic/node_quic_socket.h b/src/quic/node_quic_socket.h index f108eb47901b81..5b071c41b898df 100644 --- a/src/quic/node_quic_socket.h +++ b/src/quic/node_quic_socket.h @@ -27,10 +27,8 @@ namespace node { using v8::Context; -using v8::FunctionCallbackInfo; using v8::Local; using v8::Object; -using v8::Value; namespace quic { diff --git a/test/addons/async-hooks-promise/binding.cc b/test/addons/async-hooks-promise/binding.cc index 452cbda8793aa1..8fe6b9471bcee5 100644 --- a/test/addons/async-hooks-promise/binding.cc +++ b/test/addons/async-hooks-promise/binding.cc @@ -6,7 +6,6 @@ namespace { using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; -using v8::NewStringType; using v8::Object; using v8::Promise; using v8::String; diff --git a/test/addons/dlopen-ping-pong/binding.cc b/test/addons/dlopen-ping-pong/binding.cc index c8711f09aedac6..be33708c9317d3 100644 --- a/test/addons/dlopen-ping-pong/binding.cc +++ b/test/addons/dlopen-ping-pong/binding.cc @@ -17,7 +17,6 @@ using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; using v8::Object; -using v8::NewStringType; using v8::String; using v8::Value; diff --git a/test/addons/non-node-context/binding.cc b/test/addons/non-node-context/binding.cc index 6fe776b7c60c3d..8423d2b1d7a5a5 100644 --- a/test/addons/non-node-context/binding.cc +++ b/test/addons/non-node-context/binding.cc @@ -5,12 +5,9 @@ namespace { using v8::Context; -using v8::Function; -using v8::FunctionTemplate; using v8::Isolate; using v8::Local; using v8::MaybeLocal; -using v8::NewStringType; using v8::Object; using v8::Script; using v8::String; diff --git a/test/addons/repl-domain-abort/binding.cc b/test/addons/repl-domain-abort/binding.cc index 3e716443540229..f5e82d3718ccac 100644 --- a/test/addons/repl-domain-abort/binding.cc +++ b/test/addons/repl-domain-abort/binding.cc @@ -25,8 +25,8 @@ using v8::Boolean; using v8::Function; using v8::FunctionCallbackInfo; -using v8::Local; using v8::Isolate; +using v8::Local; using v8::Object; using v8::Value; diff --git a/test/addons/uv-handle-leak/binding.cc b/test/addons/uv-handle-leak/binding.cc index 1b769b141c0076..20ddfac6802e97 100644 --- a/test/addons/uv-handle-leak/binding.cc +++ b/test/addons/uv-handle-leak/binding.cc @@ -6,7 +6,6 @@ using v8::Context; using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; -using v8::Object; using v8::Value; // Give these things names in the public namespace so that we can see diff --git a/test/cctest/test_base64.cc b/test/cctest/test_base64.cc index 5e39a1052bc057..be61618f9086ed 100644 --- a/test/cctest/test_base64.cc +++ b/test/cctest/test_base64.cc @@ -5,8 +5,8 @@ #include "gtest/gtest.h" -using node::base64_encode; using node::base64_decode; +using node::base64_encode; TEST(Base64Test, Encode) { auto test = [](const char* string, const char* base64_string) { diff --git a/test/cctest/test_util.cc b/test/cctest/test_util.cc index 6cfd5d317f7982..85c5a6a7fe43ae 100644 --- a/test/cctest/test_util.cc +++ b/test/cctest/test_util.cc @@ -3,6 +3,16 @@ #include "env-inl.h" #include "gtest/gtest.h" +using node::Calloc; +using node::Malloc; +using node::MaybeStackBuffer; +using node::SPrintF; +using node::StringEqualNoCase; +using node::StringEqualNoCaseN; +using node::ToLower; +using node::UncheckedCalloc; +using node::UncheckedMalloc; + TEST(UtilTest, ListHead) { struct Item { node::ListNode node_; }; typedef node::ListHead List; @@ -58,7 +68,6 @@ TEST(UtilTest, ListHead) { } TEST(UtilTest, StringEqualNoCase) { - using node::StringEqualNoCase; EXPECT_FALSE(StringEqualNoCase("a", "b")); EXPECT_TRUE(StringEqualNoCase("", "")); EXPECT_TRUE(StringEqualNoCase("equal", "equal")); @@ -69,7 +78,6 @@ TEST(UtilTest, StringEqualNoCase) { } TEST(UtilTest, StringEqualNoCaseN) { - using node::StringEqualNoCaseN; EXPECT_FALSE(StringEqualNoCaseN("a", "b", strlen("a"))); EXPECT_TRUE(StringEqualNoCaseN("", "", strlen(""))); EXPECT_TRUE(StringEqualNoCaseN("equal", "equal", strlen("equal"))); @@ -84,7 +92,6 @@ TEST(UtilTest, StringEqualNoCaseN) { } TEST(UtilTest, ToLower) { - using node::ToLower; EXPECT_EQ('0', ToLower('0')); EXPECT_EQ('a', ToLower('a')); EXPECT_EQ('a', ToLower('A')); @@ -98,7 +105,6 @@ TEST(UtilTest, ToLower) { } while (0) TEST(UtilTest, Malloc) { - using node::Malloc; TEST_AND_FREE(Malloc(0)); TEST_AND_FREE(Malloc(1)); TEST_AND_FREE(Malloc(0)); @@ -106,7 +112,6 @@ TEST(UtilTest, Malloc) { } TEST(UtilTest, Calloc) { - using node::Calloc; TEST_AND_FREE(Calloc(0)); TEST_AND_FREE(Calloc(1)); TEST_AND_FREE(Calloc(0)); @@ -114,7 +119,6 @@ TEST(UtilTest, Calloc) { } TEST(UtilTest, UncheckedMalloc) { - using node::UncheckedMalloc; TEST_AND_FREE(UncheckedMalloc(0)); TEST_AND_FREE(UncheckedMalloc(1)); TEST_AND_FREE(UncheckedMalloc(0)); @@ -122,7 +126,6 @@ TEST(UtilTest, UncheckedMalloc) { } TEST(UtilTest, UncheckedCalloc) { - using node::UncheckedCalloc; TEST_AND_FREE(UncheckedCalloc(0)); TEST_AND_FREE(UncheckedCalloc(1)); TEST_AND_FREE(UncheckedCalloc(0)); @@ -131,8 +134,6 @@ TEST(UtilTest, UncheckedCalloc) { template static void MaybeStackBufferBasic() { - using node::MaybeStackBuffer; - MaybeStackBuffer buf; size_t old_length; size_t old_capacity; @@ -211,8 +212,6 @@ static void MaybeStackBufferBasic() { } TEST(UtilTest, MaybeStackBuffer) { - using node::MaybeStackBuffer; - MaybeStackBufferBasic(); MaybeStackBufferBasic(); @@ -254,8 +253,6 @@ TEST(UtilTest, MaybeStackBuffer) { } TEST(UtilTest, SPrintF) { - using node::SPrintF; - // %d, %u and %s all do the same thing. The actual C++ type is used to infer // the right representation. EXPECT_EQ(SPrintF("%s", false), "false"); diff --git a/test/embedding/embedtest.cc b/test/embedding/embedtest.cc index a927167ea6a921..21e5ac713ed017 100644 --- a/test/embedding/embedtest.cc +++ b/test/embedding/embedtest.cc @@ -16,8 +16,8 @@ using v8::Local; using v8::Locker; using v8::MaybeLocal; using v8::SealHandleScope; -using v8::Value; using v8::V8; +using v8::Value; static int RunNodeInstance(MultiIsolatePlatform* platform, const std::vector& args, diff --git a/tools/checkimports.py b/tools/checkimports.py index 609a75f542748f..b94919e3cc47e4 100755 --- a/tools/checkimports.py +++ b/tools/checkimports.py @@ -5,7 +5,7 @@ import io import re import sys - +import itertools def do_exist(file_name, lines, imported): if not any(not re.match('using \w+::{0};'.format(imported), line) and @@ -41,5 +41,10 @@ def is_valid(file_name): return valid if __name__ == '__main__': - files = glob.iglob(sys.argv[1] if len(sys.argv) > 1 else 'src/*.cc') - sys.exit(0 if all(map(is_valid, files)) else 1) + if len(sys.argv) > 1: + files = [] + for pattern in sys.argv[1:]: + files = itertools.chain(files, glob.iglob(pattern)) + else: + files = glob.iglob('src/*.cc') + sys.exit(0 if all(list(map(is_valid, files))) else 1)