Compare commits

...
Author SHA1 Message Date
CodemodService BotandFacebook GitHub Bot 6a015b7832 Fix CQS signal readability-implicit-bool-conversion in xplat/js/react-native-github/packages
Reviewed By: rshest

Differential Revision: D81565980
2025-09-03 06:07:10 -07:00
11 changed files with 71 additions and 69 deletions
@@ -18,17 +18,17 @@ void RCTSurfaceMinimumSizeAndMaximumSizeFromSizeAndSizeMeasureMode(
*minimumSize = CGSizeZero;
*maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);
if (sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthExact) {
if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthExact) != 0) {
minimumSize->width = size.width;
maximumSize->width = size.width;
} else if (sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthAtMost) {
} else if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthAtMost) != 0) {
maximumSize->width = size.width;
}
if (sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightExact) {
if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightExact) != 0) {
minimumSize->height = size.height;
maximumSize->height = size.height;
} else if (sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightAtMost) {
} else if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightAtMost) != 0) {
maximumSize->height = size.height;
}
}
@@ -31,7 +31,7 @@ using namespace facebook::react;
- (instancetype)init
{
self = [super init];
if (self) {
if (self != nullptr) {
_alertControllers = [NSMutableArray new];
}
return self;
@@ -53,7 +53,7 @@ RCT_EXPORT_MODULE()
alertController.modalPresentationStyle = UIModalPresentationPopover;
UIView *sourceView = parentViewController.view;
if (anchorViewTag) {
if (anchorViewTag != nullptr) {
sourceView = [self.viewRegistry_DEPRECATED viewForReactTag:anchorViewTag];
} else {
alertController.popoverPresentationController.permittedArrowDirections = 0;
@@ -166,12 +166,12 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions
index++;
}
if (disabledButtonIndices) {
if (disabledButtonIndices != nullptr) {
for (NSNumber *disabledButtonIndex in disabledButtonIndices) {
if ([disabledButtonIndex integerValue] < buttons.count) {
UIAlertAction *action = alertController.actions[[disabledButtonIndex integerValue]];
[action setEnabled:false];
if (disabledButtonTintColor) {
if (disabledButtonTintColor != nullptr) {
[action setValue:disabledButtonTintColor forKey:@"titleTextColor"];
}
} else {
@@ -235,14 +235,14 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions
UIColor *tintColor = [RCTConvert UIColor:options.tintColor() ? @(*options.tintColor()) : nil];
dispatch_async(dispatch_get_main_queue(), ^{
if (message) {
if (message != nullptr) {
[items addObject:message];
}
if (URL) {
if (URL != nullptr) {
if ([URL.scheme.lowercaseString isEqualToString:@"data"]) {
NSError *error;
NSData *data = [NSData dataWithContentsOfURL:URL options:(NSDataReadingOptions)0 error:&error];
if (!data) {
if (data == nullptr) {
failureCallback(@[ RCTJSErrorFromNSError(error) ]);
return;
}
@@ -258,17 +258,17 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions
UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:items
applicationActivities:nil];
if (subject) {
if (subject != nullptr) {
[shareController setValue:subject forKey:@"subject"];
}
if (excludedActivityTypes) {
if (excludedActivityTypes != nullptr) {
shareController.excludedActivityTypes = excludedActivityTypes;
}
UIViewController *controller = RCTPresentedViewController();
shareController.completionWithItemsHandler =
^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) {
if (activityError) {
if (activityError != nullptr) {
failureCallback(@[ RCTJSErrorFromNSError(activityError) ]);
} else if (completed || activityType == nil) {
successCallback(@[ @(completed), RCTNullIfNil(activityType) ]);
@@ -27,7 +27,7 @@
_alertWindow = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
}
if (_alertWindow) {
if (_alertWindow != nullptr) {
_alertWindow.rootViewController = [UIViewController new];
_alertWindow.windowLevel = UIWindowLevelAlert + 1;
}
@@ -41,7 +41,7 @@
UIUserInterfaceStyle style = self.overrideUserInterfaceStyle;
if (style == UIUserInterfaceStyleUnspecified) {
UIUserInterfaceStyle overriddenStyle = RCTKeyWindow().overrideUserInterfaceStyle;
style = overriddenStyle ? overriddenStyle : UIUserInterfaceStyleUnspecified;
style = (overriddenStyle != 0) ? overriddenStyle : UIUserInterfaceStyleUnspecified;
}
self.overrideUserInterfaceStyle = style;
@@ -86,7 +86,7 @@ RCT_EXPORT_METHOD(alertWithArgs : (JS::NativeAlertManager::Args &)args callback
UIKeyboardType keyboardType = [RCTConvert UIKeyboardType:args.keyboardType()];
UIUserInterfaceStyle userInterfaceStyle = [RCTConvert UIUserInterfaceStyle:args.userInterfaceStyle()];
if (!title && !message) {
if ((title == nullptr) && (message == nullptr)) {
RCTLogError(@"Must specify either an alert title, or message, or both");
return;
}
@@ -193,7 +193,7 @@ RCT_EXPORT_METHOD(alertWithArgs : (JS::NativeAlertManager::Args &)args callback
}
}
if (!self->_alertControllers) {
if (self->_alertControllers == nullptr) {
self->_alertControllers = [NSHashTable weakObjectsHashTable];
}
[self->_alertControllers addObject:alertController];
@@ -47,7 +47,7 @@ NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification";
- (instancetype)initWithTitleBlock:(RCTDevMenuItemTitleBlock)titleBlock handler:(dispatch_block_t)handler
{
if ((self = [super init])) {
if ((self = [super init]) != nullptr) {
_titleBlock = [titleBlock copy];
_handler = [handler copy];
}
@@ -72,14 +72,14 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
- (void)callHandler
{
if (_handler) {
if (_handler != nullptr) {
_handler();
}
}
- (NSString *)title
{
if (_titleBlock) {
if (_titleBlock != nullptr) {
return _titleBlock();
}
return nil;
@@ -120,7 +120,7 @@ RCT_EXPORT_MODULE()
- (instancetype)init
{
if ((self = [super init])) {
if ((self = [super init]) != nullptr) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(showOnShake)
name:RCTShowDevMenuNotification
@@ -214,7 +214,7 @@ RCT_EXPORT_MODULE()
if (_actionSheet.isBeingPresented || _actionSheet.beingDismissed) {
return;
}
if (_actionSheet) {
if (_actionSheet != nullptr) {
[_actionSheet dismissViewControllerAnimated:YES
completion:^(void) {
self->_actionSheet = nil;
@@ -379,7 +379,7 @@ RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(show)
{
if (_actionSheet || RCTRunningInAppExtension()) {
if ((_actionSheet != nullptr) || RCTRunningInAppExtension()) {
return;
}
@@ -412,7 +412,7 @@ RCT_EXPORT_METHOD(show)
- (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *__nullable)item
{
return ^(__unused UIAlertAction *action) {
if (item) {
if (item != nullptr) {
[item callHandler];
}
@@ -71,12 +71,14 @@ RCT_EXPORT_MODULE()
{
[_callableJSModules invokeModule:@"RCTNativeAppEventEmitter"
method:@"emit"
withArgs:body ? @[ name, body ] : @[ name ]];
withArgs:(body != nullptr) ? @[ name, body ] : @[ name ]];
}
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
{
[_callableJSModules invokeModule:@"RCTDeviceEventEmitter" method:@"emit" withArgs:body ? @[ name, body ] : @[ name ]];
[_callableJSModules invokeModule:@"RCTDeviceEventEmitter"
method:@"emit"
withArgs:(body != nullptr) ? @[ name, body ] : @[ name ]];
}
- (void)sendTextEventWithType:(RCTTextEventType)type
@@ -91,13 +93,13 @@ RCT_EXPORT_MODULE()
@"eventCount" : @(eventCount),
}];
if (text) {
if (text != nullptr) {
// We copy the string here because if it's a mutable string it may get released before we dispatch the event on a
// different thread, causing a crash.
body[@"text"] = [text copy];
}
if (key) {
if (key != nullptr) {
if (key.length == 0) {
key = @"Backspace"; // backspace
} else {
@@ -142,7 +144,7 @@ RCT_EXPORT_MODULE()
if (event.canCoalesce) {
eventID = RCTGetEventID(event.viewTag, event.eventName, event.coalescingKey);
id<RCTEvent> previousEvent = _events[eventID];
if (previousEvent) {
if (previousEvent != nullptr) {
event = [previousEvent coalesceWithEvent:event];
} else {
[_eventQueue addObject:eventID];
@@ -173,13 +175,13 @@ RCT_EXPORT_MODULE()
[_eventQueueLock unlock];
if (scheduleEventsDispatch) {
if (_bridge) {
if (_bridge != nullptr) {
[_bridge
dispatchBlock:^{
[self flushEventsQueue];
}
queue:RCTJSThread];
} else if (_dispatchToJSThread) {
} else if (_dispatchToJSThread != nullptr) {
_dispatchToJSThread(^{
[self flushEventsQueue];
});
@@ -236,7 +238,7 @@ RCT_EXPORT_MODULE()
{
NSDictionary *userInfo = notification.userInfo;
id<RCTEvent> event = [userInfo objectForKey:@"event"];
if (event) {
if (event != nullptr) {
[self notifyObserversOfEvent:event];
}
}
@@ -30,7 +30,7 @@ RCT_EXPORT_MODULE()
- (instancetype)initWithDelegate:(id<RCTExceptionsManagerDelegate>)delegate
{
if ((self = [self init])) {
if ((self = [self init]) != nullptr) {
_delegate = delegate;
}
return self;
@@ -46,7 +46,7 @@ RCT_EXPORT_MODULE()
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}
if (_delegate) {
if (_delegate != nullptr) {
[_delegate handleSoftJSExceptionWithMessage:message
stack:stack
exceptionId:[NSNumber numberWithDouble:exceptionId]
@@ -64,7 +64,7 @@ RCT_EXPORT_MODULE()
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}
if (_delegate) {
if (_delegate != nullptr) {
[_delegate handleFatalJSExceptionWithMessage:message
stack:stack
exceptionId:[NSNumber numberWithDouble:exceptionId]
@@ -107,13 +107,13 @@ RCT_EXPORT_METHOD(reportException : (JS::NativeExceptionsManager::ExceptionData
{
NSMutableDictionary<NSString *, id> *mutableErrorData = [NSMutableDictionary new];
mutableErrorData[@"message"] = data.message();
if (data.originalMessage()) {
if (data.originalMessage() != nullptr) {
mutableErrorData[@"originalMessage"] = data.originalMessage();
}
if (data.name()) {
if (data.name() != nullptr) {
mutableErrorData[@"name"] = data.name();
}
if (data.componentStack()) {
if (data.componentStack() != nullptr) {
mutableErrorData[@"componentStack"] = data.componentStack();
}
@@ -141,7 +141,7 @@ RCT_EXPORT_METHOD(reportException : (JS::NativeExceptionsManager::ExceptionData
mutableErrorData[@"id"] = @(data.id_());
mutableErrorData[@"isFatal"] = @(data.isFatal());
if (data.extraData()) {
if (data.extraData() != nullptr) {
mutableErrorData[@"extraData"] = data.extraData();
}
@@ -37,7 +37,7 @@
- (instancetype)initWithFrame:(CGRect)frame color:(UIColor *)color
{
if ((self = [super initWithFrame:frame])) {
if ((self = [super initWithFrame:frame]) != nullptr) {
_frameCount = -1;
_prevTime = -1;
_maxFPS = 0;
@@ -64,7 +64,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
- (CAShapeLayer *)graph
{
if (!_graph) {
if (_graph == nullptr) {
_graph = [CAShapeLayer new];
_graph.frame = self.bounds;
_graph.backgroundColor = [_color colorWithAlphaComponent:0.2].CGColor;
@@ -76,7 +76,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
- (UILabel *)label
{
if (!_label) {
if (_label == nullptr) {
_label = [[UILabel alloc] initWithFrame:self.bounds];
_label.font = [UIFont boldSystemFontOfSize:13];
_label.textAlignment = NSTextAlignmentCenter;
@@ -45,23 +45,23 @@ RCT_EXPORT_METHOD(show)
__weak RCTLogBox *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
__strong RCTLogBox *strongSelf = weakSelf;
if (!strongSelf) {
if (strongSelf == nullptr) {
return;
}
if (strongSelf->_view) {
if (strongSelf->_view != nullptr) {
[strongSelf->_view show];
return;
}
if (strongSelf->_bridgelessSurfacePresenter) {
if (strongSelf->_bridgelessSurfacePresenter != nullptr) {
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
surfacePresenter:strongSelf->_bridgelessSurfacePresenter];
[strongSelf->_view show];
}
#ifndef RCT_FIT_RM_OLD_RUNTIME
else if (strongSelf->_bridge && strongSelf->_bridge.valid) {
if (strongSelf->_bridge.surfacePresenter) {
else if ((strongSelf->_bridge != nullptr) && strongSelf->_bridge.valid) {
if (strongSelf->_bridge.surfacePresenter != nullptr) {
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
surfacePresenter:strongSelf->_bridge.surfacePresenter];
} else {
@@ -80,7 +80,7 @@ RCT_EXPORT_METHOD(hide)
__weak RCTLogBox *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
__strong RCTLogBox *strongSelf = weakSelf;
if (!strongSelf) {
if (strongSelf == nullptr) {
return;
}
[strongSelf->_view setHidden:YES];
@@ -19,7 +19,7 @@
- (instancetype)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
if ((self = [super initWithFrame:frame]) != nullptr) {
self.windowLevel = UIWindowLevelStatusBar - 1;
self.backgroundColor = [UIColor clearColor];
}
@@ -134,7 +134,7 @@ RCT_EXPORT_MODULE()
#if __has_include(<React/RCTDevMenu.h>)
- (RCTDevMenuItem *)devMenuItem
{
if (!_devMenuItem) {
if (_devMenuItem == nullptr) {
__weak __typeof__(self) weakSelf = self;
__weak RCTDevSettings *devSettings = [self->_moduleRegistry moduleForName:"DevSettings"];
if (devSettings.isPerfMonitorShown) {
@@ -161,7 +161,7 @@ RCT_EXPORT_MODULE()
- (UIPanGestureRecognizer *)gestureRecognizer
{
if (!_gestureRecognizer) {
if (_gestureRecognizer == nullptr) {
_gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(gesture:)];
}
@@ -170,7 +170,7 @@ RCT_EXPORT_MODULE()
- (UIView *)container
{
if (!_container) {
if (_container == nullptr) {
UIEdgeInsets safeInsets = RCTKeyWindow().safeAreaInsets;
_container =
@@ -188,7 +188,7 @@ RCT_EXPORT_MODULE()
- (UILabel *)memory
{
if (!_memory) {
if (_memory == nullptr) {
_memory = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 44, RCTPerfMonitorBarHeight)];
_memory.font = [UIFont systemFontOfSize:12];
_memory.numberOfLines = 3;
@@ -200,7 +200,7 @@ RCT_EXPORT_MODULE()
- (UILabel *)heap
{
if (!_heap) {
if (_heap == nullptr) {
_heap = [[UILabel alloc] initWithFrame:CGRectMake(44, 0, 44, RCTPerfMonitorBarHeight)];
_heap.font = [UIFont systemFontOfSize:12];
_heap.numberOfLines = 3;
@@ -212,7 +212,7 @@ RCT_EXPORT_MODULE()
- (UILabel *)views
{
if (!_views) {
if (_views == nullptr) {
_views = [[UILabel alloc] initWithFrame:CGRectMake(88, 0, 44, RCTPerfMonitorBarHeight)];
_views.font = [UIFont systemFontOfSize:12];
_views.numberOfLines = 3;
@@ -224,7 +224,7 @@ RCT_EXPORT_MODULE()
- (RCTFPSGraph *)uiGraph
{
if (!_uiGraph) {
if (_uiGraph == nullptr) {
_uiGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(134, 14, 40, 30) color:[UIColor lightGrayColor]];
}
return _uiGraph;
@@ -232,7 +232,7 @@ RCT_EXPORT_MODULE()
- (RCTFPSGraph *)jsGraph
{
if (!_jsGraph) {
if (_jsGraph == nullptr) {
_jsGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(178, 14, 40, 30) color:[UIColor lightGrayColor]];
}
return _jsGraph;
@@ -240,7 +240,7 @@ RCT_EXPORT_MODULE()
- (UILabel *)uiGraphLabel
{
if (!_uiGraphLabel) {
if (_uiGraphLabel == nullptr) {
_uiGraphLabel = [[UILabel alloc] initWithFrame:CGRectMake(134, 3, 40, 10)];
_uiGraphLabel.font = [UIFont systemFontOfSize:11];
_uiGraphLabel.textAlignment = NSTextAlignmentCenter;
@@ -252,7 +252,7 @@ RCT_EXPORT_MODULE()
- (UILabel *)jsGraphLabel
{
if (!_jsGraphLabel) {
if (_jsGraphLabel == nullptr) {
_jsGraphLabel = [[UILabel alloc] initWithFrame:CGRectMake(178, 3, 38, 10)];
_jsGraphLabel.font = [UIFont systemFontOfSize:11];
_jsGraphLabel.textAlignment = NSTextAlignmentCenter;
@@ -264,7 +264,7 @@ RCT_EXPORT_MODULE()
- (UITableView *)metrics
{
if (!_metrics) {
if (_metrics == nullptr) {
_metrics = [[UITableView alloc] initWithFrame:CGRectMake(
0,
RCTPerfMonitorBarHeight,
@@ -281,7 +281,7 @@ RCT_EXPORT_MODULE()
- (void)show
{
if (_container) {
if (_container != nullptr) {
return;
}
@@ -317,7 +317,7 @@ RCT_EXPORT_MODULE()
- (void)hide
{
if (!_container) {
if (_container == nullptr) {
return;
}
@@ -360,7 +360,7 @@ RCT_EXPORT_MODULE()
dispatch_io_set_low_water(_io, 20);
dispatch_io_read(_io, 0, SIZE_MAX, _queue, ^(__unused bool done, dispatch_data_t data, __unused int error) {
if (!data) {
if (data == nullptr) {
return;
}
@@ -391,7 +391,7 @@ RCT_EXPORT_MODULE()
GCRegex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];
});
if (_remaining) {
if (_remaining != nullptr) {
log = [_remaining stringByAppendingString:log];
_remaining = nil;
}
@@ -404,7 +404,7 @@ RCT_EXPORT_MODULE()
for (NSString *line in lines) {
NSTextCheckingResult *match = [GCRegex firstMatchInString:line options:0 range:NSMakeRange(0, line.length)];
if (match) {
if (match != nullptr) {
NSString *heapSizeStr = [line substringWithRange:[match rangeAtIndex:2]];
_heapSize = [heapSizeStr integerValue];
}
@@ -417,7 +417,7 @@ RCT_EXPORT_MODULE()
NSUInteger viewCount = views.count;
NSUInteger visibleViewCount = 0;
for (UIView *view in views.allValues) {
if (view.window || view.superview.window) {
if ((view.window != nullptr) || (view.superview.window != nullptr)) {
visibleViewCount++;
}
}
@@ -436,7 +436,7 @@ RCT_EXPORT_MODULE()
__weak __typeof__(self) weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
__strong __typeof__(weakSelf) strongSelf = weakSelf;
if (strongSelf && strongSelf->_container.superview) {
if ((strongSelf != nullptr) && (strongSelf->_container.superview != nullptr)) {
[strongSelf updateStats];
}
});
@@ -512,7 +512,7 @@ RCT_EXPORT_MODULE()
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RCTPerfMonitorCellIdentifier
forIndexPath:indexPath];
if (!cell) {
if (cell == nullptr) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:RCTPerfMonitorCellIdentifier];
}