Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Fix simple OCLint warnings #337

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Carthage/Build
fastlane/report.xml
fastlane/screenshots

# Infer
infer-out

# Documentation
documentation/output/

Expand Down
47 changes: 24 additions & 23 deletions sources/HUBAutoEquatable.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,36 @@ - (HUBAutoEquatableComparisonMap *)getOrCreateComparisonMap

HUBAutoEquatableComparisonMap *comparisonMap = comparisonMapsForClassNames[className];

if (comparisonMap == nil) {
NSSet<NSString *> * const ignoredPropertyNames = [[self class] ignoredAutoEquatablePropertyNames];
HUBAutoEquatableMutableComparisonMap * const mutableComparisonMap = [HUBAutoEquatableMutableComparisonMap new];
if (comparisonMap != nil) {
return comparisonMap;
}

NSSet<NSString *> * const ignoredPropertyNames = [[self class] ignoredAutoEquatablePropertyNames];
HUBAutoEquatableMutableComparisonMap * const mutableComparisonMap = [HUBAutoEquatableMutableComparisonMap new];

unsigned int propertyCount;
const objc_property_t * propertyList = class_copyPropertyList([self class], &propertyCount);

for (unsigned int i = 0; i < propertyCount; i++) {
const objc_property_t property = propertyList[i];
const char * propertyNameCString = property_getName(property);
NSString * const propertyName = [NSString stringWithUTF8String:propertyNameCString];

unsigned int propertyCount;
const objc_property_t * propertyList = class_copyPropertyList([self class], &propertyCount);
if (protocol_getProperty(@protocol(NSObject), propertyNameCString, YES, YES) != NULL) {
continue;
}

for (unsigned int i = 0; i < propertyCount; i++) {
const objc_property_t property = propertyList[i];
const char * propertyNameCString = property_getName(property);
NSString * const propertyName = [NSString stringWithUTF8String:propertyNameCString];

if (protocol_getProperty(@protocol(NSObject), propertyNameCString, YES, YES) != NULL) {
continue;
}

if ([ignoredPropertyNames containsObject:propertyName]) {
continue;
}

mutableComparisonMap[propertyName] = ^(NSObject * const objectA, NSObject * const objectB) {
return HUBPropertyIsEqual(objectA, objectB, propertyName);
};
if ([ignoredPropertyNames containsObject:propertyName]) {
continue;
}

comparisonMap = mutableComparisonMap;
comparisonMapsForClassNames[className] = comparisonMap;
mutableComparisonMap[propertyName] = ^(NSObject * const objectA, NSObject * const objectB) {
return HUBPropertyIsEqual(objectA, objectB, propertyName);
};
}

comparisonMap = mutableComparisonMap;
comparisonMapsForClassNames[className] = comparisonMap;
return comparisonMap;
}

Expand Down
10 changes: 4 additions & 6 deletions sources/HUBCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ - (void)setContentOffset:(CGPoint)contentOffset
{
id<HUBCollectionViewDelegate> const delegate = self.delegate;

if (delegate != nil) {
if (![delegate collectionViewShouldBeginScrolling:self]) {
self.panGestureRecognizer.enabled = NO;
self.panGestureRecognizer.enabled = YES;
return;
}
if (delegate != nil && ![delegate collectionViewShouldBeginScrolling:self]) {
self.panGestureRecognizer.enabled = NO;
self.panGestureRecognizer.enabled = YES;
return;
}

[super setContentOffset:contentOffset];
Expand Down
2 changes: 1 addition & 1 deletion sources/HUBComponentModelBuilderImplementation.m
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ - (id)copyWithZone:(nullable NSZone *)zone
id<HUBComponentImageData> const imageData = [builder buildWithIdentifier:imageIdentifier type:HUBComponentImageTypeCustom];

if (imageData != nil) {
[customImageData setObject:imageData forKey:imageIdentifier];
customImageData[imageIdentifier] = imageData;
}
}

Expand Down
10 changes: 4 additions & 6 deletions sources/HUBComponentWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,10 @@ - (void)loadView
BOOL const viewLoaded = (self.view != nil);
UIView * const view = HUBComponentLoadViewIfNeeded(self.component);

if (!viewLoaded) {
if (HUBConformsToProtocol(self.component, @protocol(HUBComponentViewObserver))) {
HUBComponentResizeObservingView * const resizeObservingView = [[HUBComponentResizeObservingView alloc] initWithFrame:view.bounds];
resizeObservingView.delegate = self;
[view addSubview:resizeObservingView];
}
if (!viewLoaded && HUBConformsToProtocol(self.component, @protocol(HUBComponentViewObserver))) {
HUBComponentResizeObservingView * const resizeObservingView = [[HUBComponentResizeObservingView alloc] initWithFrame:view.bounds];
resizeObservingView.delegate = self;
[view addSubview:resizeObservingView];
}
}

Expand Down
18 changes: 9 additions & 9 deletions sources/HUBDefaultComponentLayoutManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ - (CGFloat)horizontalMarginForComponentWithLayoutTraits:(NSSet<HUBComponentLayou
{
if ([layoutTraits containsObject:HUBComponentLayoutTraitFullWidth]) {
return 0;
} else {
BOOL const isCentered = [layoutTraits containsObject:HUBComponentLayoutTraitCentered];
BOOL const precedingIsCentered = [precedingComponentLayoutTraits containsObject:HUBComponentLayoutTraitCentered];

// Centered components are always grouped toghether
if (isCentered != precedingIsCentered) {
return CGFLOAT_MAX;
}
}


BOOL const isCentered = [layoutTraits containsObject:HUBComponentLayoutTraitCentered];
BOOL const precedingIsCentered = [precedingComponentLayoutTraits containsObject:HUBComponentLayoutTraitCentered];

// Centered components are always grouped toghether
if (isCentered != precedingIsCentered) {
return CGFLOAT_MAX;
}

return self.margin;
}

Expand Down
5 changes: 1 addition & 4 deletions sources/HUBDefaultConnectivityStateResolver.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,10 @@ - (void)startObservingReachability
- (SCNetworkReachabilityContext)createReachabilityContext
{
__weak __typeof(self) weakSelf = self;

SCNetworkReachabilityContext const context = {
return (SCNetworkReachabilityContext){
.version = 0,
.info = (__bridge void *)weakSelf
};

return context;
}

- (HUBConnectivityState)connectivityStateFromReachabilityFlags:(SCNetworkReachabilityFlags)flags
Expand Down
3 changes: 1 addition & 2 deletions sources/HUBIconImplementation.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ - (nullable UIImage *)imageWithSize:(CGSize)size color:(UIColor *)color
{
if (self.isPlaceholder) {
return [self.imageResolver imageForPlaceholderIconWithIdentifier:self.identifier size:size color:color];
} else {
return [self.imageResolver imageForComponentIconWithIdentifier:self.identifier size:size color:color];
}
return [self.imageResolver imageForComponentIconWithIdentifier:self.identifier size:size color:color];
}

@end
4 changes: 2 additions & 2 deletions sources/HUBLiveServiceFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ - (id)createLiveService
{
#if HUB_DEBUG
return [HUBLiveServiceImplementation new];
#endif

#else
return nil;
#endif
}

@end
22 changes: 9 additions & 13 deletions sources/HUBViewControllerExperimentalImplementation.m
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,9 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
currentContentOffset:scrollView.contentOffset
proposedContentOffset:*targetContentOffset];

if (targetContentOffset->y >= (scrollView.contentSize.height - CGRectGetHeight(scrollView.frame))) {
if (!self.viewModelLoader.isLoading) {
[self.viewModelLoader loadNextPageForCurrentViewModel];
}
CGFloat threshold = scrollView.contentSize.height - CGRectGetHeight(scrollView.frame);
if (targetContentOffset->y >= threshold && !self.viewModelLoader.isLoading) {
[self.viewModelLoader loadNextPageForCurrentViewModel];
}
}

Expand Down Expand Up @@ -842,7 +841,7 @@ - (void)renderViewModel:(id<HUBViewModel>)viewModel
completion:(void (^)(void))completionBlock
{
__weak __typeof(self) weakSelf = self;
void (^renderBlock)() = ^{
void (^renderBlock)(void) = ^{
__strong __typeof(self) strongSelf = weakSelf;
[strongSelf renderViewModel:viewModel
addHeaderMargin:addHeaderMargin
Expand Down Expand Up @@ -974,8 +973,7 @@ - (CGFloat)calculateTopContentInset
CGFloat const statusBarHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
CGFloat const navigationBarWidth = CGRectGetWidth(self.navigationController.navigationBar.frame);
CGFloat const navigationBarHeight = CGRectGetHeight(self.navigationController.navigationBar.frame);
CGFloat const topBarHeight = MIN(statusBarWidth, statusBarHeight) + MIN(navigationBarWidth, navigationBarHeight);
return topBarHeight;
return MIN(statusBarWidth, statusBarHeight) + MIN(navigationBarWidth, navigationBarHeight);
}

- (BOOL)shouldAutomaticallyManageTopContentInset
Expand Down Expand Up @@ -1138,10 +1136,8 @@ - (void)collectionViewCellWillAppear:(HUBComponentCollectionViewCell *)cell
return;
}

if (wrapper.viewHasAppearedSinceLastModelChange) {
if (!ignorePreviousAppearance) {
return;
}
if (wrapper.viewHasAppearedSinceLastModelChange && !ignorePreviousAppearance) {
return;
}

[self componentWrapperWillAppear:wrapper];
Expand Down Expand Up @@ -1255,7 +1251,7 @@ - (void)removeComponentWrapperFromLookupTables:(nullable HUBComponentWrapper *)c
- (void)scrollToRootBodyComponentAtIndex:(NSUInteger)componentIndex
scrollPosition:(HUBScrollPosition)scrollPosition
animated:(BOOL)animated
completion:(void (^)())completion
completion:(void (^)(void))completion
{
NSParameterAssert(componentIndex <= (NSUInteger)[self.collectionView numberOfItemsInSection:0]);

Expand Down Expand Up @@ -1298,7 +1294,7 @@ - (void)scrollToRemainingComponentsOfType:(HUBComponentType)componentType
}

__weak HUBViewControllerExperimentalImplementation *weakSelf = self;
void (^stepCompletionHandler)() = ^{
void (^stepCompletionHandler)(void) = ^{
HUBViewControllerExperimentalImplementation *strongSelf = weakSelf;

HUBComponentWrapper *childComponentWrapper = nil;
Expand Down
3 changes: 1 addition & 2 deletions sources/HUBViewControllerFactoryImplementation.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ - (HUBViewController *)createViewControllerForViewURI:(NSURL *)viewURI
BOOL useV2 = [featureRegistration.options[@"HUBViewController"] isEqualToString:@"v2"];
if (useV2) {
return [self createExperimentalViewControllerForViewURI:viewURI featureRegistration:featureRegistration];
} else {
return [self createStandardViewControllerForViewURI:viewURI featureRegistration:featureRegistration];
}
return [self createStandardViewControllerForViewURI:viewURI featureRegistration:featureRegistration];
}

- (HUBViewController *)createStandardViewControllerForViewURI:(NSURL *)viewURI
Expand Down
20 changes: 8 additions & 12 deletions sources/HUBViewControllerImplementation.m
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,9 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
currentContentOffset:scrollView.contentOffset
proposedContentOffset:*targetContentOffset];

if (targetContentOffset->y >= (scrollView.contentSize.height - CGRectGetHeight(scrollView.frame))) {
if (!self.viewModelLoader.isLoading) {
[self.viewModelLoader loadNextPageForCurrentViewModel];
}
CGFloat threshold = scrollView.contentSize.height - CGRectGetHeight(scrollView.frame);
if (targetContentOffset->y >= threshold && !self.viewModelLoader.isLoading) {
[self.viewModelLoader loadNextPageForCurrentViewModel];
}
}

Expand Down Expand Up @@ -939,8 +938,7 @@ - (CGFloat)calculateTopContentInset
CGFloat const statusBarHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
CGFloat const navigationBarWidth = CGRectGetWidth(self.navigationController.navigationBar.frame);
CGFloat const navigationBarHeight = CGRectGetHeight(self.navigationController.navigationBar.frame);
CGFloat const topBarHeight = MIN(statusBarWidth, statusBarHeight) + MIN(navigationBarWidth, navigationBarHeight);
return topBarHeight;
return MIN(statusBarWidth, statusBarHeight) + MIN(navigationBarWidth, navigationBarHeight);
}

- (BOOL)shouldAutomaticallyManageTopContentInset
Expand Down Expand Up @@ -1103,10 +1101,8 @@ - (void)collectionViewCellWillAppear:(HUBComponentCollectionViewCell *)cell
return;
}

if (wrapper.viewHasAppearedSinceLastModelChange) {
if (!ignorePreviousAppearance) {
return;
}
if (wrapper.viewHasAppearedSinceLastModelChange && !ignorePreviousAppearance) {
return;
}

[self componentWrapperWillAppear:wrapper];
Expand Down Expand Up @@ -1220,7 +1216,7 @@ - (void)removeComponentWrapperFromLookupTables:(nullable HUBComponentWrapper *)c
- (void)scrollToRootBodyComponentAtIndex:(NSUInteger)componentIndex
scrollPosition:(HUBScrollPosition)scrollPosition
animated:(BOOL)animated
completion:(void (^)())completion
completion:(void (^)(void))completion
{
NSParameterAssert(componentIndex <= (NSUInteger)[self.collectionView numberOfItemsInSection:0]);

Expand Down Expand Up @@ -1263,7 +1259,7 @@ - (void)scrollToRemainingComponentsOfType:(HUBComponentType)componentType
}

__weak HUBViewControllerImplementation *weakSelf = self;
void (^stepCompletionHandler)() = ^{
void (^stepCompletionHandler)(void) = ^{
HUBViewControllerImplementation *strongSelf = weakSelf;

HUBComponentWrapper *childComponentWrapper = nil;
Expand Down
2 changes: 1 addition & 1 deletion sources/HUBViewModelBuilderImplementation.m
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ - (void)setCustomDataValue:(nullable id)value forKey:(nonnull NSString *)key
if (value == nil) {
[customData removeObjectForKey:key];
} else {
[customData setObject:(id)value forKey:key];
customData[key] = value;
}

self.customData = customData;
Expand Down