From 992c3b7caa30251bd5c35cc36caa49832168e7e8 Mon Sep 17 00:00:00 2001 From: Ben Asher Date: Wed, 12 Oct 2016 09:27:04 -0700 Subject: [PATCH] IGListAdapter: Fix not returning early when collectionView/dataSource is nil and completion is nil Summary: - I ran the static analyzer, and it found a case in `performUpdatesAnimated:completion:` where it looks like we meant to bail out early if the `collectionView` or `dataSource` is nil, but it only does so if `completion` is provided. - Fixed a spelling error in nearby documentation - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/CONTRIBUTING.md) - There is one other analyzer warning, but it seems to be making an incorrect assumption. In any case, it's not something I can fix quickly (requires more time spent staring at IGListDiff.mm). - A ticket should be opened to add static analysis to .travis.yml. I'lll do this soonish, unless someone beats me to it! - I could add a test for this, but this project is annotated well enough with null Closes https://github.com/Instagram/IGListKit/pull/51 Reviewed By: ocrickard Differential Revision: D4008605 Pulled By: rnystrom fbshipit-source-id: c2b7516cb8c1fc619aa63d1e9b0c26f2918cd8a1 --- Source/IGListAdapter.h | 4 ++-- Source/IGListAdapter.m | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/IGListAdapter.h b/Source/IGListAdapter.h index 79f50eec..5e4f76c3 100644 --- a/Source/IGListAdapter.h +++ b/Source/IGListAdapter.h @@ -103,14 +103,14 @@ IGLK_SUBCLASSING_RESTRICTED - (void)performUpdatesAnimated:(BOOL)animated completion:(nullable IGListUpdaterCompletion)completion; /** - Perform an immediate reload of the data in the data source, discarding the old objectss. + Perform an immediate reload of the data in the data source, discarding the old objects. @param completion A block executed when the reload completes. */ - (void)reloadDataWithCompletion:(nullable IGListUpdaterCompletion)completion; /** - Reload the infra for specific objectss only. + Reload the infra for specific objects only. @param objects The objects to reload. */ diff --git a/Source/IGListAdapter.m b/Source/IGListAdapter.m index cb9524b2..05610204 100644 --- a/Source/IGListAdapter.m +++ b/Source/IGListAdapter.m @@ -248,8 +248,8 @@ if (dataSource == nil || collectionView == nil) { if (completion) { completion(NO); - return; } + return; } NSArray *newItems = [[dataSource objectsForListAdapter:self] copy];