Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
svoit committed Apr 10, 2018
1 parent 9e005d9 commit 1f70ba8
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions AFNetworking/AFSecurityPolicy.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -290,6 +287,9 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
}
return trustedPublicKeyCount > 0;
}
case AFSSLPinningModeNone:
default:
return NO;
}

return NO;
Expand Down
2 changes: 1 addition & 1 deletion AFNetworking/AFURLResponseSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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)) {

Expand Down
4 changes: 2 additions & 2 deletions AFNetworking/AFURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,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];
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Tests/AFAutoPurgingImageCacheTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Tests/AFImageDownloaderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions UIKit+AFNetworking/AFAutoPurgingImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ @interface AFCachedImage : NSObject

@implementation AFCachedImage

-(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
- (instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
if (self = [self init]) {
self.image = image;
self.identifier = identifier;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions UIKit+AFNetworking/UIButton+AFNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
5 changes: 2 additions & 3 deletions UIKit+AFNetworking/UIImageView+AFNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -85,7 +84,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
return;
}

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

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 1f70ba8

Please sign in to comment.