diff --git a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTAnimatedNode.mm b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTAnimatedNode.mm index c17f29fd447..b858f019093 100644 --- a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTAnimatedNode.mm +++ b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTAnimatedNode.mm @@ -16,7 +16,7 @@ - (instancetype)initWithTag:(NSNumber *)tag config:(NSDictionary *)config { - if ((self = [super init])) { + if ((self = [super init]) != nullptr) { _nodeTag = tag; _config = [config copy]; } @@ -37,10 +37,10 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init) - (void)addChild:(RCTAnimatedNode *)child { - if (!_childNodes) { + if (_childNodes == nullptr) { _childNodes = [NSMapTable strongToWeakObjectsMapTable]; } - if (child) { + if (child != nullptr) { [_childNodes setObject:child forKey:child.nodeTag]; [child onAttachedToNode:self]; } @@ -48,10 +48,10 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init) - (void)removeChild:(RCTAnimatedNode *)child { - if (!_childNodes) { + if (_childNodes == nullptr) { return; } - if (child) { + if (child != nullptr) { [_childNodes removeObjectForKey:child.nodeTag]; [child onDetachedFromNode:self]; } @@ -59,20 +59,20 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init) - (void)onAttachedToNode:(RCTAnimatedNode *)parent { - if (!_parentNodes) { + if (_parentNodes == nullptr) { _parentNodes = [NSMapTable strongToWeakObjectsMapTable]; } - if (parent) { + if (parent != nullptr) { [_parentNodes setObject:parent forKey:parent.nodeTag]; } } - (void)onDetachedFromNode:(RCTAnimatedNode *)parent { - if (!_parentNodes) { + if (_parentNodes == nullptr) { return; } - if (parent) { + if (parent != nullptr) { [_parentNodes removeObjectForKey:parent.nodeTag]; } } diff --git a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTInterpolationAnimatedNode.mm b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTInterpolationAnimatedNode.mm index 45846b8471c..b45410f9c0c 100644 --- a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTInterpolationAnimatedNode.mm +++ b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTInterpolationAnimatedNode.mm @@ -86,7 +86,7 @@ NSString *RCTInterpolateString( - (instancetype)initWithTag:(NSNumber *)tag config:(NSDictionary *)config { - if ((self = [super initWithTag:tag config:config])) { + if ((self = [super initWithTag:tag config:config]) != nullptr) { _inputRange = config[@"inputRange"]; NSArray *outputRangeConfig = config[@"outputRange"]; @@ -104,7 +104,7 @@ NSString *RCTInterpolateString( switch (_outputType) { case RCTInterpolationOutputColor: { UIColor *color = [RCTConvert UIColor:value]; - [outputRange addObject:color ? color : [UIColor whiteColor]]; + [outputRange addObject:(color != nullptr) ? color : [UIColor whiteColor]]; break; } case RCTInterpolationOutputString: @@ -141,7 +141,7 @@ NSString *RCTInterpolateString( - (void)performUpdate { [super performUpdate]; - if (!_parentNode) { + if (_parentNode == nullptr) { return; } diff --git a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTObjectAnimatedNode.mm b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTObjectAnimatedNode.mm index 81b9ef37a8b..1c5d83bc030 100644 --- a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTObjectAnimatedNode.mm +++ b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTObjectAnimatedNode.mm @@ -48,7 +48,7 @@ NSString *const NODE_TAG_KEY = @"nodeTag"; if ([value isKindOfClass:[NSDictionary class]]) { NSDictionary *dict = (NSDictionary *)value; id nodeTag = [dict objectForKey:NODE_TAG_KEY]; - if (nodeTag && [nodeTag isKindOfClass:[NSNumber class]]) { + if ((nodeTag != nullptr) && [nodeTag isKindOfClass:[NSNumber class]]) { RCTAnimatedNode *node = [self.parentNodes objectForKey:(NSNumber *)nodeTag]; if ([node isKindOfClass:[RCTValueAnimatedNode class]]) { RCTValueAnimatedNode *valueNode = (RCTValueAnimatedNode *)node; diff --git a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTStyleAnimatedNode.mm b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTStyleAnimatedNode.mm index 7673db6323e..8be4e22bb0b 100644 --- a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTStyleAnimatedNode.mm +++ b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTStyleAnimatedNode.mm @@ -18,7 +18,7 @@ - (instancetype)initWithTag:(NSNumber *)tag config:(NSDictionary *)config { - if ((self = [super initWithTag:tag config:config])) { + if ((self = [super initWithTag:tag config:config]) != nullptr) { _propsDictionary = [NSMutableDictionary new]; } return self; @@ -36,11 +36,11 @@ NSDictionary *style = self.config[@"style"]; [style enumerateKeysAndObjectsUsingBlock:^(NSString *property, NSNumber *nodeTag, __unused BOOL *stop) { RCTAnimatedNode *node = [self.parentNodes objectForKey:nodeTag]; - if (node) { + if (node != nullptr) { if ([node isKindOfClass:[RCTValueAnimatedNode class]]) { RCTValueAnimatedNode *valueAnimatedNode = (RCTValueAnimatedNode *)node; id animatedObject = valueAnimatedNode.animatedObject; - if (animatedObject) { + if (animatedObject != nullptr) { _propsDictionary[property] = animatedObject; } else { _propsDictionary[property] = @(valueAnimatedNode.value); diff --git a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.mm b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.mm index 85d208680f3..900a23d9071 100644 --- a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.mm +++ b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.mm @@ -18,7 +18,7 @@ - (instancetype)initWithTag:(NSNumber *)tag config:(NSDictionary *)config { - if ((self = [super initWithTag:tag config:config])) { + if ((self = [super initWithTag:tag config:config]) != nullptr) { _animationId = config[@"animationId"]; _toValueNodeTag = config[@"toValue"]; _valueNodeTag = config[@"value"]; diff --git a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTransformAnimatedNode.mm b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTransformAnimatedNode.mm index 8c58d6d33ca..a0dcef13761 100644 --- a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTransformAnimatedNode.mm +++ b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTTransformAnimatedNode.mm @@ -14,7 +14,7 @@ - (instancetype)initWithTag:(NSNumber *)tag config:(NSDictionary *)config { - if ((self = [super initWithTag:tag config:config])) { + if ((self = [super initWithTag:tag config:config]) != nullptr) { _propsDictionary = [NSMutableDictionary new]; } return self; diff --git a/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.mm b/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.mm index 206fdd26f85..11146ca1f23 100644 --- a/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.mm +++ b/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.mm @@ -59,7 +59,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) - (instancetype)initWithBridge:(nullable RCTBridge *)bridge surfacePresenter:(id)surfacePresenter { - if ((self = [super init])) { + if ((self = [super init]) != nullptr) { _bridge = bridge; _surfacePresenter = surfacePresenter; _animationNodes = [NSMutableDictionary new]; @@ -72,7 +72,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) - (BOOL)isNodeManagedByFabric:(NSNumber *)tag { RCTAnimatedNode *node = _animationNodes[tag]; - if (node) { + if (node != nullptr) { return [node isManagedByFabric]; } return false; @@ -106,7 +106,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) NSString *nodeType = [RCTConvert NSString:config[@"type"]]; Class nodeClass = map[nodeType]; - if (!nodeClass) { + if (nodeClass == nullptr) { RCTLogError(@"Animated node type %@ not supported natively", nodeType); return; } @@ -187,7 +187,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) - (void)dropAnimatedNode:(NSNumber *)tag { RCTAnimatedNode *node = _animationNodes[tag]; - if (node) { + if (node != nullptr) { [node detachNode]; [_animationNodes removeObjectForKey:tag]; } @@ -345,7 +345,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) NSNumber *nodeTag = [RCTConvert NSNumber:eventMapping[@"animatedValueTag"]]; RCTAnimatedNode *node = _animationNodes[nodeTag]; - if (!node) { + if (node == nullptr) { RCTLogError(@"Animated node with tag %@ does not exist", nodeTag); return; } @@ -407,7 +407,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) NSString *key = [NSString stringWithFormat:@"%@%@", event.viewTag, RCTNormalizeAnimatedEventName(event.eventName)]; NSMutableArray *driversForKey = _eventDrivers[key]; - if (driversForKey) { + if (driversForKey != nullptr) { for (RCTEventAnimation *driver in driversForKey) { [self stopAnimationsForNode:driver.valueNode]; [driver updateWithEvent:event]; @@ -439,7 +439,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) - (void)startAnimationLoopIfNeeded { - if (!_displayLink && _activeAnimations.count > 0) { + if ((_displayLink == nullptr) && _activeAnimations.count > 0) { _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(stepAnimations:)]; [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; } @@ -454,7 +454,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) - (void)stopAnimationLoop { - if (_displayLink) { + if (_displayLink != nullptr) { [_displayLink invalidate]; _displayLink = nil; } @@ -486,7 +486,7 @@ static NSString *RCTNormalizeAnimatedEventName(NSString *eventName) NSArray *eventAnimations = _eventDrivers[key]; for (RCTEventAnimation *animation in eventAnimations) { NSNumber *nodeTag = [animation.valueNode nodeTag]; - if (nodeTag) { + if (nodeTag != nullptr) { [tags addObject:nodeTag]; } for (NSNumber *childNodeKey in [animation.valueNode childNodes]) { diff --git a/packages/react-native/Libraries/Network/RCTDataRequestHandler.mm b/packages/react-native/Libraries/Network/RCTDataRequestHandler.mm index c91f89e22bd..d52f6ba8ad6 100644 --- a/packages/react-native/Libraries/Network/RCTDataRequestHandler.mm +++ b/packages/react-native/Libraries/Network/RCTDataRequestHandler.mm @@ -25,7 +25,7 @@ RCT_EXPORT_MODULE() - (void)invalidate { std::lock_guard lock(_operationHandlerMutexLock); - if (_queue) { + if (_queue != nullptr) { for (NSOperation *operation in _queue.operations) { if (!operation.isCancelled && !operation.isFinished) { [operation cancel]; @@ -44,7 +44,7 @@ RCT_EXPORT_MODULE() { std::lock_guard lock(_operationHandlerMutexLock); // Lazy setup - if (!_queue) { + if (_queue == nullptr) { _queue = [NSOperationQueue new]; _queue.maxConcurrentOperationCount = 2; } @@ -59,7 +59,7 @@ RCT_EXPORT_MODULE() // Get mime type NSRange firstSemicolon = [request.URL.resourceSpecifier rangeOfString:@";"]; NSString *mimeType = - firstSemicolon.length ? [request.URL.resourceSpecifier substringToIndex:firstSemicolon.location] : nil; + (firstSemicolon.length != 0u) ? [request.URL.resourceSpecifier substringToIndex:firstSemicolon.location] : nil; // Send response NSURLResponse *response = [[NSURLResponse alloc] initWithURL:request.URL @@ -72,7 +72,7 @@ RCT_EXPORT_MODULE() // Load data NSError *error; NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error]; - if (data) { + if (data != nullptr) { [delegate URLRequest:strongOp didReceiveData:data]; } [delegate URLRequest:strongOp didCompleteWithError:error]; diff --git a/packages/react-native/Libraries/Network/RCTHTTPRequestHandler.mm b/packages/react-native/Libraries/Network/RCTHTTPRequestHandler.mm index 8f21bf3e284..0303970a2e4 100644 --- a/packages/react-native/Libraries/Network/RCTHTTPRequestHandler.mm +++ b/packages/react-native/Libraries/Network/RCTHTTPRequestHandler.mm @@ -46,7 +46,7 @@ RCT_EXPORT_MODULE() - (BOOL)isValid { // if session == nil and delegates != nil, we've been invalidated - return _session || !_delegates; + return (_session != nullptr) || (_delegates == nullptr); } #pragma mark - NSURLRequestHandler @@ -67,7 +67,7 @@ RCT_EXPORT_MODULE() { std::lock_guard lock(_mutex); // Lazy setup - if (!_session && [self isValid]) { + if ((_session == nullptr) && [self isValid]) { // You can override default NSURLSession instance property allowsCellularAccess (default value YES) // by providing the following key to your RN project (edit ios/project/Info.plist file in Xcode): // ReactNetworkForceWifiOnly @@ -80,12 +80,12 @@ RCT_EXPORT_MODULE() callbackQueue.maxConcurrentOperationCount = 1; callbackQueue.underlyingQueue = [[_moduleRegistry moduleForName:"Networking"] methodQueue]; NSURLSessionConfiguration *configuration; - if (urlSessionConfigurationProvider) { + if (urlSessionConfigurationProvider != nullptr) { configuration = urlSessionConfigurationProvider(); } else { configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; // Set allowsCellularAccess to NO ONLY if key ReactNetworkForceWifiOnly exists AND its value is YES - if (useWifiOnly) { + if (useWifiOnly != nullptr) { configuration.allowsCellularAccess = ![useWifiOnly boolValue]; } [configuration setHTTPShouldSetCookies:YES]; diff --git a/packages/react-native/Libraries/Settings/RCTSettingsManager.mm b/packages/react-native/Libraries/Settings/RCTSettingsManager.mm index e0f37c9a6de..e1515ef05c2 100644 --- a/packages/react-native/Libraries/Settings/RCTSettingsManager.mm +++ b/packages/react-native/Libraries/Settings/RCTSettingsManager.mm @@ -39,7 +39,7 @@ RCT_EXPORT_MODULE() - (instancetype)initWithUserDefaults:(NSUserDefaults *)defaults { - if ((self = [super init])) { + if ((self = [super init]) != nullptr) { _defaults = defaults; [[NSNotificationCenter defaultCenter] addObserver:self @@ -84,7 +84,7 @@ RCT_EXPORT_METHOD(setValues : (NSDictionary *)values) _ignoringUpdates = YES; [values enumerateKeysAndObjectsUsingBlock:^(NSString *key, id json, BOOL *stop) { id plist = [RCTConvert NSPropertyList:json]; - if (plist) { + if (plist != nullptr) { [self->_defaults setObject:plist forKey:key]; } else { [self->_defaults removeObjectForKey:key];