[ios] Static analysis fix tweaks - part 2 (#14572)

This commit is contained in:
Julian Rex
2019-05-02 14:08:48 -04:00
committed by GitHub
parent c611d085b3
commit f7915fdc51
30 changed files with 102 additions and 85 deletions

View File

@@ -69,8 +69,6 @@ typedef void (^NetworkUnreachable)(MGLReachability * reachability);
+(instancetype)reachabilityWithAddress:(void *)hostAddress;
+(instancetype)reachabilityForLocalWiFi;
-(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
-(BOOL)startNotifier;
-(void)stopNotifier;

View File

@@ -190,7 +190,7 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLExpressionInterpolationMode MGLExpressionI
@return An initialized expression equivalent to `object`, suitable for use as
the value of a style layer attribute.
*/
+ (instancetype)expressionWithMGLJSONObject:(nullable id)object NS_SWIFT_NAME(init(mglJSONObject:));
+ (instancetype)expressionWithMGLJSONObject:(id)object NS_SWIFT_NAME(init(mglJSONObject:));
/**
An equivalent Foundation object that can be serialized as JSON.

View File

@@ -792,6 +792,9 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
} else if ([curveType isEqualToString:@"cubic-bezier"]) {
curveParameters = @[@"literal", [interpolationOptions subarrayWithRange:NSMakeRange(1, 4)]];
}
else {
curveParameters = [NSNull null];
}
NSExpression *curveParameterExpression = [NSExpression expressionWithMGLJSONObject:curveParameters];
argumentObjects = [argumentObjects subarrayWithRange:NSMakeRange(1, argumentObjects.count - 1)];
NSExpression *inputExpression = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject];

View File

@@ -100,6 +100,8 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
{
id reachability = [[self alloc] initWithReachabilityRef:ref];
CFRelease(ref);
return reachability;
}
@@ -113,6 +115,8 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
{
id reachability = [[self alloc] initWithReachabilityRef:ref];
CFRelease(ref);
return reachability;
}
@@ -149,13 +153,13 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
self = [super init];
if (self != nil)
{
self.reachableOnWWAN = YES;
self.reachabilityRef = ref;
_reachableOnWWAN = YES;
_reachabilityRef = CFRetain(ref);
// We need to create a serial queue.
// We allocate this once for the lifetime of the notifier.
self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL);
_reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL);
}
return self;
@@ -165,15 +169,15 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
{
[self stopNotifier];
if(self.reachabilityRef)
if(_reachabilityRef)
{
CFRelease(self.reachabilityRef);
self.reachabilityRef = nil;
CFRelease(_reachabilityRef);
_reachabilityRef = nil;
}
self.reachableBlock = nil;
self.unreachableBlock = nil;
self.reachabilitySerialQueue = nil;
_reachableBlock = nil;
_unreachableBlock = nil;
_reachabilitySerialQueue = nil;
}
#pragma mark - Notifier Methods

View File

@@ -3749,6 +3749,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -4094,6 +4096,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -4106,6 +4110,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

View File

@@ -1,7 +1,7 @@
/* Accessibility hint */
"ANNOTATION_A11Y_HINT" = "Shows more info";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Cancel";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */
@@ -20,7 +20,7 @@
"DESIGNABLE" = "To display a Mapbox-hosted map here, set %1$@ to your access token in %2$@\n\nFor detailed instructions, see:";
/* Setup documentation URL display string; keep as short as possible */
"FIRST_STEPS_URL" = "mapbox.com/help/first-steps-ios-sdk";
"FIRST_STEPS_URL" = "docs.mapbox.com/help/tutorials/first-steps-ios-sdk";
/* Accessibility hint */
"INFO_A11Y_HINT" = "Shows credits, a feedback form, and more";

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Статус код %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Отказ";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "El codi d’estat era %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Cancel·lar";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -1,7 +1,7 @@
/* Accessibility hint */
"ANNOTATION_A11Y_HINT" = "Shows more info";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Cancel";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Status koden var %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Fortryd";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Der Statuscode ist %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Abbrechen";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "El código de estado fue %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Cancelar";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -1,7 +1,7 @@
/* Accessibility hint */
"ANNOTATION_A11Y_HINT" = "Afficher plus d’informations";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Annuler";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -1,7 +1,7 @@
/* Accessibility hint */
"ANNOTATION_A11Y_HINT" = "Amosa máis información";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Desbotar";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "סטטוס הקוד היה %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "ביטול";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "A státuszkód %ld volt";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Mégse";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "The status code was %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "キャンセル";
/* Accessibility hint */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "상태 코드 %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "취소";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Būklės kodas: %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Atšaukti";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "O código de status foi %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Cancelar";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "O código de estado era %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Cancelar";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Код ответа %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Отмена";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Statuskoden var %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Avbryt";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Код стану %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Скасувати";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "Mã trạng thái là %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "Hủy bỏ";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "The status code was %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "取消";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -7,7 +7,7 @@
/* No comment provided by engineer. */
"API_CLIENT_400_REASON" = "The status code was %ld";
/* No comment provided by engineer. */
/* Title of button for dismissing attribution action sheet */
"CANCEL" = "取消";
/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */

View File

@@ -1130,7 +1130,7 @@ MGL_EXPORT
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
depending on the order of notification delivery.
*/
- (nullable MGLMapCamera *)cameraThatFitsCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
- (MGLMapCamera *)cameraThatFitsCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
/**
Returns the camera that best fits the given coordinate bounds, with the specified camera,
@@ -1150,7 +1150,7 @@ MGL_EXPORT
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
depending on the order of notification delivery.
*/
- (nullable MGLMapCamera *)camera:(MGLMapCamera *)camera fittingCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
- (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
/**
Returns the camera that best fits the given shape, with the specified camera,
@@ -1169,7 +1169,7 @@ MGL_EXPORT
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
depending on the order of notification delivery.
*/
- (nullable MGLMapCamera *)camera:(MGLMapCamera *)camera fittingShape:(MGLShape *)shape edgePadding:(UIEdgeInsets)insets;
- (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingShape:(MGLShape *)shape edgePadding:(UIEdgeInsets)insets;
/**
Returns the camera that best fits the given shape, with the specified direction,
@@ -1187,7 +1187,7 @@ MGL_EXPORT
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
depending on the order of notification delivery.
*/
- (nullable MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets;
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets;
/**
Returns the point in this view’s coordinate system on which to "anchor" in

View File

@@ -2481,7 +2481,7 @@ public:
}];
[attributionController addAction:telemetryAction];
NSString *cancelTitle = NSLocalizedStringWithDefaultValue(@"CANCEL", nil, nil, @"Cancel", @"Cancel");
NSString *cancelTitle = NSLocalizedStringWithDefaultValue(@"CANCEL", nil, nil, @"Cancel", @"Title of button for dismissing attribution action sheet");
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelTitle
style:UIAlertActionStyleCancel
handler:NULL];
@@ -3873,9 +3873,9 @@ public:
{
if (!_mbglMap)
{
return nil;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset);
mbgl::CameraOptions cameraOptions = self.mbglMap.cameraForLatLngBounds(MGLLatLngBoundsFromCoordinateBounds(bounds), padding);
@@ -3886,7 +3886,7 @@ public:
{
if (!_mbglMap)
{
return nil;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
@@ -3903,7 +3903,7 @@ public:
- (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingShape:(MGLShape *)shape edgePadding:(UIEdgeInsets)insets {
if (!_mbglMap)
{
return nil;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
@@ -3921,7 +3921,7 @@ public:
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets {
if (!_mbglMap)
{
return nil;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
@@ -3936,7 +3936,7 @@ public:
{
if (!_mbglMap)
{
return nil;
return self.residualCamera;
}
mbgl::CameraOptions mapCamera = self.mbglMap.getCameraOptions();

View File

@@ -520,52 +520,58 @@ NSTimeInterval const kMGLSMCalloutViewRepositionDelayForUIScrollView = 1.0/3.0;
- (CAAnimation *)animationWithType:(MGLSMCalloutAnimation)type presenting:(BOOL)presenting {
CAAnimation *animation = nil;
if (type == MGLSMCalloutAnimationBounce) {
CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
fade.duration = 0.23;
fade.fromValue = presenting ? @0.0 : @1.0;
fade.toValue = presenting ? @1.0 : @0.0;
fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
bounce.duration = 0.23;
bounce.fromValue = presenting ? @0.7 : @1.0;
bounce.toValue = presenting ? @1.0 : @0.7;
bounce.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.59367:0.12066:0.18878:1.5814];
CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = @[fade, bounce];
group.duration = 0.23;
animation = group;
switch (type)
{
case MGLSMCalloutAnimationBounce:
{
CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
fade.duration = 0.23;
fade.fromValue = presenting ? @0.0 : @1.0;
fade.toValue = presenting ? @1.0 : @0.0;
fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
bounce.duration = 0.23;
bounce.fromValue = presenting ? @0.7 : @1.0;
bounce.toValue = presenting ? @1.0 : @0.7;
bounce.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.59367:0.12066:0.18878:1.5814];
CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = @[fade, bounce];
group.duration = 0.23;
animation = group;
break;
}
case MGLSMCalloutAnimationFade:
{
CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
fade.duration = 1.0/3.0;
fade.fromValue = presenting ? @0.0 : @1.0;
fade.toValue = presenting ? @1.0 : @0.0;
animation = fade;
break;
}
case MGLSMCalloutAnimationStretch:
{
CABasicAnimation *stretch = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
stretch.duration = 0.1;
stretch.fromValue = presenting ? @0.0 : @1.0;
stretch.toValue = presenting ? @1.0 : @0.0;
animation = stretch;
break;
}
}
else if (type == MGLSMCalloutAnimationFade) {
CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
fade.duration = 1.0/3.0;
fade.fromValue = presenting ? @0.0 : @1.0;
fade.toValue = presenting ? @1.0 : @0.0;
animation = fade;
}
else if (type == MGLSMCalloutAnimationStretch) {
CABasicAnimation *stretch = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
stretch.duration = 0.1;
stretch.fromValue = presenting ? @0.0 : @1.0;
stretch.toValue = presenting ? @1.0 : @0.0;
animation = stretch;
}
NSAssert(animation, @"There should be an animation");
// CAAnimation is KVC compliant, so we can store whether we're presenting for lookup in our delegate methods
[animation setValue:@(presenting) forKey:@"presenting"];
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
// Cast as non-null to mute static analysis warning as documented at
// https://clang-analyzer.llvm.org/faq.html#decide_nullability
return (CAAnimation * _Nonnull)animation;
return animation;
}
- (void)layoutSubviews {