Permalink
Browse files

Merge pull request #4200 from svoit/code_cleaning

Code cleaning
  • Loading branch information...
SlaunchaMan committed Feb 9, 2019
2 parents 9cc7829 + d6db830 commit ee950948f2ef85240f8fc0a6b84f793912af9c24
@@ -252,9 +252,6 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
}

switch (self.SSLPinningMode) {
case AFSSLPinningModeNone:
default:
return NO;
case AFSSLPinningModeCertificate: {
NSMutableArray *pinnedCertificates = [NSMutableArray array];
for (NSData *certificateData in self.pinnedCertificates) {
@@ -290,6 +287,9 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
}
return trustedPublicKeyCount > 0;
}

default:
return NO;
}

return NO;
@@ -114,7 +114,7 @@ - (BOOL)validateResponse:(NSHTTPURLResponse *)response
BOOL responseIsValid = YES;
NSError *validationError = nil;

if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] &&
!([response MIMEType] == nil && [data length] == 0)) {

@@ -1094,9 +1094,9 @@ - (void)URLSession:(NSURLSession *)session
{

int64_t totalUnitCount = totalBytesExpectedToSend;
if(totalUnitCount == NSURLSessionTransferSizeUnknown) {
if (totalUnitCount == NSURLSessionTransferSizeUnknown) {
NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"];
if(contentLength) {
if (contentLength) {
totalUnitCount = (int64_t) [contentLength longLongValue];
}
}
@@ -219,7 +219,7 @@ - (void)testThatPrioritizedImagesWithOldestLastAccessDatesAreRemovedDuringPurge
UInt64 postPurgeMemoryUsage = self.cache.memoryUsage;
XCTAssertTrue(postPurgeMemoryUsage < prePurgeMemoryUsage);

for (NSUInteger index = 0; index <= numberOfImages ; index++) {
for (NSUInteger index = 0; index <= numberOfImages; index++) {
NSString * identifier = [NSString stringWithFormat:@"image-%ld",(long)index];
UIImage *cachedImage = [self.cache imageWithIdentifier:identifier];
if (index == 0 || index >= 6) {
@@ -561,7 +561,7 @@ - (void)testThatReceiptIDMatchesReturnedID {

@implementation MockAFAutoPurgingImageCache

-(BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
if (self.shouldCache) {
return self.shouldCache(image, request, identifier);
}
@@ -570,7 +570,7 @@ -(BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request with
}
}

-(void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{
- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{
[super addImage:image withIdentifier:identifier];
if (self.addCache) {
self.addCache(image, identifier);
@@ -134,7 +134,7 @@ - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier {
[self.cachedImages removeObjectForKey:cachedImage.identifier];
bytesPurged += cachedImage.totalBytes;
if (bytesPurged >= bytesToPurge) {
break ;
break;
}
}
self.currentMemoryUsage -= bytesPurged;
@@ -168,7 +168,7 @@ - (void)setImageForState:(UIControlState)state
if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
if (success) {
success(request, response, responseObject);
} else if(responseObject) {
} else if (responseObject) {
[strongSelf setImage:responseObject forState:state];
}
[strongSelf af_setImageDownloadReceipt:nil forState:state];
@@ -247,7 +247,7 @@ - (void)setBackgroundImageForState:(UIControlState)state
if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
if (success) {
success(request, response, responseObject);
} else if(responseObject) {
} else if (responseObject) {
[strongSelf setBackgroundImage:responseObject forState:state];
}
[strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
@@ -75,7 +75,6 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
{

if ([urlRequest URL] == nil) {
self.image = placeholderImage;
if (failure) {
@@ -85,7 +84,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
return;
}

if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
if ([self isActiveTaskURLEqualToURLRequest:urlRequest]) {
return;
}

@@ -119,7 +118,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
if (success) {
success(request, response, responseObject);
} else if(responseObject) {
} else if (responseObject) {
strongSelf.image = responseObject;
}
[strongSelf clearActiveDownloadInformation];

0 comments on commit ee95094

Please sign in to comment.