Skip to content

Commit 8d84521

Browse files
generatedunixname89002005287564facebook-github-bot
authored andcommitted
Fix CQS signal readability-implicit-bool-conversion in xplat/js/react-native-github/packages (#53584)
Summary: Pull Request resolved: #53584 Reviewed By: rshest Differential Revision: D81565980 fbshipit-source-id: e9c7eeb3219ee56b693583a6cf8a7905ac360324
1 parent e41dce3 commit 8d84521

File tree

11 files changed

+71
-69
lines changed

11 files changed

+71
-69
lines changed

packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ void RCTSurfaceMinimumSizeAndMaximumSizeFromSizeAndSizeMeasureMode(
1818
*minimumSize = CGSizeZero;
1919
*maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);
2020

21-
if (sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthExact) {
21+
if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthExact) != 0) {
2222
minimumSize->width = size.width;
2323
maximumSize->width = size.width;
24-
} else if (sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthAtMost) {
24+
} else if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthAtMost) != 0) {
2525
maximumSize->width = size.width;
2626
}
2727

28-
if (sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightExact) {
28+
if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightExact) != 0) {
2929
minimumSize->height = size.height;
3030
maximumSize->height = size.height;
31-
} else if (sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightAtMost) {
31+
} else if ((sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightAtMost) != 0) {
3232
maximumSize->height = size.height;
3333
}
3434
}

packages/react-native/React/CoreModules/RCTActionSheetManager.mm

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ @implementation RCTActionSheetManager
3131
- (instancetype)init
3232
{
3333
self = [super init];
34-
if (self) {
34+
if (self != nullptr) {
3535
_alertControllers = [NSMutableArray new];
3636
}
3737
return self;
@@ -53,7 +53,7 @@ - (void)presentViewController:(UIViewController *)alertController
5353
alertController.modalPresentationStyle = UIModalPresentationPopover;
5454
UIView *sourceView = parentViewController.view;
5555

56-
if (anchorViewTag) {
56+
if (anchorViewTag != nullptr) {
5757
sourceView = [self.viewRegistry_DEPRECATED viewForReactTag:anchorViewTag];
5858
} else {
5959
alertController.popoverPresentationController.permittedArrowDirections = 0;
@@ -166,12 +166,12 @@ - (void)presentViewController:(UIViewController *)alertController
166166
index++;
167167
}
168168

169-
if (disabledButtonIndices) {
169+
if (disabledButtonIndices != nullptr) {
170170
for (NSNumber *disabledButtonIndex in disabledButtonIndices) {
171171
if ([disabledButtonIndex integerValue] < buttons.count) {
172172
UIAlertAction *action = alertController.actions[[disabledButtonIndex integerValue]];
173173
[action setEnabled:false];
174-
if (disabledButtonTintColor) {
174+
if (disabledButtonTintColor != nullptr) {
175175
[action setValue:disabledButtonTintColor forKey:@"titleTextColor"];
176176
}
177177
} else {
@@ -235,14 +235,14 @@ - (void)presentViewController:(UIViewController *)alertController
235235
UIColor *tintColor = [RCTConvert UIColor:options.tintColor() ? @(*options.tintColor()) : nil];
236236

237237
dispatch_async(dispatch_get_main_queue(), ^{
238-
if (message) {
238+
if (message != nullptr) {
239239
[items addObject:message];
240240
}
241-
if (URL) {
241+
if (URL != nullptr) {
242242
if ([URL.scheme.lowercaseString isEqualToString:@"data"]) {
243243
NSError *error;
244244
NSData *data = [NSData dataWithContentsOfURL:URL options:(NSDataReadingOptions)0 error:&error];
245-
if (!data) {
245+
if (data == nullptr) {
246246
failureCallback(@[ RCTJSErrorFromNSError(error) ]);
247247
return;
248248
}
@@ -258,17 +258,17 @@ - (void)presentViewController:(UIViewController *)alertController
258258

259259
UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:items
260260
applicationActivities:nil];
261-
if (subject) {
261+
if (subject != nullptr) {
262262
[shareController setValue:subject forKey:@"subject"];
263263
}
264-
if (excludedActivityTypes) {
264+
if (excludedActivityTypes != nullptr) {
265265
shareController.excludedActivityTypes = excludedActivityTypes;
266266
}
267267

268268
UIViewController *controller = RCTPresentedViewController();
269269
shareController.completionWithItemsHandler =
270270
^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) {
271-
if (activityError) {
271+
if (activityError != nullptr) {
272272
failureCallback(@[ RCTJSErrorFromNSError(activityError) ]);
273273
} else if (completed || activityType == nil) {
274274
successCallback(@[ @(completed), RCTNullIfNil(activityType) ]);

packages/react-native/React/CoreModules/RCTAlertController.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ - (UIWindow *)alertWindow
2727
_alertWindow = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
2828
}
2929

30-
if (_alertWindow) {
30+
if (_alertWindow != nullptr) {
3131
_alertWindow.rootViewController = [UIViewController new];
3232
_alertWindow.windowLevel = UIWindowLevelAlert + 1;
3333
}
@@ -41,7 +41,7 @@ - (void)show:(BOOL)animated completion:(void (^)(void))completion
4141
UIUserInterfaceStyle style = self.overrideUserInterfaceStyle;
4242
if (style == UIUserInterfaceStyleUnspecified) {
4343
UIUserInterfaceStyle overriddenStyle = RCTKeyWindow().overrideUserInterfaceStyle;
44-
style = overriddenStyle ? overriddenStyle : UIUserInterfaceStyleUnspecified;
44+
style = (overriddenStyle != 0) ? overriddenStyle : UIUserInterfaceStyleUnspecified;
4545
}
4646

4747
self.overrideUserInterfaceStyle = style;

packages/react-native/React/CoreModules/RCTAlertManager.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ - (void)invalidate
8686
UIKeyboardType keyboardType = [RCTConvert UIKeyboardType:args.keyboardType()];
8787
UIUserInterfaceStyle userInterfaceStyle = [RCTConvert UIUserInterfaceStyle:args.userInterfaceStyle()];
8888

89-
if (!title && !message) {
89+
if ((title == nullptr) && (message == nullptr)) {
9090
RCTLogError(@"Must specify either an alert title, or message, or both");
9191
return;
9292
}
@@ -193,7 +193,7 @@ - (void)invalidate
193193
}
194194
}
195195

196-
if (!self->_alertControllers) {
196+
if (self->_alertControllers == nullptr) {
197197
self->_alertControllers = [NSHashTable weakObjectsHashTable];
198198
}
199199
[self->_alertControllers addObject:alertController];

packages/react-native/React/CoreModules/RCTDevMenu.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ @implementation RCTDevMenuItem {
4747

4848
- (instancetype)initWithTitleBlock:(RCTDevMenuItemTitleBlock)titleBlock handler:(dispatch_block_t)handler
4949
{
50-
if ((self = [super init])) {
50+
if ((self = [super init]) != nullptr) {
5151
_titleBlock = [titleBlock copy];
5252
_handler = [handler copy];
5353
}
@@ -72,14 +72,14 @@ + (instancetype)buttonItemWithTitle:(NSString *)title handler:(dispatch_block_t)
7272

7373
- (void)callHandler
7474
{
75-
if (_handler) {
75+
if (_handler != nullptr) {
7676
_handler();
7777
}
7878
}
7979

8080
- (NSString *)title
8181
{
82-
if (_titleBlock) {
82+
if (_titleBlock != nullptr) {
8383
return _titleBlock();
8484
}
8585
return nil;
@@ -120,7 +120,7 @@ + (BOOL)requiresMainQueueSetup
120120

121121
- (instancetype)init
122122
{
123-
if ((self = [super init])) {
123+
if ((self = [super init]) != nullptr) {
124124
[[NSNotificationCenter defaultCenter] addObserver:self
125125
selector:@selector(showOnShake)
126126
name:RCTShowDevMenuNotification
@@ -214,7 +214,7 @@ - (void)toggle
214214
if (_actionSheet.isBeingPresented || _actionSheet.beingDismissed) {
215215
return;
216216
}
217-
if (_actionSheet) {
217+
if (_actionSheet != nullptr) {
218218
[_actionSheet dismissViewControllerAnimated:YES
219219
completion:^(void) {
220220
self->_actionSheet = nil;
@@ -379,7 +379,7 @@ - (void)setDefaultJSBundle
379379

380380
RCT_EXPORT_METHOD(show)
381381
{
382-
if (_actionSheet || RCTRunningInAppExtension()) {
382+
if ((_actionSheet != nullptr) || RCTRunningInAppExtension()) {
383383
return;
384384
}
385385

@@ -412,7 +412,7 @@ - (void)setDefaultJSBundle
412412
- (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *__nullable)item
413413
{
414414
return ^(__unused UIAlertAction *action) {
415-
if (item) {
415+
if (item != nullptr) {
416416
[item callHandler];
417417
}
418418

packages/react-native/React/CoreModules/RCTEventDispatcher.mm

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ - (void)sendAppEventWithName:(NSString *)name body:(id)body
7171
{
7272
[_callableJSModules invokeModule:@"RCTNativeAppEventEmitter"
7373
method:@"emit"
74-
withArgs:body ? @[ name, body ] : @[ name ]];
74+
withArgs:(body != nullptr) ? @[ name, body ] : @[ name ]];
7575
}
7676

7777
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
7878
{
79-
[_callableJSModules invokeModule:@"RCTDeviceEventEmitter" method:@"emit" withArgs:body ? @[ name, body ] : @[ name ]];
79+
[_callableJSModules invokeModule:@"RCTDeviceEventEmitter"
80+
method:@"emit"
81+
withArgs:(body != nullptr) ? @[ name, body ] : @[ name ]];
8082
}
8183

8284
- (void)sendTextEventWithType:(RCTTextEventType)type
@@ -91,13 +93,13 @@ - (void)sendTextEventWithType:(RCTTextEventType)type
9193
@"eventCount" : @(eventCount),
9294
}];
9395

94-
if (text) {
96+
if (text != nullptr) {
9597
// We copy the string here because if it's a mutable string it may get released before we dispatch the event on a
9698
// different thread, causing a crash.
9799
body[@"text"] = [text copy];
98100
}
99101

100-
if (key) {
102+
if (key != nullptr) {
101103
if (key.length == 0) {
102104
key = @"Backspace"; // backspace
103105
} else {
@@ -142,7 +144,7 @@ - (void)sendEvent:(id<RCTEvent>)event
142144
if (event.canCoalesce) {
143145
eventID = RCTGetEventID(event.viewTag, event.eventName, event.coalescingKey);
144146
id<RCTEvent> previousEvent = _events[eventID];
145-
if (previousEvent) {
147+
if (previousEvent != nullptr) {
146148
event = [previousEvent coalesceWithEvent:event];
147149
} else {
148150
[_eventQueue addObject:eventID];
@@ -173,13 +175,13 @@ - (void)sendEvent:(id<RCTEvent>)event
173175
[_eventQueueLock unlock];
174176

175177
if (scheduleEventsDispatch) {
176-
if (_bridge) {
178+
if (_bridge != nullptr) {
177179
[_bridge
178180
dispatchBlock:^{
179181
[self flushEventsQueue];
180182
}
181183
queue:RCTJSThread];
182-
} else if (_dispatchToJSThread) {
184+
} else if (_dispatchToJSThread != nullptr) {
183185
_dispatchToJSThread(^{
184186
[self flushEventsQueue];
185187
});
@@ -236,7 +238,7 @@ - (void)_notifyEventDispatcherObserversOfEvent_DEPRECATED:(NSNotification *)noti
236238
{
237239
NSDictionary *userInfo = notification.userInfo;
238240
id<RCTEvent> event = [userInfo objectForKey:@"event"];
239-
if (event) {
241+
if (event != nullptr) {
240242
[self notifyObserversOfEvent:event];
241243
}
242244
}

packages/react-native/React/CoreModules/RCTExceptionsManager.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ @implementation RCTExceptionsManager
3030

3131
- (instancetype)initWithDelegate:(id<RCTExceptionsManagerDelegate>)delegate
3232
{
33-
if ((self = [self init])) {
33+
if ((self = [self init]) != nullptr) {
3434
_delegate = delegate;
3535
}
3636
return self;
@@ -46,7 +46,7 @@ - (void)reportSoft:(NSString *)message
4646
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
4747
}
4848

49-
if (_delegate) {
49+
if (_delegate != nullptr) {
5050
[_delegate handleSoftJSExceptionWithMessage:message
5151
stack:stack
5252
exceptionId:[NSNumber numberWithDouble:exceptionId]
@@ -64,7 +64,7 @@ - (void)reportFatal:(NSString *)message
6464
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
6565
}
6666

67-
if (_delegate) {
67+
if (_delegate != nullptr) {
6868
[_delegate handleFatalJSExceptionWithMessage:message
6969
stack:stack
7070
exceptionId:[NSNumber numberWithDouble:exceptionId]
@@ -107,13 +107,13 @@ - (void)reportFatal:(NSString *)message
107107
{
108108
NSMutableDictionary<NSString *, id> *mutableErrorData = [NSMutableDictionary new];
109109
mutableErrorData[@"message"] = data.message();
110-
if (data.originalMessage()) {
110+
if (data.originalMessage() != nullptr) {
111111
mutableErrorData[@"originalMessage"] = data.originalMessage();
112112
}
113-
if (data.name()) {
113+
if (data.name() != nullptr) {
114114
mutableErrorData[@"name"] = data.name();
115115
}
116-
if (data.componentStack()) {
116+
if (data.componentStack() != nullptr) {
117117
mutableErrorData[@"componentStack"] = data.componentStack();
118118
}
119119

@@ -141,7 +141,7 @@ - (void)reportFatal:(NSString *)message
141141
mutableErrorData[@"id"] = @(data.id_());
142142
mutableErrorData[@"isFatal"] = @(data.isFatal());
143143

144-
if (data.extraData()) {
144+
if (data.extraData() != nullptr) {
145145
mutableErrorData[@"extraData"] = data.extraData();
146146
}
147147

packages/react-native/React/CoreModules/RCTFPSGraph.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ @implementation RCTFPSGraph {
3737

3838
- (instancetype)initWithFrame:(CGRect)frame color:(UIColor *)color
3939
{
40-
if ((self = [super initWithFrame:frame])) {
40+
if ((self = [super initWithFrame:frame]) != nullptr) {
4141
_frameCount = -1;
4242
_prevTime = -1;
4343
_maxFPS = 0;
@@ -64,7 +64,7 @@ - (void)dealloc
6464

6565
- (CAShapeLayer *)graph
6666
{
67-
if (!_graph) {
67+
if (_graph == nullptr) {
6868
_graph = [CAShapeLayer new];
6969
_graph.frame = self.bounds;
7070
_graph.backgroundColor = [_color colorWithAlphaComponent:0.2].CGColor;
@@ -76,7 +76,7 @@ - (CAShapeLayer *)graph
7676

7777
- (UILabel *)label
7878
{
79-
if (!_label) {
79+
if (_label == nullptr) {
8080
_label = [[UILabel alloc] initWithFrame:self.bounds];
8181
_label.font = [UIFont boldSystemFontOfSize:13];
8282
_label.textAlignment = NSTextAlignmentCenter;

packages/react-native/React/CoreModules/RCTLogBox.mm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
4545
__weak RCTLogBox *weakSelf = self;
4646
dispatch_async(dispatch_get_main_queue(), ^{
4747
__strong RCTLogBox *strongSelf = weakSelf;
48-
if (!strongSelf) {
48+
if (strongSelf == nullptr) {
4949
return;
5050
}
5151

52-
if (strongSelf->_view) {
52+
if (strongSelf->_view != nullptr) {
5353
[strongSelf->_view show];
5454
return;
5555
}
5656

57-
if (strongSelf->_bridgelessSurfacePresenter) {
57+
if (strongSelf->_bridgelessSurfacePresenter != nullptr) {
5858
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
5959
surfacePresenter:strongSelf->_bridgelessSurfacePresenter];
6060
[strongSelf->_view show];
6161
}
6262
#ifndef RCT_FIT_RM_OLD_RUNTIME
63-
else if (strongSelf->_bridge && strongSelf->_bridge.valid) {
64-
if (strongSelf->_bridge.surfacePresenter) {
63+
else if ((strongSelf->_bridge != nullptr) && strongSelf->_bridge.valid) {
64+
if (strongSelf->_bridge.surfacePresenter != nullptr) {
6565
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
6666
surfacePresenter:strongSelf->_bridge.surfacePresenter];
6767
} else {
@@ -80,7 +80,7 @@ - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
8080
__weak RCTLogBox *weakSelf = self;
8181
dispatch_async(dispatch_get_main_queue(), ^{
8282
__strong RCTLogBox *strongSelf = weakSelf;
83-
if (!strongSelf) {
83+
if (strongSelf == nullptr) {
8484
return;
8585
}
8686
[strongSelf->_view setHidden:YES];

packages/react-native/React/CoreModules/RCTLogBoxView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ @implementation RCTLogBoxView {
1919

2020
- (instancetype)initWithFrame:(CGRect)frame
2121
{
22-
if ((self = [super initWithFrame:frame])) {
22+
if ((self = [super initWithFrame:frame]) != nullptr) {
2323
self.windowLevel = UIWindowLevelStatusBar - 1;
2424
self.backgroundColor = [UIColor clearColor];
2525
}

0 commit comments

Comments
 (0)