diff --git a/ReactCommon/react/renderer/.clang-tidy b/ReactCommon/react/renderer/.clang-tidy index f413d1fc858..244e901f289 100644 --- a/ReactCommon/react/renderer/.clang-tidy +++ b/ReactCommon/react/renderer/.clang-tidy @@ -40,5 +40,147 @@ performance-noexcept-move-constructor, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, performance-unnecessary-value-param, +cppcoreguidelines-macro-usage, +cppcoreguidelines-narrowing-conversions, +cppcoreguidelines-no-malloc, +cppcoreguidelines-pro-bounds-pointer-arithmetic, +cppcoreguidelines-pro-type-const-cast, +cppcoreguidelines-pro-type-cstyle-cast, +cppcoreguidelines-pro-type-member-init, +cppcoreguidelines-pro-type-reinterpret-cast, +cppcoreguidelines-pro-type-union-access, +cppcoreguidelines-pro-type-vararg, +cppcoreguidelines-slicing, +cppcoreguidelines-special-member-functions, +readability-avoid-const-params-in-decls, +readability-braces-around-statements, +readability-const-return-type, +readability-container-size-empty, +readability-deleted-default, +readability-delete-null-pointer, +readability-implicit-bool-conversion, +readability-inconsistent-declaration-parameter-name, +readability-isolate-declaration, +readability-misplaced-array-index, +readability-named-parameter, +readability-non-const-parameter, +readability-redundant-control-flow, +readability-redundant-declaration, +readability-redundant-function-ptr-dereference, +readability-redundant-preprocessor, +readability-redundant-smartptr-get, +readability-redundant-string-cstr, +readability-redundant-string-init, +readability-simplify-boolean-expr, +readability-simplify-subscript-expr, +readability-static-accessed-through-instance, +readability-static-definition-in-anonymous-namespace, +readability-string-compare, +readability-uniqueptr-delete-release, +misc-definitions-in-headers, +misc-new-delete-overloads, +misc-non-copyable-objects, +misc-static-assert, +misc-throw-by-value-catch-by-reference, +misc-unconventional-assign-operator, +misc-uniqueptr-reset-release, +misc-unused-alias-decls, +misc-unused-parameters, +misc-unused-using-decls, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-bool-pointer-implicit-conversion, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-exception-escape, +bugprone-fold-init-type, +bugprone-forward-declaration-namespace, +bugprone-forwarding-reference-overload, +bugprone-inaccurate-erase, +bugprone-incorrect-roundings, +bugprone-integer-division, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-operator-in-strlen-in-alloc, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-parent-virtual-call, +bugprone-sizeof-container, +bugprone-sizeof-expression, +bugprone-string-constructor, +bugprone-string-integer-assignment, +bugprone-string-literal-with-embedded-nul, +bugprone-suspicious-enum-usage, +bugprone-suspicious-memset-usage, +bugprone-suspicious-missing-comma, +bugprone-suspicious-semicolon, +bugprone-suspicious-string-compare, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-throw-keyword-missing, +bugprone-too-small-loop-variable, +bugprone-undefined-memory-manipulation, +bugprone-undelegated-constructor, +bugprone-unused-return-value, +bugprone-use-after-move, +bugprone-virtual-near-miss, +clang-analyzer-apiModeling.StdCLibraryFunctions, +clang-analyzer-apiModeling.TrustNonnull, +clang-analyzer-apiModeling.google.GTest, +clang-analyzer-core.CallAndMessage, +clang-analyzer-core.DivideZero, +clang-analyzer-core.DynamicTypePropagation, +clang-analyzer-core.NonNullParamChecker, +clang-analyzer-core.NonnilStringConstants, +clang-analyzer-core.NullDereference, +clang-analyzer-core.StackAddressEscape, +clang-analyzer-core.UndefinedBinaryOperatorResult, +clang-analyzer-core.VLASize, +clang-analyzer-core.builtin.BuiltinFunctions, +clang-analyzer-core.builtin.NoReturnFunctions, +clang-analyzer-core.uninitialized.ArraySubscript, +clang-analyzer-core.uninitialized.Assign, +clang-analyzer-core.uninitialized.Branch, +clang-analyzer-core.uninitialized.CapturedBlockVariable, +clang-analyzer-core.uninitialized.UndefReturn, +clang-analyzer-cplusplus.InnerPointer, +clang-analyzer-cplusplus.Move, +clang-analyzer-cplusplus.NewDelete, +clang-analyzer-cplusplus.NewDeleteLeaks, +clang-analyzer-cplusplus.SelfAssignment, +clang-analyzer-deadcode.DeadStores, +clang-analyzer-optin.cplusplus.VirtualCall, +clang-analyzer-optin.mpi.MPI-Checker, +clang-analyzer-optin.performance.GCDAntipattern, +clang-analyzer-optin.performance.Padding, +clang-analyzer-optin.portability.UnixAPI, +clang-analyzer-nullability.NullPassedToNonnull, +clang-analyzer-nullability.NullReturnedFromNonnull, +clang-analyzer-nullability.NullableDereferenced, +clang-analyzer-nullability.NullablePassedToNonnull, +clang-analyzer-nullability.NullableReturnedFromNonnull, +clang-analyzer-security.FloatLoopCounter, +clang-analyzer-security.insecureAPI.UncheckedReturn, +clang-analyzer-security.insecureAPI.bcmp, +clang-analyzer-security.insecureAPI.bcopy, +clang-analyzer-security.insecureAPI.bzero, +clang-analyzer-security.insecureAPI.getpw, +clang-analyzer-security.insecureAPI.gets, +clang-analyzer-security.insecureAPI.mkstemp, +clang-analyzer-security.insecureAPI.mktemp, +clang-analyzer-security.insecureAPI.rand, +clang-analyzer-security.insecureAPI.strcpy, +clang-analyzer-security.insecureAPI.vfork, +clang-analyzer-unix.API, +clang-analyzer-unix.Malloc, +clang-analyzer-unix.MallocSizeof, +clang-analyzer-unix.MismatchedDeallocator, +clang-analyzer-unix.Vfork, +clang-analyzer-unix.cstring.BadSizeArg, +clang-analyzer-unix.cstring.NullArg, +clang-analyzer-valist.CopyToSelf, +clang-analyzer-valist.Uninitialized, +clang-analyzer-valist.Unterminated, ' ... diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 00b8cfa69ef..fe321a2f1e5 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1183,11 +1183,11 @@ void LayoutAnimationKeyFrameManager::queueFinalMutationsForCompletedKeyFrame( AnimationKeyFrame const &keyframe, ShadowViewMutation::List &mutationsList, bool interrupted, - const std::string &logPrefix) const { + const std::string & /*logPrefix*/) const { if (skipInvalidatedKeyFrames_ && keyframe.invalidated) { return; } - if (keyframe.finalMutationsForKeyFrame.size() > 0) { + if (!keyframe.finalMutationsForKeyFrame.empty()) { // TODO: modularize this segment, it is repeated 2x in KeyFrameManager // as well. ShadowView prev = keyframe.viewPrev; diff --git a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index ea6a5e600a9..da1aa6cdcb0 100644 --- a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -64,7 +64,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // Create a RuntimeExecutor RuntimeExecutor runtimeExecutor = - [](std::function const &) {}; + [](std::function const & /*unused*/) {}; // Create component descriptor registry for animation driver auto providerRegistry = @@ -158,7 +158,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // If tree randomization produced no changes in the form of mutations, // don't bother trying to animate because this violates a bunch of our // assumptions in this test - if (originalMutations.size() == 0) { + if (originalMutations.empty()) { continue; } diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp index 965c7d409fa..29e144cfc28 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp @@ -11,7 +11,7 @@ namespace facebook { namespace react { void ComponentDescriptorProviderRegistry::add( - ComponentDescriptorProvider provider) const { + const ComponentDescriptorProvider &provider) const { std::unique_lock lock(mutex_); /* diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h index 182d24a7a8c..cba67833518 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h @@ -33,7 +33,7 @@ class ComponentDescriptorProviderRegistry final { * `ComponentDescriptorRegistry`s accordingly. * The methods can be called on any thread. */ - void add(ComponentDescriptorProvider provider) const; + void add(const ComponentDescriptorProvider &provider) const; /* * ComponenDescriptorRegistry will call the `request` in case if a component diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp index 42fe6e0eff1..0a29a334664 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp @@ -50,7 +50,7 @@ void ComponentDescriptorRegistry::add( } void ComponentDescriptorRegistry::registerComponentDescriptor( - SharedComponentDescriptor componentDescriptor) const { + const SharedComponentDescriptor &componentDescriptor) const { ComponentHandle componentHandle = componentDescriptor->getComponentHandle(); _registryByHandle[componentHandle] = componentDescriptor; @@ -119,11 +119,7 @@ bool ComponentDescriptorRegistry::hasComponentDescriptorAt( std::shared_lock lock(mutex_); auto iterator = _registryByHandle.find(componentHandle); - if (iterator == _registryByHandle.end()) { - return false; - } - - return true; + return iterator != _registryByHandle.end(); } ShadowNode::Shared ComponentDescriptorRegistry::createNode( @@ -136,8 +132,7 @@ ShadowNode::Shared ComponentDescriptorRegistry::createNode( auto const &componentDescriptor = this->at(unifiedComponentName); auto const fragment = ShadowNodeFamilyFragment{tag, surfaceId, nullptr}; - auto family = - componentDescriptor.createFamily(fragment, std::move(eventTarget)); + auto family = componentDescriptor.createFamily(fragment, eventTarget); auto const props = componentDescriptor.cloneProps( PropsParserContext{surfaceId, *contextContainer_.get()}, nullptr, @@ -155,7 +150,7 @@ ShadowNode::Shared ComponentDescriptorRegistry::createNode( } void ComponentDescriptorRegistry::setFallbackComponentDescriptor( - SharedComponentDescriptor descriptor) { + const SharedComponentDescriptor &descriptor) { _fallbackComponentDescriptor = descriptor; registerComponentDescriptor(descriptor); } diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h index 054af63c032..d2eeceaf60f 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h @@ -62,14 +62,15 @@ class ComponentDescriptorRegistry { folly::dynamic const &props, SharedEventTarget const &eventTarget) const; - void setFallbackComponentDescriptor(SharedComponentDescriptor descriptor); + void setFallbackComponentDescriptor( + const SharedComponentDescriptor &descriptor); ComponentDescriptor::Shared getFallbackComponentDescriptor() const; private: friend class ComponentDescriptorProviderRegistry; void registerComponentDescriptor( - SharedComponentDescriptor componentDescriptor) const; + const SharedComponentDescriptor &componentDescriptor) const; /* * Creates a `ComponentDescriptor` using specified diff --git a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp index b23525bddc7..4b7e9c69917 100644 --- a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp +++ b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp @@ -20,7 +20,7 @@ namespace react { */ NativeComponentRegistryBinding::NativeComponentRegistryBinding( const HasComponentProviderFunctionType &&hasComponentProvider) - : hasComponentProvider_(std::move(hasComponentProvider)) {} + : hasComponentProvider_(hasComponentProvider) {} void NativeComponentRegistryBinding::install( jsi::Runtime &runtime, @@ -61,7 +61,7 @@ jsi::Value NativeComponentRegistryBinding::jsProxy( bool result = hasComponent(moduleName); - return jsi::Value(result); + return {result}; } } // namespace react diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp index 3d7c97a4a03..85d7b8da139 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp @@ -25,7 +25,7 @@ void AndroidProgressBarShadowNode::setAndroidProgressBarMeasurementsManager( #pragma mark - LayoutableShadowNode Size AndroidProgressBarShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { return measurementsManager_->measure( getSurfaceId(), getConcreteProps(), layoutConstraints); diff --git a/ReactCommon/react/renderer/components/root/RootProps.cpp b/ReactCommon/react/renderer/components/root/RootProps.cpp index 47013f3c14e..df7e709b9ec 100644 --- a/ReactCommon/react/renderer/components/root/RootProps.cpp +++ b/ReactCommon/react/renderer/components/root/RootProps.cpp @@ -26,8 +26,8 @@ RootProps::RootProps( // If that's a problem and the context is necesary here, refactor RootShadowNode // first. RootProps::RootProps( - const PropsParserContext &context, - RootProps const &sourceProps, + const PropsParserContext & /*context*/, + RootProps const & /*sourceProps*/, LayoutConstraints const &layoutConstraints, LayoutContext const &layoutContext) : ViewProps(), diff --git a/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp b/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp index 09438980173..b4d24e69feb 100644 --- a/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp +++ b/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp @@ -84,7 +84,7 @@ ImageSource SliderShadowNode::getThumbImageSource() const { #pragma mark - LayoutableShadowNode Size SliderShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { if (SliderMeasurementsManager::shouldMeasureSlider()) { return measurementsManager_->measure(getSurfaceId(), layoutConstraints); diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp index 4dca3fbda46..af2d201d0f3 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp @@ -22,7 +22,7 @@ void AndroidSwitchShadowNode::setAndroidSwitchMeasurementsManager( #pragma mark - LayoutableShadowNode Size AndroidSwitchShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { return measurementsManager_->measure(getSurfaceId(), layoutConstraints); } diff --git a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp index 88189288fdf..c1606d0ddae 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp @@ -219,7 +219,7 @@ BaseTextProps::BaseTextProps( void BaseTextProps::setProp( const PropsParserContext &context, RawPropsPropNameHash hash, - const char *propName, + const char * /*propName*/, RawValue const &value) { static auto defaults = TextAttributes{}; diff --git a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp index 054bdeb14fb..88cf821aac0 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp @@ -34,7 +34,7 @@ void BaseTextShadowNode::buildAttributedString( // RawShadowNode auto rawTextShadowNode = traitCast(childNode.get()); - if (rawTextShadowNode) { + if (rawTextShadowNode != nullptr) { auto fragment = AttributedString::Fragment{}; fragment.string = rawTextShadowNode->getConcreteProps().text; fragment.textAttributes = baseTextAttributes; @@ -50,7 +50,7 @@ void BaseTextShadowNode::buildAttributedString( // TextShadowNode auto textShadowNode = traitCast(childNode.get()); - if (textShadowNode) { + if (textShadowNode != nullptr) { auto localTextAttributes = baseTextAttributes; localTextAttributes.apply( textShadowNode->getConcreteProps().textAttributes); diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp index 5edf5badde2..2c98a0e164e 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp @@ -168,7 +168,7 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() { #pragma mark - LayoutableShadowNode Size AndroidTextInputShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { if (getStateData().cachedAttributedStringId != 0) { return textLayoutManager_ diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h index a872f5f7ba6..3dc1cefaff5 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h @@ -45,8 +45,8 @@ class TextInputEventEmitter : public ViewEventEmitter { void onSelectionChange(TextInputMetrics const &textInputMetrics) const; void onEndEditing(TextInputMetrics const &textInputMetrics) const; void onSubmitEditing(TextInputMetrics const &textInputMetrics) const; - void onKeyPress(KeyPressMetrics const &textInputMetrics) const; - void onKeyPressSync(KeyPressMetrics const &textInputMetrics) const; + void onKeyPress(KeyPressMetrics const &keyPressMetrics) const; + void onKeyPressSync(KeyPressMetrics const &keyPressMetrics) const; void onScroll(TextInputMetrics const &textInputMetrics) const; private: diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp index f4930a436e9..bd3e8c4f4bc 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp @@ -12,8 +12,8 @@ namespace react { #ifdef ANDROID TextInputState::TextInputState( - TextInputState const &previousState, - folly::dynamic const &data){}; + TextInputState const & /*previousState*/, + folly::dynamic const & /*data*/){}; /* * Empty implementation for Android because it doesn't use this class. diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp index d3a91fdfa35..d5a4dcadf87 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp @@ -194,7 +194,7 @@ AccessibilityProps::AccessibilityProps( void AccessibilityProps::setProp( const PropsParserContext &context, RawPropsPropNameHash hash, - const char *propName, + const char * /*propName*/, RawValue const &value) { switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(accessible, false); @@ -217,7 +217,7 @@ void AccessibilityProps::setProp( RAW_SET_PROP_SWITCH_CASE(testId, "testID", std::string{""}); case CONSTEXPR_RAW_PROPS_KEY_HASH("accessibilityRole"): { AccessibilityTraits traits = AccessibilityTraits::None; - std::string roleString = ""; + std::string roleString; if (value.hasValue()) { fromRawValue(context, value, traits); fromRawValue(context, value, roleString); diff --git a/ReactCommon/react/renderer/components/view/PointerEvent.cpp b/ReactCommon/react/renderer/components/view/PointerEvent.cpp index 842c8a4408b..0bf0a7302de 100644 --- a/ReactCommon/react/renderer/components/view/PointerEvent.cpp +++ b/ReactCommon/react/renderer/components/view/PointerEvent.cpp @@ -12,7 +12,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(PointerEvent const &pointerEvent) { +std::string getDebugName(PointerEvent const & /*pointerEvent*/) { return "PointerEvent"; } diff --git a/ReactCommon/react/renderer/components/view/Touch.cpp b/ReactCommon/react/renderer/components/view/Touch.cpp index 15e5bfaaee5..116b7deefec 100644 --- a/ReactCommon/react/renderer/components/view/Touch.cpp +++ b/ReactCommon/react/renderer/components/view/Touch.cpp @@ -12,7 +12,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(Touch const &touch) { +std::string getDebugName(Touch const & /*touch*/) { return "Touch"; } diff --git a/ReactCommon/react/renderer/components/view/Touch.h b/ReactCommon/react/renderer/components/view/Touch.h index 13383a0e5bb..415fdc49943 100644 --- a/ReactCommon/react/renderer/components/view/Touch.h +++ b/ReactCommon/react/renderer/components/view/Touch.h @@ -80,7 +80,7 @@ using Touches = std::unordered_set; std::string getDebugName(Touch const &touch); std::vector getDebugProps( - Touch const &object, + Touch const &touch, DebugStringConvertibleOptions options); #endif diff --git a/ReactCommon/react/renderer/components/view/TouchEvent.cpp b/ReactCommon/react/renderer/components/view/TouchEvent.cpp index 7f8b9fda170..3939345653c 100644 --- a/ReactCommon/react/renderer/components/view/TouchEvent.cpp +++ b/ReactCommon/react/renderer/components/view/TouchEvent.cpp @@ -12,7 +12,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(TouchEvent const &touchEvent) { +std::string getDebugName(TouchEvent const & /*touchEvent*/) { return "TouchEvent"; } diff --git a/ReactCommon/react/renderer/core/EventEmitter.cpp b/ReactCommon/react/renderer/core/EventEmitter.cpp index 894ddf8eddd..cca4a0eca17 100644 --- a/ReactCommon/react/renderer/core/EventEmitter.cpp +++ b/ReactCommon/react/renderer/core/EventEmitter.cpp @@ -44,7 +44,7 @@ ValueFactory EventEmitter::defaultPayloadFactory() { EventEmitter::EventEmitter( SharedEventTarget eventTarget, - Tag tag, + Tag /*tag*/, EventDispatcher::Weak eventDispatcher) : eventTarget_(std::move(eventTarget)), eventDispatcher_(std::move(eventDispatcher)) {} diff --git a/ReactCommon/react/renderer/core/EventTarget.cpp b/ReactCommon/react/renderer/core/EventTarget.cpp index 9a6d115b272..02ceab2c133 100644 --- a/ReactCommon/react/renderer/core/EventTarget.cpp +++ b/ReactCommon/react/renderer/core/EventTarget.cpp @@ -46,7 +46,7 @@ void EventTarget::retain(jsi::Runtime &runtime) const { // react_native_assert(!strongInstanceHandle_.isUndefined()); } -void EventTarget::release(jsi::Runtime &runtime) const { +void EventTarget::release(jsi::Runtime & /*runtime*/) const { // The method does not use `jsi::Runtime` reference. // It takes it only to ensure thread-safety (if the caller has the reference, // we are on a proper thread). diff --git a/ReactCommon/react/renderer/core/LayoutMetrics.cpp b/ReactCommon/react/renderer/core/LayoutMetrics.cpp index 8e92f2f07a1..6c428988658 100644 --- a/ReactCommon/react/renderer/core/LayoutMetrics.cpp +++ b/ReactCommon/react/renderer/core/LayoutMetrics.cpp @@ -15,7 +15,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(LayoutMetrics const &object) { +std::string getDebugName(LayoutMetrics const & /*object*/) { return "LayoutMetrics"; } diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp index 7f3c1f0382a..0347783f0ea 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp @@ -256,7 +256,7 @@ LayoutableShadowNode::getLayoutableChildNodes() const { Size LayoutableShadowNode::measureContent( LayoutContext const &layoutContext, LayoutConstraints const &layoutConstraints) const { - return Size(); + return {}; } Size LayoutableShadowNode::measure( diff --git a/ReactCommon/react/renderer/core/Props.cpp b/ReactCommon/react/renderer/core/Props.cpp index ad1c01c5c28..0e2af101fd8 100644 --- a/ReactCommon/react/renderer/core/Props.cpp +++ b/ReactCommon/react/renderer/core/Props.cpp @@ -41,7 +41,7 @@ Props::Props( void Props::setProp( const PropsParserContext &context, RawPropsPropNameHash hash, - const char *propName, + const char * /*propName*/, RawValue const &value) { switch (hash) { case CONSTEXPR_RAW_PROPS_KEY_HASH("nativeID"): diff --git a/ReactCommon/react/renderer/core/RawProps.cpp b/ReactCommon/react/renderer/core/RawProps.cpp index 454e2bed304..bd476f6ca03 100644 --- a/ReactCommon/react/renderer/core/RawProps.cpp +++ b/ReactCommon/react/renderer/core/RawProps.cpp @@ -48,8 +48,9 @@ RawProps::RawProps(folly::dynamic const &dynamic) noexcept { dynamic_ = dynamic; } -void RawProps::parse(RawPropsParser const &parser, const PropsParserContext &) - const noexcept { +void RawProps::parse( + RawPropsParser const &parser, + const PropsParserContext & /*unused*/) const noexcept { react_native_assert(parser_ == nullptr && "A parser was already assigned."); parser_ = &parser; parser.preparse(*this); diff --git a/ReactCommon/react/renderer/core/RawProps.h b/ReactCommon/react/renderer/core/RawProps.h index 4e86e289cc1..08cdcdd5d03 100644 --- a/ReactCommon/react/renderer/core/RawProps.h +++ b/ReactCommon/react/renderer/core/RawProps.h @@ -118,7 +118,7 @@ class RawProps final { mutable Mode mode_; // Case 1: Source data is represented as `jsi::Object`. - jsi::Runtime *runtime_; + jsi::Runtime *runtime_{}; jsi::Value value_; // Case 2: Source data is represented as `folly::dynamic`. diff --git a/ReactCommon/react/renderer/core/RawPropsKey.cpp b/ReactCommon/react/renderer/core/RawPropsKey.cpp index de7820dc7ba..daaefbc5ae1 100644 --- a/ReactCommon/react/renderer/core/RawPropsKey.cpp +++ b/ReactCommon/react/renderer/core/RawPropsKey.cpp @@ -22,7 +22,7 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length) *length = 0; // Prefix - if (prefix) { + if (prefix != nullptr) { auto prefixLength = static_cast(std::strlen(prefix)); std::memcpy(buffer, prefix, prefixLength); @@ -35,7 +35,7 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length) *length += nameLength; // Suffix - if (suffix) { + if (suffix != nullptr) { auto suffixLength = static_cast(std::strlen(suffix)); std::memcpy(buffer + *length, suffix, suffixLength); diff --git a/ReactCommon/react/renderer/core/Sealable.cpp b/ReactCommon/react/renderer/core/Sealable.cpp index abb839c8ea6..881ac7842d4 100644 --- a/ReactCommon/react/renderer/core/Sealable.cpp +++ b/ReactCommon/react/renderer/core/Sealable.cpp @@ -29,7 +29,7 @@ namespace react { Sealable::Sealable() : sealed_(false) {} -Sealable::Sealable(const Sealable &other) : sealed_(false){}; +Sealable::Sealable(const Sealable & /*other*/) : sealed_(false){}; Sealable::Sealable(Sealable &&other) noexcept : sealed_(false) { other.ensureUnsealed(); @@ -37,7 +37,7 @@ Sealable::Sealable(Sealable &&other) noexcept : sealed_(false) { Sealable::~Sealable() noexcept = default; -Sealable &Sealable::operator=(const Sealable &other) { +Sealable &Sealable::operator=(const Sealable & /*other*/) { ensureUnsealed(); return *this; } diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp index 73d022bf2ef..b5e28cb988b 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp +++ b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp @@ -63,7 +63,7 @@ AncestorList ShadowNodeFamily::getAncestors( auto ancestorFamily = ancestorShadowNode.family_.get(); auto family = this; - while (family && family != ancestorFamily) { + while ((family != nullptr) && family != ancestorFamily) { families.push_back(family); family = family->parent_.lock().get(); } diff --git a/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp b/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp index feb6c16973a..28d85cef6d6 100644 --- a/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp +++ b/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp @@ -22,11 +22,11 @@ class EventQueueProcessorTest : public testing::Test { runtime_ = facebook::hermes::makeHermesRuntime(); auto eventPipe = [this]( - jsi::Runtime &runtime, - const EventTarget *eventTarget, + jsi::Runtime & /*runtime*/, + const EventTarget * /*eventTarget*/, const std::string &type, ReactEventPriority priority, - const ValueFactory &payloadFactory) { + const ValueFactory & /*payloadFactory*/) { eventTypes_.push_back(type); eventPriorities_.push_back(priority); }; diff --git a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp index fe908006965..a620d3c96dc 100644 --- a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp +++ b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp @@ -188,7 +188,7 @@ TEST(RawPropsTest, handleRawPropsSingleFloat) { parser.prepare(); raw.parse(parser, parserContext); - float value = (float)*raw.at("floatValue", nullptr, nullptr); + auto value = (float)*raw.at("floatValue", nullptr, nullptr); EXPECT_NEAR(value, 42.42, 0.00001); } @@ -203,7 +203,7 @@ TEST(RawPropsTest, handleRawPropsSingleDouble) { parser.prepare(); raw.parse(parser, parserContext); - double value = (double)*raw.at("doubleValue", nullptr, nullptr); + auto value = (double)*raw.at("doubleValue", nullptr, nullptr); EXPECT_NEAR(value, 42.42, 0.00001); } diff --git a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp index fde19f4163a..8e6f62b4c1a 100644 --- a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp +++ b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp @@ -24,7 +24,7 @@ std::string DebugStringConvertible::getDebugChildrenDescription( options.depth++; auto trailing = options.format ? std::string{"\n"} : std::string{""}; - auto childrenString = std::string{""}; + std::string childrenString; for (auto const &child : getDebugChildren()) { if (!child) { @@ -50,7 +50,7 @@ std::string DebugStringConvertible::getDebugPropsDescription( options.depth++; - auto propsString = std::string{""}; + std::string propsString; for (auto const &prop : getDebugProps()) { if (!prop) { @@ -116,11 +116,11 @@ std::string DebugStringConvertible::getDebugValue() const { SharedDebugStringConvertibleList DebugStringConvertible::getDebugChildren() const { - return SharedDebugStringConvertibleList(); + return {}; } SharedDebugStringConvertibleList DebugStringConvertible::getDebugProps() const { - return SharedDebugStringConvertibleList(); + return {}; } /* diff --git a/ReactCommon/react/renderer/graphics/Transform.cpp b/ReactCommon/react/renderer/graphics/Transform.cpp index a8a7f1033b8..5639203f0df 100644 --- a/ReactCommon/react/renderer/graphics/Transform.cpp +++ b/ReactCommon/react/renderer/graphics/Transform.cpp @@ -279,28 +279,40 @@ Transform Transform::operator*(Transform const &rhs) const { auto result = Transform{}; for (const auto &op : this->operations) { if (op.type == TransformOperationType::Identity && - result.operations.size() > 0) { + !result.operations.empty()) { continue; } result.operations.push_back(op); } for (const auto &op : rhs.operations) { if (op.type == TransformOperationType::Identity && - result.operations.size() > 0) { + !result.operations.empty()) { continue; } result.operations.push_back(op); } - auto lhs00 = lhs.matrix[0], lhs01 = lhs.matrix[1], lhs02 = lhs.matrix[2], - lhs03 = lhs.matrix[3], lhs10 = lhs.matrix[4], lhs11 = lhs.matrix[5], - lhs12 = lhs.matrix[6], lhs13 = lhs.matrix[7], lhs20 = lhs.matrix[8], - lhs21 = lhs.matrix[9], lhs22 = lhs.matrix[10], lhs23 = lhs.matrix[11], - lhs30 = lhs.matrix[12], lhs31 = lhs.matrix[13], lhs32 = lhs.matrix[14], - lhs33 = lhs.matrix[15]; + auto lhs00 = lhs.matrix[0]; + auto lhs01 = lhs.matrix[1]; + auto lhs02 = lhs.matrix[2]; + auto lhs03 = lhs.matrix[3]; + auto lhs10 = lhs.matrix[4]; + auto lhs11 = lhs.matrix[5]; + auto lhs12 = lhs.matrix[6]; + auto lhs13 = lhs.matrix[7]; + auto lhs20 = lhs.matrix[8]; + auto lhs21 = lhs.matrix[9]; + auto lhs22 = lhs.matrix[10]; + auto lhs23 = lhs.matrix[11]; + auto lhs30 = lhs.matrix[12]; + auto lhs31 = lhs.matrix[13]; + auto lhs32 = lhs.matrix[14]; + auto lhs33 = lhs.matrix[15]; - auto rhs0 = rhs.matrix[0], rhs1 = rhs.matrix[1], rhs2 = rhs.matrix[2], - rhs3 = rhs.matrix[3]; + auto rhs0 = rhs.matrix[0]; + auto rhs1 = rhs.matrix[1]; + auto rhs2 = rhs.matrix[2]; + auto rhs3 = rhs.matrix[3]; result.matrix[0] = rhs0 * lhs00 + rhs1 * lhs10 + rhs2 * lhs20 + rhs3 * lhs30; result.matrix[1] = rhs0 * lhs01 + rhs1 * lhs11 + rhs2 * lhs21 + rhs3 * lhs31; result.matrix[2] = rhs0 * lhs02 + rhs1 * lhs12 + rhs2 * lhs22 + rhs3 * lhs32; diff --git a/ReactCommon/react/renderer/graphics/Transform.h b/ReactCommon/react/renderer/graphics/Transform.h index e24f4af028b..50a70161207 100644 --- a/ReactCommon/react/renderer/graphics/Transform.h +++ b/ReactCommon/react/renderer/graphics/Transform.h @@ -112,9 +112,9 @@ struct Transform { /* * Returns a transform that rotates by `angle` radians along the given axis. */ - static Transform RotateX(Float angle); - static Transform RotateY(Float angle); - static Transform RotateZ(Float angle); + static Transform RotateX(Float radians); + static Transform RotateY(Float radians); + static Transform RotateZ(Float radians); static Transform Rotate(Float angleX, Float angleY, Float angleZ); /** @@ -145,8 +145,8 @@ struct Transform { /* * Matrix subscript. */ - Float &at(int x, int y); - Float const &at(int x, int y) const; + Float &at(int i, int j); + Float const &at(int i, int j) const; /* * Concatenates (multiplies) transform matrices. diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp index 02c6bf82d4a..7fb59308a08 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp @@ -20,11 +20,11 @@ bool isColorMeaningful(SharedColor const &color) noexcept { SharedColor colorFromComponents(ColorComponents components) { float ratio = 255; - return SharedColor( + return { ((int)round(components.alpha * ratio) & 0xff) << 24 | ((int)round(components.red * ratio) & 0xff) << 16 | ((int)round(components.green * ratio) & 0xff) << 8 | - ((int)round(components.blue * ratio) & 0xff)); + ((int)round(components.blue * ratio) & 0xff)}; } ColorComponents colorComponentsFromColor(SharedColor const &sharedColor) { diff --git a/ReactCommon/react/renderer/imagemanager/ImageManager.h b/ReactCommon/react/renderer/imagemanager/ImageManager.h index f76912bf778..42117ac7f77 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageManager.h +++ b/ReactCommon/react/renderer/imagemanager/ImageManager.h @@ -33,7 +33,7 @@ class ImageManager { const; private: - void *self_; + void *self_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp index b7f1274e351..6baf9a795af 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp +++ b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp @@ -10,7 +10,8 @@ namespace facebook { namespace react { -ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) { +ImageManager::ImageManager( + ContextContainer::Shared const & /*contextContainer*/) { // Silence unused-private-field warning. (void)self_; // Not implemented. @@ -22,9 +23,9 @@ ImageManager::~ImageManager() { ImageRequest ImageManager::requestImage( const ImageSource &imageSource, - SurfaceId surfaceId) const { + SurfaceId /*surfaceId*/) const { // Not implemented. - return ImageRequest(imageSource, nullptr); + return {imageSource, nullptr}; } } // namespace react diff --git a/ReactCommon/react/renderer/leakchecker/LeakChecker.h b/ReactCommon/react/renderer/leakchecker/LeakChecker.h index c88b34a5e1a..c568b190fdd 100644 --- a/ReactCommon/react/renderer/leakchecker/LeakChecker.h +++ b/ReactCommon/react/renderer/leakchecker/LeakChecker.h @@ -32,7 +32,7 @@ class LeakChecker final { RuntimeExecutor const runtimeExecutor_{}; WeakFamilyRegistry registry_{}; - SurfaceId previouslyStoppedSurface_; + SurfaceId previouslyStoppedSurface_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp index a2279a5ed62..aaf99e18ccb 100644 --- a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp +++ b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp @@ -28,9 +28,8 @@ WeakFamilyRegistry::WeakFamilies WeakFamilyRegistry::weakFamiliesForSurfaceId( std::lock_guard lock(familiesMutex_); if (families_.find(surfaceId) != families_.end()) { return families_[surfaceId]; - } else { - return {}; } + return {}; } } // namespace react diff --git a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp index eaffddf401b..f5d5198f70f 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp +++ b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp @@ -90,7 +90,7 @@ std::string MapBuffer::getString(Key key) const { uint8_t const *stringPtr = bytes_.data() + dynamicDataOffset + offset + sizeof(int); - return std::string(stringPtr, stringPtr + stringLength); + return {stringPtr, stringPtr + stringLength}; } MapBuffer MapBuffer::getMapBuffer(Key key) const { diff --git a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp index f6aec1ccf4a..8f3baaaf59f 100644 --- a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp +++ b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp @@ -164,7 +164,7 @@ TEST(MapBufferTest, testMapListEntries) { mapBufferList.push_back(builder2.build()); auto builder3 = MapBufferBuilder(); - builder3.putMapBufferList(5, std::move(mapBufferList)); + builder3.putMapBufferList(5, mapBufferList); auto map = builder3.build(); std::vector mapBufferList2 = map.getMapBufferList(5); diff --git a/ReactCommon/react/renderer/mounting/Differentiator.cpp b/ReactCommon/react/renderer/mounting/Differentiator.cpp index 372aa7cb6f0..ffaadd4266e 100644 --- a/ReactCommon/react/renderer/mounting/Differentiator.cpp +++ b/ReactCommon/react/renderer/mounting/Differentiator.cpp @@ -336,7 +336,6 @@ static_assert( "`ShadowViewNodePair::NonOwningList` must be `move assignable`."); static void calculateShadowViewMutationsV2( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, @@ -355,18 +354,15 @@ struct OrderedMutationInstructionContainer { }; static void updateMatchedPairSubtrees( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, OrderedMutationInstructionContainer &mutationContainer, TinyMap &newRemainingPairs, ShadowViewNodePair::NonOwningList &oldChildPairs, - ShadowViewNodePair::NonOwningList &newChildPairs, ShadowView const &parentShadowView, ShadowViewNodePair const &oldPair, ShadowViewNodePair const &newPair); static void updateMatchedPair( - BREADCRUMB_TYPE breadcrumb, OrderedMutationInstructionContainer &mutationContainer, bool oldNodeFoundInOrder, bool newNodeFoundInOrder, @@ -375,12 +371,11 @@ static void updateMatchedPair( ShadowViewNodePair const &newPair); static void calculateShadowViewMutationsFlattener( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ReparentMode reparentMode, OrderedMutationInstructionContainer &mutationContainer, ShadowView const &parentShadowView, - TinyMap &unvisitedFlattenedNodes, + TinyMap &unvisitedOtherNodes, ShadowViewNodePair const &node, TinyMap *parentSubVisitedOtherNewNodes = nullptr, TinyMap *parentSubVisitedOtherOldNodes = @@ -395,12 +390,10 @@ static void calculateShadowViewMutationsFlattener( * the ViewNodePairScope used within. */ static void updateMatchedPairSubtrees( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, OrderedMutationInstructionContainer &mutationContainer, TinyMap &newRemainingPairs, ShadowViewNodePair::NonOwningList &oldChildPairs, - ShadowViewNodePair::NonOwningList &newChildPairs, ShadowView const &parentShadowView, ShadowViewNodePair const &oldPair, ShadowViewNodePair const &newPair) { @@ -427,9 +420,6 @@ static void updateMatchedPairSubtrees( // children are visited, so we reuse the `newRemainingPairs` // map. calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - "Flatten tree " + std::to_string(parentShadowView.tag) + - " into list " + std::to_string(oldPair.shadowView.tag)), scope, ReparentMode::Flatten, mutationContainer, @@ -460,9 +450,6 @@ static void updateMatchedPairSubtrees( // Unflatten old list into new tree calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - "Unflatten old list " + std::to_string(parentShadowView.tag) + - " into new tree " + std::to_string(newPair.shadowView.tag)), scope, ReparentMode::Unflatten, mutationContainer, @@ -502,8 +489,6 @@ static void updateMatchedPairSubtrees( auto newGrandChildPairs = sliceChildShadowNodeViewPairsFromViewNodePair(newPair, innerScope); calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Non-trivial update " + std::to_string(oldPair.shadowView.tag)), innerScope, *(newGrandChildPairs.size() ? &mutationContainer.downwardMutations @@ -523,7 +508,6 @@ static void updateMatchedPairSubtrees( * correct ordering of INSERT and REMOVE mutations. */ static void updateMatchedPair( - BREADCRUMB_TYPE breadcrumb, OrderedMutationInstructionContainer &mutationContainer, bool oldNodeFoundInOrder, bool newNodeFoundInOrder, @@ -618,7 +602,6 @@ static void updateMatchedPair( * **after this function is called**, by the caller. */ static void calculateShadowViewMutationsFlattener( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ReparentMode reparentMode, OrderedMutationInstructionContainer &mutationContainer, @@ -845,9 +828,6 @@ static void calculateShadowViewMutationsFlattener( if (oldTreeNodePair.shadowNode != newTreeNodePair.shadowNode) { ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "(Un)Flattener trivial update of " + - std::to_string(newTreeNodePair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, newTreeNodePair.shadowView, @@ -867,17 +847,6 @@ static void calculateShadowViewMutationsFlattener( // This is a flatten-flatten, or unflatten-unflatten. if (childReparentMode == reparentMode) { calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - std::string( - reparentMode == ReparentMode::Flatten - ? "Flatten-Flatten" - : "Unflatten-Unflatten") + - " new:" + - std::to_string( - reparentMode == ReparentMode::Flatten - ? parentShadowView.tag - : newTreeNodePair.shadowView.tag) + - " old:" + std::to_string(treeChildPair.shadowView.tag)), scope, childReparentMode, mutationContainer, @@ -919,13 +888,6 @@ static void calculateShadowViewMutationsFlattener( // At the end of this loop we still want to know which of these // children are visited, so we reuse the `newRemainingPairs` map. calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - std::string("Flatten old tree into new list; new:") + - std::to_string( - reparentMode == ReparentMode::Flatten - ? parentShadowView.tag - : newTreeNodePair.shadowView.tag) + - " old:" + std::to_string(oldTreeNodePair.shadowView.tag)), scope, ReparentMode::Flatten, mutationContainer, @@ -941,13 +903,6 @@ static void calculateShadowViewMutationsFlattener( else { // Unflatten old list into new tree calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - "Unflatten old list into new tree; old:" + - std::to_string( - reparentMode == ReparentMode::Flatten - ? parentShadowView.tag - : newTreeNodePair.shadowView.tag) + - " new:" + std::to_string(newTreeNodePair.shadowView.tag)), scope, ReparentMode::Unflatten, mutationContainer, @@ -1049,9 +1004,6 @@ static void calculateShadowViewMutationsFlattener( if (!treeChildPair.flattened) { ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Recursively delete tree child pair (flatten case): " + - std::to_string(treeChildPair.shadowView.tag)), innerScope, mutationContainer.destructiveDownwardMutations, treeChildPair.shadowView, @@ -1066,9 +1018,6 @@ static void calculateShadowViewMutationsFlattener( if (!treeChildPair.flattened) { ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Recursively delete tree child pair (unflatten case): " + - std::to_string(treeChildPair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, treeChildPair.shadowView, @@ -1081,7 +1030,6 @@ static void calculateShadowViewMutationsFlattener( } static void calculateShadowViewMutationsV2( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, @@ -1177,9 +1125,6 @@ static void calculateShadowViewMutationsV2( auto newGrandChildPairs = sliceChildShadowNodeViewPairsFromViewNodePair( newChildPair, innerScope); calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Stage 1: Recurse on " + - std::to_string(oldChildPair.shadowView.tag)), innerScope, *(newGrandChildPairs.size() ? &mutationContainer.downwardMutations @@ -1246,8 +1191,6 @@ static void calculateShadowViewMutationsV2( // subtree starting from the removed view. ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Trivial delete " + std::to_string(oldChildPair.shadowView.tag)), innerScope, mutationContainer.destructiveDownwardMutations, oldChildPair.shadowView, @@ -1282,8 +1225,6 @@ static void calculateShadowViewMutationsV2( ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Trivial create " + std::to_string(newChildPair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, newChildPair.shadowView, @@ -1304,9 +1245,10 @@ static void calculateShadowViewMutationsV2( // Walk through both lists at the same time // We will perform updates, create+insert, remove+delete, remove+insert // (move) here. - size_t oldIndex = lastIndexAfterFirstStage, - newIndex = lastIndexAfterFirstStage, newSize = newChildPairs.size(), - oldSize = oldChildPairs.size(); + size_t oldIndex = lastIndexAfterFirstStage; + size_t newIndex = lastIndexAfterFirstStage; + size_t newSize = newChildPairs.size(); + size_t oldSize = oldChildPairs.size(); while (newIndex < newSize || oldIndex < oldSize) { bool haveNewPair = newIndex < newSize; bool haveOldPair = oldIndex < oldSize; @@ -1333,9 +1275,6 @@ static void calculateShadowViewMutationsV2( }); updateMatchedPair( - DIFF_BREADCRUMB( - "Update Matched Pairs (1): " + - std::to_string(oldChildPair.shadowView.tag)), mutationContainer, true, true, @@ -1344,14 +1283,10 @@ static void calculateShadowViewMutationsV2( newChildPair); updateMatchedPairSubtrees( - DIFF_BREADCRUMB( - "Update Matched Pair Subtrees (1): " + - std::to_string(oldChildPair.shadowView.tag)), scope, mutationContainer, newRemainingPairs, oldChildPairs, - newChildPairs, parentShadowView, oldChildPair, newChildPair); @@ -1378,9 +1313,6 @@ static void calculateShadowViewMutationsV2( auto const &newChildPair = *insertedIt->second; updateMatchedPair( - DIFF_BREADCRUMB( - "Update Matched Pairs (2): " + - std::to_string(oldChildPair.shadowView.tag)), mutationContainer, true, false, @@ -1389,14 +1321,10 @@ static void calculateShadowViewMutationsV2( newChildPair); updateMatchedPairSubtrees( - DIFF_BREADCRUMB( - "Update Matched Pair Subtrees (2): " + - std::to_string(oldChildPair.shadowView.tag)), scope, mutationContainer, newRemainingPairs, oldChildPairs, - newChildPairs, parentShadowView, oldChildPair, newChildPair); @@ -1534,9 +1462,6 @@ static void calculateShadowViewMutationsV2( // entire subtree starting from the removed view. ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Non-trivial delete " + - std::to_string(oldChildPair.shadowView.tag)), innerScope, mutationContainer.destructiveDownwardMutations, oldChildPair.shadowView, @@ -1581,9 +1506,6 @@ static void calculateShadowViewMutationsV2( ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Non-trivial create " + - std::to_string(newChildPair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, newChildPair.shadowView, @@ -1707,7 +1629,6 @@ ShadowViewMutation::List calculateShadowViewMutations( } calculateShadowViewMutationsV2( - CREATE_DIFF_BREADCRUMB(oldRootShadowView.tag), innerViewNodePairScope, mutations, ShadowView(oldRootShadowNode), diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index 8dc8f97ca60..02e9b58fffe 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -20,7 +20,7 @@ namespace facebook { namespace react { -MountingCoordinator::MountingCoordinator(ShadowTreeRevision baseRevision) +MountingCoordinator::MountingCoordinator(const ShadowTreeRevision &baseRevision) : surfaceId_(baseRevision.rootShadowNode->getSurfaceId()), baseRevision_(baseRevision), telemetryController_(*this) { @@ -68,7 +68,7 @@ bool MountingCoordinator::waitForTransaction( void MountingCoordinator::updateBaseRevision( ShadowTreeRevision const &baseRevision) const { - baseRevision_ = std::move(baseRevision); + baseRevision_ = baseRevision; } void MountingCoordinator::resetLatestRevision() const { diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.h b/ReactCommon/react/renderer/mounting/MountingCoordinator.h index ba66f6a11dc..d2685185660 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.h +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.h @@ -40,7 +40,7 @@ class MountingCoordinator final { * The constructor is meant to be used only inside `ShadowTree`, and it's * `public` only to enable using with `std::make_shared<>`. */ - MountingCoordinator(ShadowTreeRevision baseRevision); + MountingCoordinator(const ShadowTreeRevision &baseRevision); /* * Returns the id of the surface that the coordinator belongs to. diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index e68b88f8529..ed69d42aa9f 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -296,8 +296,8 @@ MountingCoordinator::Shared ShadowTree::getMountingCoordinator() const { } CommitStatus ShadowTree::commit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions) const { + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions) const { SystraceSection s("ShadowTree::commit"); int attempts = 0; @@ -317,8 +317,8 @@ CommitStatus ShadowTree::commit( } CommitStatus ShadowTree::tryCommit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions) const { + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions) const { SystraceSection s("ShadowTree::tryCommit"); auto telemetry = TransactionTelemetry{}; diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.h b/ReactCommon/react/renderer/mounting/ShadowTree.h index 248ce4daa10..5951c20d1a8 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -95,15 +95,15 @@ class ShadowTree final { * The `transaction` function can cancel commit returning `nullptr`. */ CommitStatus tryCommit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions = {false}) const; + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions = {false}) const; /* * Calls `tryCommit` in a loop until it finishes successfully. */ CommitStatus commit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions = {false}) const; + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions = {false}) const; /* * Returns a `ShadowTreeRevision` representing the momentary state of diff --git a/ReactCommon/react/renderer/mounting/ShadowView.cpp b/ReactCommon/react/renderer/mounting/ShadowView.cpp index a521baf785c..7e509a7edaf 100644 --- a/ReactCommon/react/renderer/mounting/ShadowView.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowView.cpp @@ -16,8 +16,9 @@ namespace react { static LayoutMetrics layoutMetricsFromShadowNode(ShadowNode const &shadowNode) { auto layoutableShadowNode = traitCast(&shadowNode); - return layoutableShadowNode ? layoutableShadowNode->getLayoutMetrics() - : EmptyLayoutMetrics; + return layoutableShadowNode != nullptr + ? layoutableShadowNode->getLayoutMetrics() + : EmptyLayoutMetrics; } ShadowView::ShadowView(const ShadowNode &shadowNode) diff --git a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp index 53006ff347b..2960499258e 100644 --- a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp @@ -148,19 +148,19 @@ std::vector getDebugProps( ShadowViewMutation const &mutation, DebugStringConvertibleOptions options) { return { - mutation.oldChildShadowView.componentHandle + mutation.oldChildShadowView.componentHandle != 0 ? DebugStringConvertibleObject{"oldChild", getDebugDescription( mutation.oldChildShadowView, options)} : DebugStringConvertibleObject{}, - mutation.newChildShadowView.componentHandle + mutation.newChildShadowView.componentHandle != 0 ? DebugStringConvertibleObject{"newChild", getDebugDescription( mutation.newChildShadowView, options)} : DebugStringConvertibleObject{}, - mutation.parentShadowView.componentHandle + mutation.parentShadowView.componentHandle != 0 ? DebugStringConvertibleObject{"parent", getDebugDescription( mutation.parentShadowView, diff --git a/ReactCommon/react/renderer/mounting/ShadowViewMutation.h b/ReactCommon/react/renderer/mounting/ShadowViewMutation.h index 4b571bcc775..cc76e261d64 100644 --- a/ReactCommon/react/renderer/mounting/ShadowViewMutation.h +++ b/ReactCommon/react/renderer/mounting/ShadowViewMutation.h @@ -125,9 +125,9 @@ using ShadowViewMutationList = std::vector; #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(ShadowViewMutation const &object); +std::string getDebugName(ShadowViewMutation const &mutation); std::vector getDebugProps( - ShadowViewMutation const &object, + ShadowViewMutation const &mutation, DebugStringConvertibleOptions options); #endif diff --git a/ReactCommon/react/renderer/mounting/StubView.cpp b/ReactCommon/react/renderer/mounting/StubView.cpp index 0d490dc6572..5d26b18d9b1 100644 --- a/ReactCommon/react/renderer/mounting/StubView.cpp +++ b/ReactCommon/react/renderer/mounting/StubView.cpp @@ -67,7 +67,7 @@ bool operator!=(StubView const &lhs, StubView const &rhs) { std::string getDebugName(StubView const &stubView) { return std::string{"Stub"} + std::string{ - stubView.componentHandle ? stubView.componentName : "[invalid]"}; + stubView.componentHandle != 0 ? stubView.componentName : "[invalid]"}; } std::vector getDebugProps( @@ -85,7 +85,7 @@ std::vector getDebugProps( std::vector getDebugChildren( StubView const &stubView, - DebugStringConvertibleOptions options) { + DebugStringConvertibleOptions /*options*/) { std::vector result; for (auto const &child : stubView.children) { result.push_back(*child); diff --git a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp index ffa54f0dd97..67069255868 100644 --- a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp @@ -25,8 +25,8 @@ using namespace facebook::react; class DummyShadowTreeDelegate : public ShadowTreeDelegate { public: RootShadowNode::Unshared shadowTreeWillCommit( - ShadowTree const &shadowTree, - RootShadowNode::Shared const &oldRootShadowNode, + ShadowTree const & /*shadowTree*/, + RootShadowNode::Shared const & /*oldRootShadowNode*/, RootShadowNode::Unshared const &newRootShadowNode) const override { return newRootShadowNode; }; @@ -108,7 +108,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { contextContainer}; shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState1); }, {true}); @@ -133,7 +133,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { findDescendantNode(*rootShadowNodeState2, family)->getState(), state2); shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState2); }, {true}); @@ -156,7 +156,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { findDescendantNode(*rootShadowNodeState3, family)->getState(), state3); shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState3); }, {true}); @@ -171,7 +171,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { // Here we commit the old tree but we expect that the state associated with // the node will stay the same (newer that the old tree has). shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState2); }, {true}); diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp index c04d842f8e6..f1f09261a6f 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp @@ -116,7 +116,7 @@ jsi::Value RuntimeSchedulerBinding::get( jsi::Value const *, size_t) noexcept -> jsi::Value { auto shouldYield = runtimeScheduler_->getShouldYield(); - return jsi::Value(shouldYield); + return {shouldYield}; }); } @@ -148,7 +148,7 @@ jsi::Value RuntimeSchedulerBinding::get( auto asDouble = std::chrono::duration(now.time_since_epoch()) .count(); - return jsi::Value(asDouble); + return {asDouble}; }); } diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp index 7c274bcf393..934fedff375 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp @@ -52,17 +52,17 @@ class RuntimeSchedulerTest : public testing::Test { jsi::PropNameID::forUtf8(*runtime_, ""), 3, [this, callback = std::move(callback)]( - jsi::Runtime &, - jsi::Value const &, + jsi::Runtime & /*unused*/, + jsi::Value const & /*unused*/, jsi::Value const *arguments, - size_t) -> jsi::Value { + size_t /*unused*/) -> jsi::Value { ++hostFunctionCallCount_; auto didUserCallbackTimeout = arguments[0].getBool(); return callback(didUserCallbackTimeout); }); } - uint hostFunctionCallCount_; + uint hostFunctionCallCount_{}; std::unique_ptr runtime_; std::unique_ptr stubClock_; @@ -160,8 +160,8 @@ TEST_F(RuntimeSchedulerTest, taskExpiration) { TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { uint firstTaskCallOrder = 0; - auto callbackOne = - createHostFunctionFromLambda([this, &firstTaskCallOrder](bool) { + auto callbackOne = createHostFunctionFromLambda( + [this, &firstTaskCallOrder](bool /*unused*/) { firstTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -170,8 +170,8 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { SchedulerPriority::NormalPriority, std::move(callbackOne)); uint secondTaskCallOrder; - auto callbackTwo = - createHostFunctionFromLambda([this, &secondTaskCallOrder](bool) { + auto callbackTwo = createHostFunctionFromLambda( + [this, &secondTaskCallOrder](bool /*unused*/) { secondTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -193,8 +193,8 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) { uint lowPriorityTaskCallOrder = 0; - auto callbackOne = - createHostFunctionFromLambda([this, &lowPriorityTaskCallOrder](bool) { + auto callbackOne = createHostFunctionFromLambda( + [this, &lowPriorityTaskCallOrder](bool /*unused*/) { lowPriorityTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -204,7 +204,7 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) { uint userBlockingPriorityTaskCallOrder; auto callbackTwo = createHostFunctionFromLambda( - [this, &userBlockingPriorityTaskCallOrder](bool) { + [this, &userBlockingPriorityTaskCallOrder](bool /*unused*/) { userBlockingPriorityTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -226,7 +226,7 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) { TEST_F(RuntimeSchedulerTest, cancelTask) { bool didRunTask = false; - auto callback = createHostFunctionFromLambda([&didRunTask](bool) { + auto callback = createHostFunctionFromLambda([&didRunTask](bool /*unused*/) { didRunTask = true; return jsi::Value::undefined(); }); @@ -249,16 +249,16 @@ TEST_F(RuntimeSchedulerTest, continuationTask) { bool didRunTask = false; bool didContinuationTask = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunTask = true; return jsi::Function::createFromHostFunction( *runtime_, jsi::PropNameID::forUtf8(*runtime_, ""), 1, - [&](jsi::Runtime &runtime, - jsi::Value const &, - jsi::Value const *arguments, - size_t) noexcept -> jsi::Value { + [&](jsi::Runtime & /*runtime*/, + jsi::Value const & /*unused*/, + jsi::Value const * /*arguments*/, + size_t /*unused*/) noexcept -> jsi::Value { didContinuationTask = true; return jsi::Value::undefined(); }); @@ -279,7 +279,7 @@ TEST_F(RuntimeSchedulerTest, continuationTask) { TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { auto callback = - createHostFunctionFromLambda([this](bool didUserCallbackTimeout) { + createHostFunctionFromLambda([this](bool /*didUserCallbackTimeout*/) { EXPECT_EQ( runtimeScheduler_->getCurrentPriorityLevel(), SchedulerPriority::ImmediatePriority); @@ -299,12 +299,13 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { runtimeScheduler_->getCurrentPriorityLevel(), SchedulerPriority::NormalPriority); - callback = createHostFunctionFromLambda([this](bool didUserCallbackTimeout) { - EXPECT_EQ( - runtimeScheduler_->getCurrentPriorityLevel(), - SchedulerPriority::IdlePriority); - return jsi::Value::undefined(); - }); + callback = + createHostFunctionFromLambda([this](bool /*didUserCallbackTimeout*/) { + EXPECT_EQ( + runtimeScheduler_->getCurrentPriorityLevel(), + SchedulerPriority::IdlePriority); + return jsi::Value::undefined(); + }); runtimeScheduler_->scheduleTask( SchedulerPriority::IdlePriority, std::move(callback)); @@ -319,7 +320,7 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { TEST_F(RuntimeSchedulerTest, scheduleWorkWithYielding) { bool wasCalled = false; runtimeScheduler_->scheduleWork( - [&](jsi::Runtime const &) { wasCalled = true; }); + [&](jsi::Runtime const & /*unused*/) { wasCalled = true; }); EXPECT_FALSE(wasCalled); @@ -338,7 +339,7 @@ TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) { bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunJavaScriptTask = true; EXPECT_TRUE(didRunPlatformWork); return jsi::Value::undefined(); @@ -347,7 +348,7 @@ TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) { runtimeScheduler_->scheduleTask( SchedulerPriority::NormalPriority, std::move(callback)); - runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) { + runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) { didRunPlatformWork = true; EXPECT_FALSE(didRunJavaScriptTask); EXPECT_FALSE(runtimeScheduler_->getShouldYield()); @@ -365,7 +366,7 @@ TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) { bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunJavaScriptTask = true; EXPECT_FALSE(didRunPlatformWork); return jsi::Value::undefined(); @@ -374,7 +375,7 @@ TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) { runtimeScheduler_->scheduleTask( SchedulerPriority::NormalPriority, std::move(callback)); - runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) { + runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) { didRunPlatformWork = true; EXPECT_TRUE(didRunJavaScriptTask); }); @@ -393,7 +394,7 @@ TEST_F(RuntimeSchedulerTest, immediateTaskDoesntYieldToPlatformEvent) { bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunJavaScriptTask = true; EXPECT_FALSE(didRunPlatformWork); return jsi::Value::undefined(); @@ -402,7 +403,7 @@ TEST_F(RuntimeSchedulerTest, immediateTaskDoesntYieldToPlatformEvent) { runtimeScheduler_->scheduleTask( SchedulerPriority::ImmediatePriority, std::move(callback)); - runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) { + runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) { didRunPlatformWork = true; EXPECT_TRUE(didRunJavaScriptTask); }); @@ -451,11 +452,12 @@ TEST_F(RuntimeSchedulerTest, scheduleTaskFromTask) { TEST_F(RuntimeSchedulerTest, handlingError) { bool didRunTask = false; - auto firstCallback = createHostFunctionFromLambda([this, &didRunTask](bool) { - didRunTask = true; - throw jsi::JSError(*runtime_, "Test error"); - return jsi::Value::undefined(); - }); + auto firstCallback = + createHostFunctionFromLambda([this, &didRunTask](bool /*unused*/) { + didRunTask = true; + throw jsi::JSError(*runtime_, "Test error"); + return jsi::Value::undefined(); + }); runtimeScheduler_->scheduleTask( SchedulerPriority::NormalPriority, std::move(firstCallback)); @@ -474,7 +476,7 @@ TEST_F(RuntimeSchedulerTest, basicSameThreadExecution) { bool didRunSynchronousTask = false; std::thread t1([this, &didRunSynchronousTask]() { runtimeScheduler_->executeNowOnTheSameThread( - [this, &didRunSynchronousTask](jsi::Runtime &rt) { + [this, &didRunSynchronousTask](jsi::Runtime & /*rt*/) { EXPECT_TRUE(runtimeScheduler_->getIsSynchronous()); didRunSynchronousTask = true; }); @@ -584,11 +586,11 @@ TEST_F(RuntimeSchedulerTest, twoThreadsRequestAccessToTheRuntime) { bool didRunWork = false; runtimeScheduler_->scheduleWork( - [&didRunWork](jsi::Runtime &) { didRunWork = true; }); + [&didRunWork](jsi::Runtime & /*unused*/) { didRunWork = true; }); std::thread t1([this, &didRunSynchronousTask]() { runtimeScheduler_->executeNowOnTheSameThread( - [&didRunSynchronousTask](jsi::Runtime &runtime) { + [&didRunSynchronousTask](jsi::Runtime & /*runtime*/) { didRunSynchronousTask = true; }); }); diff --git a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp index 543be6cf5c7..35ec8cdb17a 100644 --- a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp @@ -23,7 +23,7 @@ AsynchronousEventBeat::AsynchronousEventBeat( void AsynchronousEventBeat::activityDidChange( RunLoopObserver::Delegate const *delegate, - RunLoopObserver::Activity) const noexcept { + RunLoopObserver::Activity /*activity*/) const noexcept { react_native_assert(delegate == this); induce(); } diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index dfacbf9c1f3..a8418c52c6e 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -68,7 +68,7 @@ Scheduler::Scheduler( runtime, eventTarget, type, priority, payloadFactory); }, runtime); - if (runtimeScheduler) { + if (runtimeScheduler != nullptr) { runtimeScheduler->callExpiredTasks(runtime); } }; @@ -295,14 +295,14 @@ void Scheduler::uiManagerDidFinishTransaction( MountingCoordinator::Shared const &mountingCoordinator) { SystraceSection s("Scheduler::uiManagerDidFinishTransaction"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidFinishTransaction(mountingCoordinator); } } void Scheduler::uiManagerDidCreateShadowNode(const ShadowNode &shadowNode) { SystraceSection s("Scheduler::uiManagerDidCreateShadowNode"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidRequestPreliminaryViewAllocation( shadowNode.getSurfaceId(), shadowNode); } @@ -313,7 +313,7 @@ void Scheduler::uiManagerDidCloneShadowNode( const ShadowNode &newShadowNode) { SystraceSection s("Scheduler::uiManagerDidCloneShadowNode"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidCloneShadowNode( newShadowNode.getSurfaceId(), oldShadowNode, newShadowNode); } @@ -325,7 +325,7 @@ void Scheduler::uiManagerDidDispatchCommand( folly::dynamic const &args) { SystraceSection s("Scheduler::uiManagerDispatchCommand"); - if (delegate_) { + if (delegate_ != nullptr) { auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidDispatchCommand(shadowView, commandName, args); } @@ -336,7 +336,7 @@ void Scheduler::uiManagerDidSendAccessibilityEvent( std::string const &eventType) { SystraceSection s("Scheduler::uiManagerDidSendAccessibilityEvent"); - if (delegate_) { + if (delegate_ != nullptr) { auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidSendAccessibilityEvent(shadowView, eventType); } @@ -349,7 +349,7 @@ void Scheduler::uiManagerDidSetIsJSResponder( ShadowNode::Shared const &shadowNode, bool isJSResponder, bool blockNativeResponder) { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidSetIsJSResponder( ShadowView(*shadowNode), isJSResponder, blockNativeResponder); } diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index 626572a073f..eaba25e16f4 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -101,7 +101,7 @@ class Scheduler final : public UIManagerDelegate { const ShadowNode::Shared &shadowNode, std::string const &eventType) override; void uiManagerDidSetIsJSResponder( - ShadowNode::Shared const &shadowView, + ShadowNode::Shared const &shadowNode, bool isJSResponder, bool blockNativeResponder) override; diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp index b68e2f617a1..f8753a6ec37 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp @@ -283,10 +283,12 @@ void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept { link_.shadowTree->setCommitMode(ShadowTree::CommitMode::Suspended); // Committing the current revision back. It will be mounted only when // `DisplayMode` is changed back to `Normal`. - link_.shadowTree->commit([&](RootShadowNode const &oldRootShadowNode) { - return std::static_pointer_cast( - revision.rootShadowNode->ShadowNode::clone(ShadowNodeFragment{})); - }); + link_.shadowTree->commit( + [&](RootShadowNode const & /*oldRootShadowNode*/) { + return std::static_pointer_cast( + revision.rootShadowNode->ShadowNode::clone( + ShadowNodeFragment{})); + }); break; } } @@ -302,7 +304,8 @@ void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept { } link_.uiManager = uiManager; - link_.status = uiManager ? Status::Registered : Status::Unregistered; + link_.status = + uiManager != nullptr ? Status::Registered : Status::Unregistered; } SurfaceHandler::~SurfaceHandler() noexcept { diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h index babf534da3a..f550e709f59 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h @@ -67,7 +67,7 @@ class SurfaceHandler { /* * Movable-only. */ - SurfaceHandler(SurfaceHandler &&SurfaceHandler) noexcept; + SurfaceHandler(SurfaceHandler &&other) noexcept; SurfaceHandler(SurfaceHandler const &SurfaceHandler) noexcept = delete; SurfaceHandler &operator=(SurfaceHandler &&other) noexcept; SurfaceHandler &operator=(SurfaceHandler const &other) noexcept = delete; diff --git a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp index fc9a406629c..f100463329d 100644 --- a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp @@ -28,7 +28,7 @@ SynchronousEventBeat::SynchronousEventBeat( void SynchronousEventBeat::activityDidChange( RunLoopObserver::Delegate const *delegate, - RunLoopObserver::Activity activity) const noexcept { + RunLoopObserver::Activity /*activity*/) const noexcept { react_native_assert(delegate == this); lockExecutorAndBeat(); } diff --git a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h index a95339e58b9..81416defac2 100644 --- a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h +++ b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h @@ -46,7 +46,7 @@ class UITemplateProcessor { public: static ShadowNode::Shared buildShadowTree( const std::string &jsonStr, - int rootTag, + int surfaceId, const folly::dynamic ¶ms, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, @@ -55,7 +55,7 @@ class UITemplateProcessor { private: static ShadowNode::Shared runCommand( const folly::dynamic &command, - Tag rootTag, + Tag surfaceId, std::vector &nodes, std::vector ®isters, const ComponentDescriptorRegistry &componentDescriptorRegistry, diff --git a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp index fc672ef606b..70fa3e85e01 100644 --- a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp +++ b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp @@ -48,7 +48,8 @@ NativeModuleRegistry buildNativeModuleRegistry(); NativeModuleRegistry buildNativeModuleRegistry() { NativeModuleRegistry nMR; nMR.registerModule( - "MobileConfig", [&](const std::string &, const folly::dynamic &) { + "MobileConfig", + [&](const std::string & /*unused*/, const folly::dynamic & /*unused*/) { return mockSimpleTestValue_; }); return nMR; @@ -57,19 +58,19 @@ NativeModuleRegistry buildNativeModuleRegistry() { class MockReactNativeConfig : public ReactNativeConfig { public: MockReactNativeConfig() = default; - bool getBool(const std::string ¶m) const override { + bool getBool(const std::string & /*param*/) const override { return mockSimpleTestValue_; } - std::string getString(const std::string &) const override { + std::string getString(const std::string & /*param*/) const override { return ""; } - int64_t getInt64(const std::string &) const override { + int64_t getInt64(const std::string & /*param*/) const override { return 0; } - double getDouble(const std::string &) const override { + double getDouble(const std::string & /*param*/) const override { return 0.0; } }; diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index c4c5bfce9b1..a8ca135e579 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -166,9 +166,9 @@ TextMeasurement TextLayoutManager::measure( auto measurement = measureCache_.get( {attributedString, paragraphAttributes, layoutConstraints}, - [&](TextMeasureCacheKey const &key) { + [&](TextMeasureCacheKey const & /*key*/) { auto telemetry = TransactionTelemetry::threadLocalTelemetry(); - if (telemetry) { + if (telemetry != nullptr) { telemetry->willMeasureText(); } @@ -178,7 +178,7 @@ TextMeasurement TextLayoutManager::measure( : doMeasure( attributedString, paragraphAttributes, layoutConstraints); - if (telemetry) { + if (telemetry != nullptr) { telemetry->didMeasureText(); } diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h index ad3483b3eb8..711e617fc72 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h @@ -88,7 +88,7 @@ class TextLayoutManager { ParagraphAttributes const ¶graphAttributes, Size size) const; - void *self_; + void *self_{}; ContextContainer::Shared contextContainer_; bool mapBufferSerializationEnabled_; TextMeasureCache measureCache_; diff --git a/ReactCommon/react/renderer/timeline/Timeline.cpp b/ReactCommon/react/renderer/timeline/Timeline.cpp index ea569370e8d..e8377f8efb3 100644 --- a/ReactCommon/react/renderer/timeline/Timeline.cpp +++ b/ReactCommon/react/renderer/timeline/Timeline.cpp @@ -31,7 +31,7 @@ void Timeline::pause() const noexcept { void Timeline::resume() const noexcept { std::lock_guard lock(mutex_); - if (snapshots_.size() > 0) { + if (!snapshots_.empty()) { rewind(snapshots_.at(snapshots_.size() - 1)); } @@ -66,8 +66,8 @@ void Timeline::rewind(TimelineFrame const &frame) const noexcept { } RootShadowNode::Unshared Timeline::shadowTreeWillCommit( - ShadowTree const &shadowTree, - RootShadowNode::Shared const &oldRootShadowNode, + ShadowTree const & /*shadowTree*/, + RootShadowNode::Shared const & /*oldRootShadowNode*/, RootShadowNode::Unshared const &newRootShadowNode) const noexcept { std::lock_guard lock(mutex_); @@ -107,7 +107,8 @@ void Timeline::rewind(TimelineSnapshot const &snapshot) const noexcept { auto rootShadowNode = snapshot.getRootShadowNode(); shadowTree_->commit( - [&](RootShadowNode const &oldRootShadowNode) -> RootShadowNode::Unshared { + [&](RootShadowNode const & /*oldRootShadowNode*/) + -> RootShadowNode::Unshared { return std::static_pointer_cast( rootShadowNode->ShadowNode::clone({})); }); diff --git a/ReactCommon/react/renderer/timeline/TimelineController.cpp b/ReactCommon/react/renderer/timeline/TimelineController.cpp index 01e716741f7..accbcb7b15e 100644 --- a/ReactCommon/react/renderer/timeline/TimelineController.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineController.cpp @@ -49,7 +49,7 @@ void TimelineController::commitHookWasRegistered( } void TimelineController::commitHookWasUnregistered( - UIManager const &uiManager) const noexcept { + UIManager const & /*uiManager*/) const noexcept { uiManager_ = nullptr; } diff --git a/ReactCommon/react/renderer/timeline/TimelineHandler.cpp b/ReactCommon/react/renderer/timeline/TimelineHandler.cpp index 3deef099f73..7b8dcecb38c 100644 --- a/ReactCommon/react/renderer/timeline/TimelineHandler.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineHandler.cpp @@ -88,7 +88,7 @@ void TimelineHandler::release() noexcept { } void TimelineHandler::ensureNotEmpty() const noexcept { - if (!timeline_) { + if (timeline_ == nullptr) { abort(); } } diff --git a/ReactCommon/react/renderer/timeline/TimelineHandler.h b/ReactCommon/react/renderer/timeline/TimelineHandler.h index 61fa45f3ce8..3615d76eba7 100644 --- a/ReactCommon/react/renderer/timeline/TimelineHandler.h +++ b/ReactCommon/react/renderer/timeline/TimelineHandler.h @@ -23,7 +23,7 @@ class TimelineHandler final { /* * Movable, not copyable. */ - TimelineHandler(TimelineHandler &&timelineHandler) noexcept; + TimelineHandler(TimelineHandler &&other) noexcept; TimelineHandler(TimelineHandler const &timelineHandler) = delete; TimelineHandler &operator=(TimelineHandler &&other) noexcept; TimelineHandler &operator=(TimelineHandler const &other) = delete; @@ -73,7 +73,7 @@ class TimelineHandler final { void ensureNotEmpty() const noexcept; - Timeline const *timeline_; + Timeline const *timeline_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index cd2d3267daf..3e7b912e7b7 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -90,7 +90,7 @@ ShadowNode::Shared UIManager::createNode( }, family); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidCreateShadowNode(*shadowNode); } if (leakChecker_) { @@ -114,13 +114,14 @@ ShadowNode::Shared UIManager::cloneNode( shadowNode, { /* .props = */ - rawProps ? componentDescriptor.cloneProps( - propsParserContext, shadowNode.getProps(), *rawProps) - : ShadowNodeFragment::propsPlaceholder(), + rawProps != nullptr + ? componentDescriptor.cloneProps( + propsParserContext, shadowNode.getProps(), *rawProps) + : ShadowNodeFragment::propsPlaceholder(), /* .children = */ children, }); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidCloneShadowNode(shadowNode, *clonedShadowNode); } @@ -160,7 +161,7 @@ void UIManager::setIsJSResponder( ShadowNode::Shared const &shadowNode, bool isJSResponder, bool blockNativeResponder) const { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidSetIsJSResponder( shadowNode, isJSResponder, blockNativeResponder); } @@ -260,7 +261,7 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics( // that the node is not deallocated during method execution lifetime. auto owningAncestorShadowNode = ShadowNode::Shared{}; - if (!ancestorShadowNode) { + if (ancestorShadowNode == nullptr) { shadowTreeRegistry_.visit( shadowNode.getSurfaceId(), [&](ShadowTree const &shadowTree) { owningAncestorShadowNode = @@ -278,7 +279,7 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics( auto layoutableAncestorShadowNode = traitCast(ancestorShadowNode); - if (!layoutableAncestorShadowNode) { + if (layoutableAncestorShadowNode == nullptr) { return EmptyLayoutMetrics; } @@ -328,7 +329,7 @@ void UIManager::dispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, folly::dynamic const &args) const { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args); } } @@ -336,7 +337,7 @@ void UIManager::dispatchCommand( void UIManager::sendAccessibilityEvent( const ShadowNode::Shared &shadowNode, std::string const &eventType) { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidSendAccessibilityEvent(shadowNode, eventType); } } @@ -346,7 +347,7 @@ void UIManager::configureNextLayoutAnimation( RawValue const &config, jsi::Value const &successCallback, jsi::Value const &failureCallback) const { - if (animationDelegate_) { + if (animationDelegate_ != nullptr) { animationDelegate_->uiManagerDidConfigureNextLayoutAnimation( runtime, config, @@ -420,11 +421,11 @@ RootShadowNode::Unshared UIManager::shadowTreeWillCommit( } void UIManager::shadowTreeDidFinishTransaction( - ShadowTree const &shadowTree, + ShadowTree const & /*shadowTree*/, MountingCoordinator::Shared const &mountingCoordinator) const { SystraceSection s("UIManager::shadowTreeDidFinishTransaction"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidFinishTransaction(mountingCoordinator); } } diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index a30a594becf..e0ba886c972 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -184,7 +184,7 @@ class UIManager final : public ShadowTreeDelegate { jsi::Value const &failureCallback) const; SharedComponentDescriptorRegistry componentDescriptorRegistry_; - UIManagerDelegate *delegate_; + UIManagerDelegate *delegate_{}; UIManagerAnimationDelegate *animationDelegate_{nullptr}; RuntimeExecutor const runtimeExecutor_{}; ShadowTreeRegistry shadowTreeRegistry_{}; diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 9393ba512f6..e1ac1399850 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -107,7 +107,7 @@ void UIManagerBinding::dispatchEvent( return; } - auto instanceHandle = eventTarget + auto instanceHandle = eventTarget != nullptr ? [&]() { auto instanceHandle = eventTarget->getInstanceHandle(runtime); if (instanceHandle.isUndefined()) { @@ -187,9 +187,9 @@ jsi::Value UIManagerBinding::get( 5, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto eventTarget = eventTargetFromValue(runtime, arguments[4], arguments[0]); if (!eventTarget) { @@ -215,9 +215,9 @@ jsi::Value UIManagerBinding::get( 1, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { return valueFromShadowNode( runtime, uiManager->cloneNode( @@ -232,9 +232,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->setIsJSResponder( shadowNodeFromValue(runtime, arguments[0]), arguments[1].getBool(), @@ -251,9 +251,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto node = shadowNodeFromValue(runtime, arguments[0]); auto locationX = (Float)arguments[1].getNumber(); auto locationY = (Float)arguments[2].getNumber(); @@ -282,9 +282,9 @@ jsi::Value UIManagerBinding::get( 1, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { return valueFromShadowNode( runtime, uiManager->cloneNode( @@ -301,9 +301,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto const &rawProps = RawProps(runtime, arguments[1]); return valueFromShadowNode( runtime, @@ -322,9 +322,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto const &rawProps = RawProps(runtime, arguments[1]); return valueFromShadowNode( runtime, @@ -342,9 +342,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->appendChild( shadowNodeFromValue(runtime, arguments[0]), shadowNodeFromValue(runtime, arguments[1])); @@ -358,9 +358,9 @@ jsi::Value UIManagerBinding::get( name, 1, [](jsi::Runtime &runtime, - jsi::Value const &thisValue, - jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + jsi::Value const & /*thisValue*/, + jsi::Value const * /*arguments*/, + size_t /*count*/) noexcept -> jsi::Value { auto shadowNodeList = std::make_shared( ShadowNode::ListOfShared({})); return valueFromShadowNodeList(runtime, shadowNodeList); @@ -373,9 +373,9 @@ jsi::Value UIManagerBinding::get( name, 2, [](jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto shadowNodeList = shadowNodeListFromValue(runtime, arguments[0]); auto shadowNode = shadowNodeFromValue(runtime, arguments[1]); shadowNodeList->push_back(shadowNode); @@ -393,9 +393,9 @@ jsi::Value UIManagerBinding::get( 2, [weakUIManager, uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto runtimeSchedulerBinding = RuntimeSchedulerBinding::getBinding(runtime); auto surfaceId = surfaceIdFromValue(runtime, arguments[0]); @@ -449,9 +449,9 @@ jsi::Value UIManagerBinding::get( 1, [this]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto eventHandler = arguments[0].getObject(runtime).getFunction(runtime); eventHandler_ = @@ -467,9 +467,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNodeFromValue(runtime, arguments[0]), shadowNodeFromValue(runtime, arguments[1]).get(), @@ -491,9 +491,9 @@ jsi::Value UIManagerBinding::get( 3, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); if (shadowNode) { uiManager->dispatchCommand( @@ -513,9 +513,9 @@ jsi::Value UIManagerBinding::get( 4, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNodeFromValue(runtime, arguments[0]), shadowNodeFromValue(runtime, arguments[1]).get(), @@ -549,9 +549,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNode, nullptr, {/* .includeTransform = */ true}); @@ -567,7 +567,7 @@ jsi::Value UIManagerBinding::get( auto layoutableShadowNode = traitCast( newestCloneOfShadowNode.get()); - Point originRelativeToParent = layoutableShadowNode + Point originRelativeToParent = layoutableShadowNode != nullptr ? layoutableShadowNode->getLayoutMetrics().frame.origin : Point(); @@ -591,9 +591,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNodeFromValue(runtime, arguments[0]), nullptr, @@ -626,9 +626,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->sendAccessibilityEvent( shadowNodeFromValue(runtime, arguments[0]), stringFromValue(runtime, arguments[1])); @@ -644,9 +644,9 @@ jsi::Value UIManagerBinding::get( 3, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->configureNextLayoutAnimation( runtime, // TODO: pass in JSI value instead of folly::dynamic to RawValue @@ -667,16 +667,16 @@ jsi::Value UIManagerBinding::get( jsi::Value const &, jsi::Value const *, size_t) noexcept -> jsi::Value { - return jsi::Value(serialize(currentEventPriority_)); + return {serialize(currentEventPriority_)}; }); } if (methodName == "unstable_DefaultEventPriority") { - return jsi::Value(serialize(ReactEventPriority::Default)); + return {serialize(ReactEventPriority::Default)}; } if (methodName == "unstable_DiscreteEventPriority") { - return jsi::Value(serialize(ReactEventPriority::Discrete)); + return {serialize(ReactEventPriority::Discrete)}; } return jsi::Value::undefined();