diff --git a/packages/react-native/React/CxxBridge/RCTMessageThread.mm b/packages/react-native/React/CxxBridge/RCTMessageThread.mm index d234aaaa8cf..d337150289a 100644 --- a/packages/react-native/React/CxxBridge/RCTMessageThread.mm +++ b/packages/react-native/React/CxxBridge/RCTMessageThread.mm @@ -66,7 +66,7 @@ void RCTMessageThread::runSync(std::function func) void RCTMessageThread::tryFunc(const std::function &func) { NSError *error = tryAndReturnError(func); - if (error) { + if (error != nullptr) { m_errorBlock(error); } } diff --git a/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm b/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm index 94976166fa9..15afcb68a0a 100644 --- a/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm +++ b/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm @@ -41,7 +41,7 @@ class RCTObjcExecutor : public JSExecutor { : m_jse(jse), m_errorBlock(errorBlock), m_delegate(std::move(delegate)), m_jsThread(std::move(jsThread)) { m_jsCallback = ^(id json, NSError *error) { - if (error) { + if (error != nullptr) { // Do not use "m_errorBlock" here as the bridge might be in the middle // of invalidation as a result of error handling and "this" can be // already deallocated. @@ -81,7 +81,7 @@ class RCTObjcExecutor : public JSExecutor { onComplete:^(NSError *error) { RCTProfileEndFlowEvent(); - if (error) { + if (error != nullptr) { m_errorBlock(error); return; } diff --git a/packages/react-native/React/CxxModule/RCTCxxMethod.mm b/packages/react-native/React/CxxModule/RCTCxxMethod.mm index c87f79dffb9..f823e7d7880 100644 --- a/packages/react-native/React/CxxModule/RCTCxxMethod.mm +++ b/packages/react-native/React/CxxModule/RCTCxxMethod.mm @@ -26,7 +26,7 @@ using namespace facebook::react; - (instancetype)initWithCxxMethod:(const CxxModule::Method &)method { - if ((self = [super init])) { + if ((self = [super init]) != nullptr) { _method = std::make_unique(method); } return self; diff --git a/packages/react-native/React/CxxModule/RCTNativeModule.mm b/packages/react-native/React/CxxModule/RCTNativeModule.mm index 6150f31bf0c..b0f45eb1588 100644 --- a/packages/react-native/React/CxxModule/RCTNativeModule.mm +++ b/packages/react-native/React/CxxModule/RCTNativeModule.mm @@ -76,7 +76,7 @@ folly::dynamic RCTNativeModule::getConstants() void RCTNativeModule::invoke(unsigned int methodId, folly::dynamic &¶ms, int callId) { id method = m_moduleData.methods[methodId]; - if (method) { + if (method != nullptr) { RCT_PROFILE_BEGIN_EVENT( RCTProfileTagAlways, @"[RCTNativeModule invoke]", @@ -119,13 +119,13 @@ void RCTNativeModule::invoke(unsigned int methodId, folly::dynamic &¶ms, int if (isSyncModule) { block(); BridgeNativeModulePerfLogger::syncMethodCallReturnConversionEnd(moduleName, methodName); - } else if (queue) { + } else if (queue != nullptr) { BridgeNativeModulePerfLogger::asyncMethodCallDispatch(moduleName, methodName); dispatch_async(queue, block); } #ifdef RCT_DEV - if (!queue) { + if (queue == nullptr) { RCTLog( @"Attempted to invoke `%u` (method ID) on `%@` (NativeModule name) without a method queue.", methodId, @@ -153,7 +153,7 @@ static MethodCallResult invokeInner( int callId, SchedulingContext context) { - if (!bridge || !bridge.valid || !moduleData) { + if ((bridge == nullptr) || !bridge.valid || (moduleData == nullptr)) { if (context == Sync) { /** * NOTE: moduleName and methodName are "". This shouldn't be an issue because there can only be one ongoing sync @@ -166,7 +166,7 @@ static MethodCallResult invokeInner( } id method = moduleData.methods[methodId]; - if (RCT_DEBUG && !method) { + if (RCT_DEBUG && (method == nullptr)) { RCTLogError(@"Unknown methodID: %ud for module: %@", methodId, moduleData.name); } diff --git a/packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm b/packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm index a9aedcaddf8..9230dd3b332 100644 --- a/packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm +++ b/packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm @@ -24,14 +24,14 @@ static NSString *getServerHost(NSURL *bundleURL) { NSNumber *port = @8081; NSString *portStr = [[[NSProcessInfo processInfo] environment] objectForKey:@"RCT_METRO_PORT"]; - if (portStr && [portStr length] > 0) { + if ((portStr != nullptr) && [portStr length] > 0) { port = [NSNumber numberWithInt:[portStr intValue]]; } - if ([bundleURL port]) { + if ([bundleURL port] != nullptr) { port = [bundleURL port]; } NSString *host = [bundleURL host]; - if (!host) { + if (host == nullptr) { host = @"localhost"; } @@ -186,7 +186,7 @@ static void sendEventToAllConnections(NSString *event) NSString *key = [inspectorURL absoluteString]; id connection = socketConnections[key]; - if (!connection || !connection.isConnected) { + if ((connection == nullptr) || !connection.isConnected) { connection = [[RCTCxxInspectorPackagerConnection alloc] initWithURL:inspectorURL]; socketConnections[key] = connection; diff --git a/packages/react-native/React/DevSupport/RCTInspectorNetworkHelper.mm b/packages/react-native/React/DevSupport/RCTInspectorNetworkHelper.mm index 53e8fde774e..8e775d3185d 100644 --- a/packages/react-native/React/DevSupport/RCTInspectorNetworkHelper.mm +++ b/packages/react-native/React/DevSupport/RCTInspectorNetworkHelper.mm @@ -21,7 +21,7 @@ using ListenerBlock = void (^)(RCTInspectorNetworkListener *); - (instancetype)init { self = [super init]; - if (self) { + if (self != nullptr) { NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; self.session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil]; self.executorsByTaskId = [NSMutableDictionary new]; @@ -63,7 +63,7 @@ using ListenerBlock = void (^)(RCTInspectorNetworkListener *); - (void)withListenerForTask:(NSURLSessionTask *)task execute:(ListenerBlock)block { void (^executor)(ListenerBlock) = self.executorsByTaskId[@(task.taskIdentifier)]; - if (executor) { + if (executor != nullptr) { executor(block); } } diff --git a/packages/react-native/React/DevSupport/RCTPausedInDebuggerOverlayController.mm b/packages/react-native/React/DevSupport/RCTPausedInDebuggerOverlayController.mm index 32697c942ee..9237213bcf3 100644 --- a/packages/react-native/React/DevSupport/RCTPausedInDebuggerOverlayController.mm +++ b/packages/react-native/React/DevSupport/RCTPausedInDebuggerOverlayController.mm @@ -103,7 +103,7 @@ if (_alertWindow == nil) { _alertWindow = [[UIWindow alloc] initWithWindowScene:RCTKeyWindow().windowScene]; - if (_alertWindow) { + if (_alertWindow != nullptr) { _alertWindow.rootViewController = [UIViewController new]; _alertWindow.windowLevel = UIWindowLevelAlert + 1; } diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm index eb100a437d5..16b71e4d64e 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm @@ -17,7 +17,7 @@ - (instancetype)init { - if (!(self = [super init])) { + if ((self = [super init]) == nullptr) { return nil; } _touchHandler = [RCTSurfaceTouchHandler new]; @@ -61,7 +61,7 @@ { UIInterfaceOrientationMask appSupportedOrientationsMask = [RCTSharedApplication() supportedInterfaceOrientationsForWindow:RCTKeyWindow()]; - if (!(_supportedInterfaceOrientations & appSupportedOrientationsMask)) { + if ((_supportedInterfaceOrientations & appSupportedOrientationsMask) == 0u) { RCTLogError( @"Modal was presented with 0x%x orientations mask but the application only supports 0x%x." @"Add more interface orientations to your app's Info.plist to fix this."