Skip to content

Commit

Permalink
IGListAdapter: Fix not returning early when collectionView/dataSource…
Browse files Browse the repository at this point in the history
… 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 #51

Reviewed By: ocrickard

Differential Revision: D4008605

Pulled By: rnystrom

fbshipit-source-id: c2b7516cb8c1fc619aa63d1e9b0c26f2918cd8a1
  • Loading branch information
benasher44 authored and Facebook Github Bot committed Oct 12, 2016
1 parent bd72c71 commit 992c3b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Source/IGListAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion Source/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ - (void)reloadDataWithCompletion:(nullable IGListUpdaterCompletion)completion {
if (dataSource == nil || collectionView == nil) {
if (completion) {
completion(NO);
return;
}
return;
}

NSArray *newItems = [[dataSource objectsForListAdapter:self] copy];
Expand Down

0 comments on commit 992c3b7

Please sign in to comment.