From 4b393099255759b944b249360f88b403039d32d1 Mon Sep 17 00:00:00 2001 From: Akiva Leffert Date: Fri, 20 Mar 2015 14:28:29 -0400 Subject: [PATCH] Enable the Static Analyzer on build and fix all warnings. This fixes a pretty bad leak of an image. The other fixes look pretty unimportant. --- edXVideoLocker.xcodeproj/project.pbxproj | 9 +++++---- .../xcschemes/edXVideoLockerTests.xcscheme | 11 ++++++++++- edXVideoLocker/CutomePlayer/CLPortraitOptionsView.m | 1 - edXVideoLocker/CutomePlayer/CLVideoPlayerControls.m | 6 +----- edXVideoLocker/OEXCourseInfoTabViewController.m | 1 + .../OEXCourseVideoDownloadTableViewController.m | 1 + edXVideoLocker/OEXCustomTabBarViewViewController.m | 1 + edXVideoLocker/OEXDownloadViewController.m | 2 ++ edXVideoLocker/OEXFrontCourseViewController.m | 1 + edXVideoLocker/OEXGenericCourseTableViewController.m | 11 ----------- edXVideoLocker/OEXInterface.m | 3 +-- edXVideoLocker/OEXLoginViewController.m | 4 +--- edXVideoLocker/OEXMyVideosSubSectionViewController.m | 1 + edXVideoLocker/OEXMyVideosViewController.m | 2 +- edXVideoLocker/OEXRearTableViewController.m | 1 + edXVideoLocker/OEXRegistrationViewController.m | 1 + .../OEXUserLicenseAgreementViewController.m | 2 ++ edXVideoLocker/OEXVideoPlayerInterface.m | 2 ++ edXVideoLockerTests/NSString+OEXFormattingTests.m | 4 ++-- 19 files changed, 34 insertions(+), 30 deletions(-) diff --git a/edXVideoLocker.xcodeproj/project.pbxproj b/edXVideoLocker.xcodeproj/project.pbxproj index fb4470ebfb..bea2abfa14 100644 --- a/edXVideoLocker.xcodeproj/project.pbxproj +++ b/edXVideoLocker.xcodeproj/project.pbxproj @@ -226,7 +226,6 @@ B498407A19753C7B00019D1F /* movieForward@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B498406B19753C7B00019D1F /* movieForward@2x.png */; }; B49A390B1975919C00850002 /* OEXCustomSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = B49A390A1975919C00850002 /* OEXCustomSlider.m */; }; B4A24D0D19EE8A6600CE5010 /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B4A24D0C19EE8A6600CE5010 /* CoreMedia.framework */; }; - B4A9EA231966A2FA00AAB3DB /* NSObject+OEXReplaceNull.m in Sources */ = {isa = PBXBuildFile; fileRef = B4A9EA221966A2FA00AAB3DB /* NSObject+OEXReplaceNull.m */; }; B4B285D01A97240200DD603A /* spinner@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B4B285CE1A97240200DD603A /* spinner@2x.png */; }; B4B285D11A97240200DD603A /* spinner@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = B4B285CF1A97240200DD603A /* spinner@3x.png */; }; B4B285D91A9A48D500DD603A /* OEXGoogleConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = B4B285D81A9A48D500DD603A /* OEXGoogleConfig.m */; }; @@ -1785,7 +1784,7 @@ BECB7B031924C0C3009C77F1 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0620; ORGANIZATIONNAME = edX; TargetAttributes = { BECB7B0A1924C0C3009C77F1 = { @@ -2152,8 +2151,7 @@ 199627A71945D95D0022C489 /* OEXFrontTableViewCell.m in Sources */, 1913DD3D194B267000573977 /* OEXDownloadViewController.m in Sources */, 7764597F1A096339008404CC /* NSString+OEXEncoding.m in Sources */, - B4A9EA231966A2FA00AAB3DB /* NSObject+OEXReplaceNull.m in Sources */, - B4A9EA231966A2FA00AAB3DB /* NSObject+OEXReplaceNull.m in Sources */, + 77DC295E1ABC9D4400FAD22C /* NSObject+OEXReplaceNull.m in Sources */, B4B6D6031A949EFC000F44E8 /* OEXRegistrationOption.m in Sources */, 770A279D1A6F150B00DFC6FF /* OEXVideoPathEntry.m in Sources */, B4B6D6161A949F0F000F44E8 /* OEXRegistrationFieldEmailView.m in Sources */, @@ -2286,6 +2284,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 7.1; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = edX; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; }; name = Coverage; @@ -2375,6 +2374,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 7.1; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = edX; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; }; name = Debug; @@ -2411,6 +2411,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 7.1; PRODUCT_NAME = edX; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; diff --git a/edXVideoLocker.xcodeproj/xcshareddata/xcschemes/edXVideoLockerTests.xcscheme b/edXVideoLocker.xcodeproj/xcshareddata/xcschemes/edXVideoLockerTests.xcscheme index 2f8278a096..6867b4f8c0 100644 --- a/edXVideoLocker.xcodeproj/xcshareddata/xcschemes/edXVideoLockerTests.xcscheme +++ b/edXVideoLocker.xcodeproj/xcshareddata/xcschemes/edXVideoLockerTests.xcscheme @@ -1,6 +1,6 @@ + + + + diff --git a/edXVideoLocker/CutomePlayer/CLPortraitOptionsView.m b/edXVideoLocker/CutomePlayer/CLPortraitOptionsView.m index f6b5f638a1..6ff8e4e9c0 100644 --- a/edXVideoLocker/CutomePlayer/CLPortraitOptionsView.m +++ b/edXVideoLocker/CutomePlayer/CLPortraitOptionsView.m @@ -309,7 +309,6 @@ - (void)setPersistedLanguage { break; } if(i == [self.arr_Values count] - 1) { - strLanguage = @""; return; } } diff --git a/edXVideoLocker/CutomePlayer/CLVideoPlayerControls.m b/edXVideoLocker/CutomePlayer/CLVideoPlayerControls.m index 35465c7b5a..769811b014 100644 --- a/edXVideoLocker/CutomePlayer/CLVideoPlayerControls.m +++ b/edXVideoLocker/CutomePlayer/CLVideoPlayerControls.m @@ -421,8 +421,7 @@ - (void)callPortraitSubtitles:(NSNotification*)notification { self.btnSettings.selected = NO; [_btnSettings setImage:[UIImage imageNamed:@"ic_settings.png"] forState:UIControlStateNormal]; - NSString* Key = [[NSString alloc] init]; - Key = [[dict allKeys] lastObject]; + NSString* Key = [[dict allKeys] lastObject]; if([Key isEqualToString:KEY_SET_PLAYBACKSPEED]) { NSString* oldSpeed = [NSString stringWithFormat:@"%.1f", self.playbackRate]; @@ -883,7 +882,6 @@ - (void)setPersistedLanguage { break; } if(i == [self.arr_Values count] - 1) { - strLanguage = @""; return; } } @@ -1927,8 +1925,6 @@ - (void)setDefaultPlaybackSpeed { - (void)moviePlaybackStateDidChange:(NSNotification*)note { __weak CLVideoPlayerControls* weakSelf = self; - NSString* strLanguage = [[NSString alloc] init]; - strLanguage = [OEXInterface getCCSelectedLanguage]; switch(weakSelf.moviePlayer.playbackState) { case MPMoviePlaybackStateStopped: diff --git a/edXVideoLocker/OEXCourseInfoTabViewController.m b/edXVideoLocker/OEXCourseInfoTabViewController.m index 369dfe374e..099a7b7403 100644 --- a/edXVideoLocker/OEXCourseInfoTabViewController.m +++ b/edXVideoLocker/OEXCourseInfoTabViewController.m @@ -135,6 +135,7 @@ -(void)computeBlurredCourseImage { dispatch_async(dispatch_get_main_queue(), ^{ self.img_Course.image = blurredImage; }); + CGImageRelease(cgImage); } -(void)addAnnouncementsWebView { diff --git a/edXVideoLocker/OEXCourseVideoDownloadTableViewController.m b/edXVideoLocker/OEXCourseVideoDownloadTableViewController.m index 6e0c89b2b2..f9d9c371c3 100644 --- a/edXVideoLocker/OEXCourseVideoDownloadTableViewController.m +++ b/edXVideoLocker/OEXCourseVideoDownloadTableViewController.m @@ -199,6 +199,7 @@ - (void)viewWillAppear:(BOOL)animated { } - (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; if(self.navigationController.topViewController != self) { [[CLPortraitOptionsView sharedInstance] removeSelfFromSuperView]; diff --git a/edXVideoLocker/OEXCustomTabBarViewViewController.m b/edXVideoLocker/OEXCustomTabBarViewViewController.m index f41ba9b616..7eab44d6eb 100644 --- a/edXVideoLocker/OEXCustomTabBarViewViewController.m +++ b/edXVideoLocker/OEXCustomTabBarViewViewController.m @@ -224,6 +224,7 @@ - (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil { } -(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; [self removeObserver]; } diff --git a/edXVideoLocker/OEXDownloadViewController.m b/edXVideoLocker/OEXDownloadViewController.m index 61756da4d5..d2c2311c2d 100644 --- a/edXVideoLocker/OEXDownloadViewController.m +++ b/edXVideoLocker/OEXDownloadViewController.m @@ -102,6 +102,7 @@ - (void)reachabilityDidChange:(NSNotification*)notification { } -(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; [[NSNotificationCenter defaultCenter] removeObserver:self name:DOWNLOAD_PROGRESS_NOTIFICATION object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:VIDEO_DL_COMPLETE object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil]; @@ -123,6 +124,7 @@ - (void)viewWillAppear:(BOOL)animated { } -(void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; [self downloadCompleteNotification:nil]; } diff --git a/edXVideoLocker/OEXFrontCourseViewController.m b/edXVideoLocker/OEXFrontCourseViewController.m index 2432a5a812..26573a4606 100644 --- a/edXVideoLocker/OEXFrontCourseViewController.m +++ b/edXVideoLocker/OEXFrontCourseViewController.m @@ -292,6 +292,7 @@ -(void)viewWillAppear:(BOOL)animated { } -(void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; self.view.userInteractionEnabled = YES; [self showHideOfflineModeView]; } diff --git a/edXVideoLocker/OEXGenericCourseTableViewController.m b/edXVideoLocker/OEXGenericCourseTableViewController.m index 38c613cceb..db9b09b25d 100644 --- a/edXVideoLocker/OEXGenericCourseTableViewController.m +++ b/edXVideoLocker/OEXGenericCourseTableViewController.m @@ -169,7 +169,6 @@ - (void)viewDidLoad { //Add oserver [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTotalDownloadProgress:) name:TOTAL_DL_PROGRESS object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showFloatingView:) name:FL_MESSAGE object:nil]; [[self.dataInterface progressViews] addObject:self.customProgressBar]; [[self.dataInterface progressViews] addObject:self.btn_Downloads]; @@ -187,16 +186,6 @@ - (void)viewDidLoad { #pragma update total download progress --(void)showFloatingView:(NSNotification* )notification { - NSDictionary* progress = (NSDictionary*)notification.userInfo; - - NSArray* array = [progress objectForKey:FL_ARRAY]; - NSString* sString = @""; - if(array.count > 1) { - sString = OEXLocalizedString(@"s", nil); - } -} - -(void)updateTotalDownloadProgress:(NSNotification* )notification { [self.customProgressBar setProgress:_dataInterface.totalProgress animated:YES]; [self performSelector:@selector(reloadTableOnMainThread) withObject:nil afterDelay:1.5]; diff --git a/edXVideoLocker/OEXInterface.m b/edXVideoLocker/OEXInterface.m index cf951ba0cf..774be2bcc2 100644 --- a/edXVideoLocker/OEXInterface.m +++ b/edXVideoLocker/OEXInterface.m @@ -1211,8 +1211,7 @@ - (NSString*)getFormattedDate { NSDate* date = [NSDate date]; NSDateFormatter* format = [[NSDateFormatter alloc] init]; [format setDateFormat:@"YYYY-MM-dd HH:mm:ss.SSSSSSZ"]; - NSString* strdate = [[NSString alloc] init]; - strdate = [format stringFromDate:date]; + NSString* strdate = [format stringFromDate:date]; NSString* substringFirst = [strdate substringToIndex:29]; NSString* substringsecond = [strdate substringFromIndex:29]; diff --git a/edXVideoLocker/OEXLoginViewController.m b/edXVideoLocker/OEXLoginViewController.m index c8bf787cfd..0f02a5fc29 100644 --- a/edXVideoLocker/OEXLoginViewController.m +++ b/edXVideoLocker/OEXLoginViewController.m @@ -264,6 +264,7 @@ - (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil { } -(void) viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.view setUserInteractionEnabled:NO]; @@ -272,9 +273,6 @@ -(void) viewWillDisappear:(BOOL)animated { } } --(void)viewDidAppear:(BOOL)animated { -} - - (void)hideOverlay { self.imgOverlay.hidden = YES; } diff --git a/edXVideoLocker/OEXMyVideosSubSectionViewController.m b/edXVideoLocker/OEXMyVideosSubSectionViewController.m index 826ed7aaa5..bbe2a8d9d9 100644 --- a/edXVideoLocker/OEXMyVideosSubSectionViewController.m +++ b/edXVideoLocker/OEXMyVideosSubSectionViewController.m @@ -805,6 +805,7 @@ -(void)dealloc { } - (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; if(self.navigationController.topViewController != self) { [[CLPortraitOptionsView sharedInstance] removeSelfFromSuperView]; [self.videoPlayerInterface.moviePlayerController pause]; diff --git a/edXVideoLocker/OEXMyVideosViewController.m b/edXVideoLocker/OEXMyVideosViewController.m index 6009738f1f..f451b7fac9 100644 --- a/edXVideoLocker/OEXMyVideosViewController.m +++ b/edXVideoLocker/OEXMyVideosViewController.m @@ -1217,7 +1217,7 @@ -(void)dealloc { } - (void)viewWillDisappear:(BOOL)animated { - //NSLog(@"DEALLOC my videos"); + [super viewWillDisappear:animated]; if(self.navigationController.topViewController != self) { [[CLPortraitOptionsView sharedInstance] removeSelfFromSuperView]; [self.videoPlayerInterface.moviePlayerController pause]; diff --git a/edXVideoLocker/OEXRearTableViewController.m b/edXVideoLocker/OEXRearTableViewController.m index 90f6ba4ebe..31b5666cdb 100644 --- a/edXVideoLocker/OEXRearTableViewController.m +++ b/edXVideoLocker/OEXRearTableViewController.m @@ -234,6 +234,7 @@ - (void)pop { } -(void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; [self.view setUserInteractionEnabled:YES]; } diff --git a/edXVideoLocker/OEXRegistrationViewController.m b/edXVideoLocker/OEXRegistrationViewController.m index 98a2fe048b..aee14422ae 100644 --- a/edXVideoLocker/OEXRegistrationViewController.m +++ b/edXVideoLocker/OEXRegistrationViewController.m @@ -158,6 +158,7 @@ -(void)viewWillAppear:(BOOL)animated { } -(void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; // This will remove observer for keyboard [[NSNotificationCenter defaultCenter] removeObserver:self]; } diff --git a/edXVideoLocker/OEXUserLicenseAgreementViewController.m b/edXVideoLocker/OEXUserLicenseAgreementViewController.m index 387e38de64..dbac29a04d 100644 --- a/edXVideoLocker/OEXUserLicenseAgreementViewController.m +++ b/edXVideoLocker/OEXUserLicenseAgreementViewController.m @@ -35,10 +35,12 @@ - (void)viewDidLoad { } -(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; [UIApplication sharedApplication].statusBarHidden = YES; } -(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; [UIApplication sharedApplication].statusBarHidden = NO; } diff --git a/edXVideoLocker/OEXVideoPlayerInterface.m b/edXVideoLocker/OEXVideoPlayerInterface.m index 354e09b36b..e20e991d3d 100644 --- a/edXVideoLocker/OEXVideoPlayerInterface.m +++ b/edXVideoLocker/OEXVideoPlayerInterface.m @@ -205,12 +205,14 @@ -(void)willResignActive:(NSNotification*)notification { } -(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; [NSObject cancelPreviousPerformRequestsWithTarget:self]; [_moviePlayerController setShouldAutoplay:NO]; _shouldRotate = NO; } -(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; [_moviePlayerController setShouldAutoplay:YES]; _shouldRotate = YES; } diff --git a/edXVideoLockerTests/NSString+OEXFormattingTests.m b/edXVideoLockerTests/NSString+OEXFormattingTests.m index 7968e62c71..3d3ae5ce4f 100644 --- a/edXVideoLockerTests/NSString+OEXFormattingTests.m +++ b/edXVideoLockerTests/NSString+OEXFormattingTests.m @@ -51,12 +51,12 @@ - (void)testFormatMultipleReplacement { - (void)testMissingArgument { NSString* format = @"{param} {arg} with {param} {arg} in it"; - XCTAssertThrowsSpecific([NSString oex_stringWithFormat:format parameters:@{@"param" : @"some"}], NSException); + XCTAssertThrows([NSString oex_stringWithFormat:format parameters:@{@"param" : @"some"}]); } - (void)testExtraParameter { NSString* format = @"{arg} some text"; - XCTAssertThrowsSpecific([NSString oex_stringWithFormat:format parameters:@{}], NSException); + XCTAssertThrows([NSString oex_stringWithFormat:format parameters:@{}]); } #endif