diff --git a/Demo/AGWindowViewDemo/oclint.sh b/Demo/AGWindowViewDemo/oclint.sh new file mode 100755 index 0000000..b4bba24 --- /dev/null +++ b/Demo/AGWindowViewDemo/oclint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +xcodebuild clean build | tee xcodebuild.log +oclint-xcodebuild +oclint-json-compilation-database -v -- -rc=LONG_LINE=150 + + diff --git a/Source/AGWindowView.m b/Source/AGWindowView.m index f4bd9a5..ff26520 100755 --- a/Source/AGWindowView.m +++ b/Source/AGWindowView.m @@ -103,19 +103,18 @@ - (id)initAndAddToKeyWindow { UIWindow *window = [[UIApplication sharedApplication] keyWindow]; self = [self initAndAddToWindow:window]; - if(self) - { - } return self; } -- (void)setup +- (void)setup __attribute__((annotate("oclint:suppress[ivar assignment outside accessors or init]"))) { _supportedInterfaceOrientations = AGInterfaceOrientationMaskAll; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) + name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) + name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; } - (void)dealloc @@ -172,7 +171,9 @@ - (void)rotateAccordingToStatusBarOrientationAndSupportedOrientations } CGAffineTransform transform = CGAffineTransformMakeRotation(angle); - CGRect frame = [[self class] rectInWindowBounds:self.window.bounds statusBarOrientation:statusBarOrientation statusBarHeight:statusBarHeight]; + CGRect frame = [[self class] rectInWindowBounds:self.window.bounds + statusBarOrientation:statusBarOrientation + statusBarHeight:statusBarHeight]; [self setIfNotEqualTransform:transform frame:frame]; } @@ -196,10 +197,7 @@ + (CGFloat)getStatusBarHeight { return [UIApplication sharedApplication].statusBarFrame.size.width; } - else - { - return [UIApplication sharedApplication].statusBarFrame.size.height; - } + return [UIApplication sharedApplication].statusBarFrame.size.height; } static BOOL IS_BELOW_IOS_7() @@ -222,7 +220,9 @@ static BOOL IS_IOS_8_OR_HIGHER() return answer; } -+ (CGRect)rectInWindowBounds:(CGRect)windowBounds statusBarOrientation:(UIInterfaceOrientation)statusBarOrientation statusBarHeight:(CGFloat)statusBarHeight ++ (CGRect)rectInWindowBounds:(CGRect)windowBounds + statusBarOrientation:(UIInterfaceOrientation)statusBarOrientation + statusBarHeight:(CGFloat)statusBarHeight { CGRect frame = windowBounds; @@ -236,7 +236,7 @@ + (CGRect)rectInWindowBounds:(CGRect)windowBounds statusBarOrientation:(UIInterf return frame; } -- (UIInterfaceOrientation)desiredOrientation +- (UIInterfaceOrientation)desiredOrientation __attribute__((annotate("oclint:suppress[bitwise operator in conditional]"))) { UIInterfaceOrientation statusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation]; AGInterfaceOrientationMask statusBarOrientationAsMask = AGInterfaceOrientationMaskFromOrientation(statusBarOrientation); @@ -244,25 +244,19 @@ - (UIInterfaceOrientation)desiredOrientation { return statusBarOrientation; } - else + if(self.supportedInterfaceOrientations & AGInterfaceOrientationMaskPortrait) { - if(self.supportedInterfaceOrientations & AGInterfaceOrientationMaskPortrait) - { - return UIInterfaceOrientationPortrait; - } - else if(self.supportedInterfaceOrientations & AGInterfaceOrientationMaskLandscapeLeft) - { - return UIInterfaceOrientationLandscapeLeft; - } - else if(self.supportedInterfaceOrientations & AGInterfaceOrientationMaskLandscapeRight) - { - return UIInterfaceOrientationLandscapeRight; - } - else - { - return UIInterfaceOrientationPortraitUpsideDown; - } + return UIInterfaceOrientationPortrait; + } + else if(self.supportedInterfaceOrientations & AGInterfaceOrientationMaskLandscapeLeft) + { + return UIInterfaceOrientationLandscapeLeft; } + else if(self.supportedInterfaceOrientations & AGInterfaceOrientationMaskLandscapeRight) + { + return UIInterfaceOrientationLandscapeRight; + } + return UIInterfaceOrientationPortraitUpsideDown; } - (void)didMoveToWindow @@ -292,11 +286,14 @@ - (void)assertCorrectHirearchy { if(self.superview != self.window) { - [NSException raise:NSInternalInconsistencyException format:@"AGWindowView should only be added directly on UIWindow"]; + [NSException raise:NSInternalInconsistencyException + format:@"AGWindowView should only be added directly on UIWindow"]; } if([self.window.subviews indexOfObject:self] == 0) { - [NSException raise:NSInternalInconsistencyException format:@"AGWindowView is not meant to be first subview on window since UIWindow automatically rotates the first view for you."]; + [NSException raise:NSInternalInconsistencyException + format:@"AGWindowView is not meant to be the first subview on window since " + "UIWindow automatically rotates the first view for you."]; } } } @@ -319,7 +316,8 @@ - (void)addSubViewAndKeepSamePosition:(UIView *)view { if(view.superview == nil) { - [NSException raise:NSInternalInconsistencyException format:@"When calling %s we are expecting the view to be moved is already in a view hierarchy.", __PRETTY_FUNCTION__]; + [NSException raise:NSInternalInconsistencyException + format:@"When calling %s we are expecting the view to be moved is already in a view hierarchy.", __PRETTY_FUNCTION__]; } view.frame = [view convertRect:view.bounds toView:self]; @@ -446,26 +444,23 @@ + (AGWindowView *)activeWindowViewContainingView:(UIView *)view @implementation AGWindowViewHelper -BOOL UIInterfaceOrientationsIsForSameAxis(UIInterfaceOrientation o1, UIInterfaceOrientation o2) +BOOL UIInterfaceOrientationsIsForSameAxis(UIInterfaceOrientation orientation1, UIInterfaceOrientation orientation2) { - if(UIInterfaceOrientationIsLandscape(o1) && UIInterfaceOrientationIsLandscape(o2)) + if(UIInterfaceOrientationIsLandscape(orientation1) && UIInterfaceOrientationIsLandscape(orientation2)) { return YES; } - else if(UIInterfaceOrientationIsPortrait(o1) && UIInterfaceOrientationIsPortrait(o2)) + else if(UIInterfaceOrientationIsPortrait(orientation1) && UIInterfaceOrientationIsPortrait(orientation2)) { return YES; } - else - { - return NO; - } + return NO; } -CGFloat UIInterfaceOrientationAngleBetween(UIInterfaceOrientation o1, UIInterfaceOrientation o2) +CGFloat UIInterfaceOrientationAngleBetween(UIInterfaceOrientation orientation1, UIInterfaceOrientation orientation2) { - CGFloat angle1 = UIInterfaceOrientationAngleOfOrientation(o1); - CGFloat angle2 = UIInterfaceOrientationAngleOfOrientation(o2); + CGFloat angle1 = UIInterfaceOrientationAngleOfOrientation(orientation1); + CGFloat angle2 = UIInterfaceOrientationAngleOfOrientation(orientation2); return angle1 - angle2; }