diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp index 8e2fb90e0b0..7e0d9831e12 100644 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp +++ b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp @@ -14,9 +14,10 @@ #include +#include + namespace facebook::hermes::inspector_modern::chrome { -using ::facebook::react::jsinspector_modern::IInspector; using ::facebook::react::jsinspector_modern::ILocalConnection; using ::facebook::react::jsinspector_modern::IRemoteConnection; @@ -27,7 +28,7 @@ class LocalConnection : public ILocalConnection { LocalConnection( std::shared_ptr conn, std::shared_ptr> inspectedContexts); - ~LocalConnection(); + ~LocalConnection() override; void sendMessage(std::string message) override; void disconnect() override; @@ -40,14 +41,14 @@ class LocalConnection : public ILocalConnection { LocalConnection::LocalConnection( std::shared_ptr conn, std::shared_ptr> inspectedContexts) - : conn_(conn), inspectedContexts_(inspectedContexts) { + : conn_(conn), inspectedContexts_(std::move(inspectedContexts)) { inspectedContexts_->insert(conn->getTitle()); } LocalConnection::~LocalConnection() = default; -void LocalConnection::sendMessage(std::string str) { - conn_->handle(std::move(str)); +void LocalConnection::sendMessage(std::string message) { + conn_->handle(std::move(message)); } void LocalConnection::disconnect() { @@ -76,9 +77,9 @@ DebugSessionToken ConnectionDemux::enableDebugging( // register the new CS VM instance, check for any previous CS VM (via strcmp // of title) and remove them. std::vector pagesToDelete; - for (auto it = conns_.begin(); it != conns_.end(); ++it) { - if (it->second->getTitle() == title) { - pagesToDelete.push_back(it->first); + for (auto& conn : conns_) { + if (conn.second->getTitle() == title) { + pagesToDelete.push_back(conn.first); } } diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/HermesRuntimeAgentDelegate.cpp b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/HermesRuntimeAgentDelegate.cpp index 66a91c91c64..81930abb051 100644 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/HermesRuntimeAgentDelegate.cpp +++ b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/HermesRuntimeAgentDelegate.cpp @@ -14,6 +14,8 @@ #include #include +#include + using namespace facebook::hermes; namespace facebook::react::jsinspector_modern { @@ -25,7 +27,7 @@ class HermesRuntimeAgentDelegate::Impl final : public RuntimeAgentDelegate { explicit HermesStateWrapper(HermesState state) : state_(std::move(state)) {} static HermesState unwrapDestructively(ExportedState* wrapper) { - if (!wrapper) { + if (wrapper == nullptr) { return {}; } if (auto* typedWrapper = dynamic_cast(wrapper)) { @@ -58,7 +60,7 @@ class HermesRuntimeAgentDelegate::Impl final : public RuntimeAgentDelegate { runtimeExecutor( [&runtime, fn = std::move(fn)](auto&) { fn(runtime); }); }, - frontendChannel, + std::move(frontendChannel), HermesStateWrapper::unwrapDestructively( previouslyExportedState.get()))) { if (sessionState.isRuntimeDomainEnabled) { diff --git a/packages/react-native/ReactCommon/jsinspector-modern/FallbackRuntimeAgentDelegate.cpp b/packages/react-native/ReactCommon/jsinspector-modern/FallbackRuntimeAgentDelegate.cpp index e46712f72be..8e65edc9cf3 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/FallbackRuntimeAgentDelegate.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/FallbackRuntimeAgentDelegate.cpp @@ -9,6 +9,7 @@ #include #include +#include using namespace std::chrono; using namespace std::literals::string_view_literals; @@ -26,7 +27,8 @@ FallbackRuntimeAgentDelegate::FallbackRuntimeAgentDelegate( FrontendChannel frontendChannel, const SessionState& sessionState, std::string engineDescription) - : frontendChannel_(frontendChannel), engineDescription_(engineDescription) { + : frontendChannel_(std::move(frontendChannel)), + engineDescription_(std::move(engineDescription)) { if (sessionState.isLogDomainEnabled) { sendFallbackRuntimeWarning(); } diff --git a/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp b/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp index 29b2a7608a4..ee6d29ed6ba 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp @@ -19,6 +19,7 @@ #include #include +#include namespace facebook::react::jsinspector_modern { @@ -180,7 +181,7 @@ HostTarget::~HostTarget() { "HostTargetSession objects must be destroyed before their HostTarget. Did you call getInspectorInstance().removePage()?"); } -HostTargetDelegate::~HostTargetDelegate() {} +HostTargetDelegate::~HostTargetDelegate() = default; InstanceTarget& HostTarget::registerInstance(InstanceTargetDelegate& delegate) { assert(!currentInstance_ && "Only one instance allowed"); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/InspectorInterfaces.cpp b/packages/react-native/ReactCommon/jsinspector-modern/InspectorInterfaces.cpp index a2da293e112..d660504a84d 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/InspectorInterfaces.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/InspectorInterfaces.cpp @@ -10,17 +10,18 @@ #include #include #include +#include namespace facebook::react::jsinspector_modern { // pure destructors in C++ are odd. You would think they don't want an // implementation, but in fact the linker requires one. Define them to be // empty so that people don't count on them for any particular behaviour. -IDestructible::~IDestructible() {} -ILocalConnection::~ILocalConnection() {} -IRemoteConnection::~IRemoteConnection() {} -IInspector::~IInspector() {} -IPageStatusListener::~IPageStatusListener() {} +IDestructible::~IDestructible() = default; +ILocalConnection::~ILocalConnection() = default; +IRemoteConnection::~IRemoteConnection() = default; +IInspector::~IInspector() = default; +IPageStatusListener::~IPageStatusListener() = default; folly::dynamic targetCapabilitiesToDynamic( const InspectorTargetCapabilities& capabilities) { @@ -54,8 +55,8 @@ class InspectorImpl : public IInspector { public: Page( int id, - const std::string& description, - const std::string& vm, + std::string description, + std::string vm, ConnectFunc connectFunc, InspectorTargetCapabilities capabilities); operator InspectorPageDescription() const; @@ -77,13 +78,13 @@ class InspectorImpl : public IInspector { InspectorImpl::Page::Page( int id, - const std::string& description, - const std::string& vm, + std::string description, + std::string vm, ConnectFunc connectFunc, InspectorTargetCapabilities capabilities) : id_(id), - description_(description), - vm_(vm), + description_(std::move(description)), + vm_(std::move(vm)), connectFunc_(std::move(connectFunc)), capabilities_(capabilities) {} @@ -122,7 +123,7 @@ void InspectorImpl::removePage(int pageId) { std::scoped_lock lock(mutex_); if (pages_.erase(pageId) != 0) { - for (auto& listenerWeak : listeners_) { + for (const auto& listenerWeak : listeners_) { if (auto listener = listenerWeak.lock()) { listener->onPageRemoved(pageId); } diff --git a/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnection.cpp b/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnection.cpp index 4063b6b537f..86f57231d6f 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnection.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnection.cpp @@ -14,6 +14,7 @@ #include #include #include +#include using namespace std::literals; @@ -34,7 +35,10 @@ InspectorPackagerConnection::Impl::create( // No make_shared because the constructor is private std::shared_ptr impl( new InspectorPackagerConnection::Impl( - url, deviceName, appName, std::move(delegate))); + std::move(url), + std::move(deviceName), + std::move(appName), + std::move(delegate))); getInspectorInstance().registerPageStatusListener(impl); return impl; } @@ -50,7 +54,7 @@ InspectorPackagerConnection::Impl::Impl( delegate_(std::move(delegate)) {} void InspectorPackagerConnection::Impl::handleProxyMessage( - folly::const_dynamic_view message) { + const folly::const_dynamic_view& message) { std::string event = message.descend("event").string_or(INVALID); if (event == "getPages") { sendToPackager( @@ -67,7 +71,7 @@ void InspectorPackagerConnection::Impl::handleProxyMessage( } void InspectorPackagerConnection::Impl::sendEventToAllConnections( - std::string event) { + const std::string& event) { for (auto& connection : inspectorSessions_) { connection.second.localConnection->sendMessage(event); } @@ -81,7 +85,7 @@ void InspectorPackagerConnection::Impl::closeAllConnections() { } void InspectorPackagerConnection::Impl::handleConnect( - folly::const_dynamic_view payload) { + const folly::const_dynamic_view& payload) { std::string pageId = payload.descend("pageId").string_or(INVALID); auto existingConnectionIt = inspectorSessions_.find(pageId); if (existingConnectionIt != inspectorSessions_.end()) { @@ -91,7 +95,7 @@ void InspectorPackagerConnection::Impl::handleConnect( LOG(WARNING) << "Already connected: " << pageId; return; } - int pageIdInt; + int pageIdInt = 0; try { pageIdInt = std::stoi(pageId); } catch (...) { @@ -123,7 +127,7 @@ void InspectorPackagerConnection::Impl::handleConnect( } void InspectorPackagerConnection::Impl::handleDisconnect( - folly::const_dynamic_view payload) { + const folly::const_dynamic_view& payload) { std::string pageId = payload.descend("pageId").string_or(INVALID); auto inspectorConnection = removeConnectionForPage(pageId); if (inspectorConnection) { @@ -132,7 +136,8 @@ void InspectorPackagerConnection::Impl::handleDisconnect( } std::unique_ptr -InspectorPackagerConnection::Impl::removeConnectionForPage(std::string pageId) { +InspectorPackagerConnection::Impl::removeConnectionForPage( + const std::string& pageId) { auto it = inspectorSessions_.find(pageId); if (it != inspectorSessions_.end()) { auto connection = std::move(it->second); @@ -143,7 +148,7 @@ InspectorPackagerConnection::Impl::removeConnectionForPage(std::string pageId) { } void InspectorPackagerConnection::Impl::handleWrappedEvent( - folly::const_dynamic_view payload) { + const folly::const_dynamic_view& payload) { std::string pageId = payload.descend("pageId").string_or(INVALID); std::string wrappedEvent = payload.descend("wrappedEvent").string_or(INVALID); auto connectionIt = inspectorSessions_.find(pageId); @@ -195,7 +200,7 @@ void InspectorPackagerConnection::Impl::didReceiveMessage( << e.what(); return; } - handleProxyMessage(std::move(parsedJSON)); + handleProxyMessage(parsedJSON); } void InspectorPackagerConnection::Impl::didOpen() { @@ -277,7 +282,8 @@ void InspectorPackagerConnection::Impl::closeQuietly() { disposeWebSocket(); } -void InspectorPackagerConnection::Impl::sendToPackager(folly::dynamic message) { +void InspectorPackagerConnection::Impl::sendToPackager( + const folly::dynamic& message) { if (!webSocket_) { return; } @@ -288,7 +294,7 @@ void InspectorPackagerConnection::Impl::sendToPackager(folly::dynamic message) { void InspectorPackagerConnection::Impl::scheduleSendToPackager( folly::dynamic message, SessionId sourceSessionId, - std::string sourcePageId) { + const std::string& sourcePageId) { delegate_->scheduleCallback( [weakSelf = weak_from_this(), message = std::move(message), @@ -331,7 +337,7 @@ InspectorPackagerConnection::Impl::RemoteConnection::RemoteConnection( std::weak_ptr owningPackagerConnection, std::string pageId, SessionId sessionId) - : owningPackagerConnection_(owningPackagerConnection), + : owningPackagerConnection_(std::move(owningPackagerConnection)), pageId_(std::move(pageId)), sessionId_(sessionId) {} @@ -367,7 +373,11 @@ InspectorPackagerConnection::InspectorPackagerConnection( std::string deviceName, std::string appName, std::unique_ptr delegate) - : impl_(Impl::create(url, deviceName, appName, std::move(delegate))) {} + : impl_(Impl::create( + std::move(url), + std::move(deviceName), + std::move(appName), + std::move(delegate))) {} bool InspectorPackagerConnection::isConnected() const { return impl_->isConnected(); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnectionImpl.h b/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnectionImpl.h index ee17c5524c1..025727b292f 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnectionImpl.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnectionImpl.h @@ -39,8 +39,9 @@ class InspectorPackagerConnection::Impl bool isConnected() const; void connect(); void closeQuietly(); - void sendEventToAllConnections(std::string event); - std::unique_ptr removeConnectionForPage(std::string pageId); + void sendEventToAllConnections(const std::string& event); + std::unique_ptr removeConnectionForPage( + const std::string& pageId); /** * Send a message to the packager as soon as possible. This method is safe @@ -51,7 +52,7 @@ class InspectorPackagerConnection::Impl void scheduleSendToPackager( folly::dynamic message, SessionId sourceSessionId, - std::string sourcePageId); + const std::string& sourcePageId); private: struct Session { @@ -68,15 +69,15 @@ class InspectorPackagerConnection::Impl Impl(const Impl&) = delete; Impl& operator=(const Impl&) = delete; - void handleDisconnect(folly::const_dynamic_view payload); - void handleConnect(folly::const_dynamic_view payload); - void handleWrappedEvent(folly::const_dynamic_view wrappedEvent); - void handleProxyMessage(folly::const_dynamic_view message); + void handleDisconnect(const folly::const_dynamic_view& payload); + void handleConnect(const folly::const_dynamic_view& payload); + void handleWrappedEvent(const folly::const_dynamic_view& payload); + void handleProxyMessage(const folly::const_dynamic_view& message); folly::dynamic pages(); void reconnect(); void closeAllConnections(); void disposeWebSocket(); - void sendToPackager(folly::dynamic message); + void sendToPackager(const folly::dynamic& message); void abort( std::optional posixCode, diff --git a/packages/react-native/ReactCommon/jsinspector-modern/InstanceAgent.cpp b/packages/react-native/ReactCommon/jsinspector-modern/InstanceAgent.cpp index 493980ea874..7aba1679add 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/InstanceAgent.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/InstanceAgent.cpp @@ -10,6 +10,8 @@ #include +#include + namespace facebook::react::jsinspector_modern { InstanceAgent::InstanceAgent( diff --git a/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.cpp b/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.cpp index 53d898d4681..29b9563ef75 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.cpp @@ -10,6 +10,8 @@ #include +#include + namespace facebook::react::jsinspector_modern { std::shared_ptr InstanceTarget::create( @@ -30,10 +32,10 @@ InstanceTarget::InstanceTarget( (void)delegate_; } -InstanceTargetDelegate::~InstanceTargetDelegate() {} +InstanceTargetDelegate::~InstanceTargetDelegate() = default; std::shared_ptr InstanceTarget::createAgent( - FrontendChannel channel, + const FrontendChannel& channel, SessionState& sessionState) { auto instanceAgent = std::make_shared(channel, *this, sessionState); @@ -61,7 +63,7 @@ RuntimeTarget& InstanceTarget::registerRuntime( .name = "main", .uniqueId = std::nullopt}, delegate, - jsExecutor, + std::move(jsExecutor), makeVoidExecutor(executorFromThis())); agents_.forEach([currentRuntime = &*currentRuntime_](InstanceAgent& agent) { diff --git a/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.h b/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.h index c1cdeb96f67..60385229a8f 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/InstanceTarget.h @@ -65,7 +65,7 @@ class InstanceTarget : public EnableExecutorFromThis { ~InstanceTarget(); std::shared_ptr createAgent( - FrontendChannel channel, + const FrontendChannel& channel, SessionState& sessionState); /** diff --git a/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp b/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp index 6624e5aa649..1449de08d07 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp @@ -59,7 +59,7 @@ class Stream : public NetworkRequestListener, Stream(const Stream& other) = delete; Stream& operator=(const Stream& other) = delete; Stream(Stream&& other) = default; - Stream& operator=(Stream&& other) = default; + Stream& operator=(Stream&& other) noexcept = default; /** * Factory method to create a Stream with a callback for the initial result @@ -72,9 +72,9 @@ class Stream : public NetworkRequestListener, */ static std::shared_ptr create( VoidExecutor executor, - StreamInitCallback initCb) { + const StreamInitCallback& initCb) { std::shared_ptr stream{new Stream(initCb)}; - stream->setExecutor(executor); + stream->setExecutor(std::move(executor)); return stream; } @@ -87,8 +87,7 @@ class Stream : public NetworkRequestListener, * with the result of the read, or an error string. */ void read(long maxBytesToRead, const IOReadCallback& callback) { - pendingReadRequests_.emplace_back( - std::make_tuple(maxBytesToRead, callback)); + pendingReadRequests_.emplace_back(maxBytesToRead, callback); processPending(); } diff --git a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.cpp b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.cpp index c683a503807..982b53ff109 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.cpp @@ -8,19 +8,21 @@ #include "RuntimeAgent.h" #include "SessionState.h" +#include + namespace facebook::react::jsinspector_modern { RuntimeAgent::RuntimeAgent( FrontendChannel frontendChannel, RuntimeTargetController& targetController, - const ExecutionContextDescription& executionContextDescription, + ExecutionContextDescription executionContextDescription, SessionState& sessionState, std::unique_ptr delegate) : frontendChannel_(std::move(frontendChannel)), targetController_(targetController), sessionState_(sessionState), delegate_(std::move(delegate)), - executionContextDescription_(executionContextDescription) { + executionContextDescription_(std::move(executionContextDescription)) { for (auto& [name, contextSelectors] : sessionState_.subscribedBindings) { if (matchesAny(executionContextDescription_, contextSelectors)) { targetController_.installBindingHandler(name); @@ -43,7 +45,7 @@ bool RuntimeAgent::handleRequest(const cdp::PreparsedRequest& req) { // Right now, there's only ever one context (Runtime) in a Host, so we can // handle it here for simplicity, and use session state to propagate // bindings to the next RuntimeAgent. - if (req.params.count("executionContextId")) { + if (req.params.count("executionContextId") != 0u) { auto executionContextId = req.params["executionContextId"].getInt(); if (executionContextId < (int64_t)std::numeric_limits::min() || executionContextId > (int64_t)std::numeric_limits::max()) { @@ -56,14 +58,14 @@ bool RuntimeAgent::handleRequest(const cdp::PreparsedRequest& req) { contextSelector = ExecutionContextSelector::byId((int32_t)executionContextId); - if (req.params.count("executionContextName")) { + if (req.params.count("executionContextName") != 0u) { frontendChannel_(cdp::jsonError( req.id, cdp::ErrorCode::InvalidParams, "executionContextName is mutually exclusive with executionContextId")); return true; } - } else if (req.params.count("executionContextName")) { + } else if (req.params.count("executionContextName") != 0u) { contextSelector = ExecutionContextSelector::byName( req.params["executionContextName"].getString()); } @@ -119,7 +121,7 @@ void RuntimeAgent::notifyBindingCalled( // React Native intentionally replicates this behavior for the sake of // bug-for-bug compatibility with Chrome, but clients should probably not rely // on it. - if (!sessionState_.subscribedBindings.count(bindingName)) { + if (sessionState_.subscribedBindings.count(bindingName) == 0u) { return; } diff --git a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.h b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.h index 291c8ca3714..cabda0c01a2 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeAgent.h @@ -45,7 +45,7 @@ class RuntimeAgent final { RuntimeAgent( FrontendChannel frontendChannel, RuntimeTargetController& targetController, - const ExecutionContextDescription& executionContextDescription, + ExecutionContextDescription executionContextDescription, SessionState& sessionState, std::unique_ptr delegate); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.cpp b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.cpp index fb0f425a63b..8d92d23e93a 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.cpp @@ -10,6 +10,8 @@ #include #include +#include + using namespace facebook::jsi; namespace facebook::react::jsinspector_modern { @@ -34,20 +36,20 @@ std::shared_ptr RuntimeTarget::create( RuntimeTargetDelegate& delegate, RuntimeExecutor jsExecutor, VoidExecutor selfExecutor) { - std::shared_ptr runtimeTarget{ - new RuntimeTarget(executionContextDescription, delegate, jsExecutor)}; - runtimeTarget->setExecutor(selfExecutor); + std::shared_ptr runtimeTarget{new RuntimeTarget( + executionContextDescription, delegate, std::move(jsExecutor))}; + runtimeTarget->setExecutor(std::move(selfExecutor)); runtimeTarget->installGlobals(); return runtimeTarget; } RuntimeTarget::RuntimeTarget( - const ExecutionContextDescription& executionContextDescription, + ExecutionContextDescription executionContextDescription, RuntimeTargetDelegate& delegate, RuntimeExecutor jsExecutor) - : executionContextDescription_(executionContextDescription), + : executionContextDescription_(std::move(executionContextDescription)), delegate_(delegate), - jsExecutor_(jsExecutor) {} + jsExecutor_(std::move(jsExecutor)) {} void RuntimeTarget::installGlobals() { // NOTE: RuntimeTarget::installConsoleHandler is in RuntimeTargetConsole.cpp @@ -56,7 +58,7 @@ void RuntimeTarget::installGlobals() { } std::shared_ptr RuntimeTarget::createAgent( - FrontendChannel channel, + const FrontendChannel& channel, SessionState& sessionState) { auto runtimeAgentState = std::move(sessionState.lastRuntimeAgentExportedState); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.h b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.h index 1ef4c75ac05..62afc0a37b2 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.h @@ -205,7 +205,7 @@ class JSINSPECTOR_EXPORT RuntimeTarget * \returns The new agent, or nullptr if the runtime is not debuggable. */ std::shared_ptr createAgent( - FrontendChannel channel, + const FrontendChannel& channel, SessionState& sessionState); /** @@ -248,7 +248,7 @@ class JSINSPECTOR_EXPORT RuntimeTarget * constructor should be executed before any user code is run). */ RuntimeTarget( - const ExecutionContextDescription& executionContextDescription, + ExecutionContextDescription executionContextDescription, RuntimeTargetDelegate& delegate, RuntimeExecutor jsExecutor); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/ConsoleApiTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/ConsoleApiTest.cpp index 56e15c65a34..6a20aac06d3 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/ConsoleApiTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/ConsoleApiTest.cpp @@ -58,7 +58,7 @@ class ConsoleApiTest : public JsiIntegrationPortableTestBase< onMessage( JsonParsed(AllOf(AtJsonPtr("/method", "Debugger.scriptParsed"))))) .Times(AnyNumber()) - .WillRepeatedly(Invoke<>([this](std::string message) { + .WillRepeatedly(Invoke<>([this](const std::string& message) { auto params = folly::parseJson(message); // Store the script ID and URL for later use. scriptUrlsById_.emplace( @@ -114,7 +114,8 @@ class ConsoleApiTest : public JsiIntegrationPortableTestBase< * paramsMatcher, only if the Runtime domain is currently disabled ( = the * call will be buffered and reported later upon enabling the domain). */ - void expectConsoleApiCallBuffered(Matcher paramsMatcher) { + void expectConsoleApiCallBuffered( + const Matcher& paramsMatcher) { if (!runtimeEnabled_) { expectedConsoleApiCalls_.emplace_back(paramsMatcher); } @@ -136,7 +137,7 @@ class ConsoleApiTest : public JsiIntegrationPortableTestBase< } private: - std::optional getScriptUrlById(std::string scriptId) { + std::optional getScriptUrlById(const std::string& scriptId) { auto it = scriptUrlsById_.find(scriptId); if (it == scriptUrlsById_.end()) { return std::nullopt; diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.cpp index 943a057bc2c..9eaf645fe51 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.cpp @@ -17,7 +17,7 @@ namespace facebook::folly_dynamic_matchers_utils { std::string as_string(std::string value) { return value; } -std::string as_string(folly::dynamic value) { +std::string as_string(const folly::dynamic& value) { return value.asString(); } diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.h b/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.h index d58abbb74b7..f1f42f625d6 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/FollyDynamicMatchers.h @@ -17,7 +17,7 @@ namespace facebook { namespace folly_dynamic_matchers_utils { std::string as_string(std::string value); -std::string as_string(folly::dynamic value); +std::string as_string(const folly::dynamic& value); std::string explain_error( folly::dynamic::json_pointer_resolution_error error); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/HostTargetTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/HostTargetTest.cpp index d989d7f4c63..b9956dc04ca 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/HostTargetTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/HostTargetTest.cpp @@ -642,7 +642,7 @@ TEST_F(HostTargetTest, HostCommands) { std::unique_ptr exportedState, const ExecutionContextDescription& context, - RuntimeExecutor runtimeExecutor) { + const RuntimeExecutor& runtimeExecutor) { auto delegate = runtimeAgentDelegates_.make_unique( std::move(frontendChannel), sessionState, @@ -1417,7 +1417,7 @@ TEST_F(HostTargetTest, NetworkLoadNetworkResourceNotImplementedByDelegate) { Field(&LoadNetworkResourceRequest::url, "http://example.com"), _)) .Times(1) .WillOnce([](const LoadNetworkResourceRequest& /*params*/, - ScopedExecutor /*executor*/) { + const ScopedExecutor& /*executor*/) { throw NotImplementedException( "This delegate does not implement loadNetworkResource."); }) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/engines/JsiIntegrationTestGenericEngineAdapter.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/engines/JsiIntegrationTestGenericEngineAdapter.cpp index fb0650c7c90..ea6208d23c4 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/engines/JsiIntegrationTestGenericEngineAdapter.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/engines/JsiIntegrationTestGenericEngineAdapter.cpp @@ -10,8 +10,6 @@ #include "JsiIntegrationTestGenericEngineAdapter.h" -using facebook::hermes::makeHermesRuntime; - namespace facebook::react::jsinspector_modern { JsiIntegrationTestGenericEngineAdapter::JsiIntegrationTestGenericEngineAdapter( diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp index 03cb4dd6371..0cc49d63231 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp @@ -157,8 +157,7 @@ void PerformanceTracer::reportMark( folly::dynamic eventArgs = folly::dynamic::object(); if (detail != nullptr) { eventArgs = folly::dynamic::object( - "data", - folly::dynamic::object("detail", folly::toJson(std::move(detail)))); + "data", folly::dynamic::object("detail", folly::toJson(detail))); } buffer_.emplace_back(TraceEvent{ @@ -183,8 +182,7 @@ void PerformanceTracer::reportMeasure( folly::dynamic beginEventArgs = folly::dynamic::object(); if (detail != nullptr) { - beginEventArgs = - folly::dynamic::object("detail", folly::toJson(std::move(detail))); + beginEventArgs = folly::dynamic::object("detail", folly::toJson(detail)); } auto currentThreadId = oscompat::getCurrentThreadId();