Better nullability and error handling#315
Open
ZevEisenberg wants to merge 8 commits intoAliSoftware:masterfrom
Open
Better nullability and error handling#315ZevEisenberg wants to merge 8 commits intoAliSoftware:masterfrom
ZevEisenberg wants to merge 8 commits intoAliSoftware:masterfrom
Conversation
added 8 commits
September 18, 2019 14:04
… is an issue reading the input file.
…ndefined unless result signals failure via a nil value.
AliSoftware
approved these changes
Sep 18, 2019
| @interface OHHTTPStubs() | ||
| + (instancetype)sharedInstance; | ||
| @property(atomic, copy) NSMutableArray* stubDescriptors; | ||
| @property(atomic, readonly) NSMutableArray* stubDescriptors; |
Owner
There was a problem hiding this comment.
Problem with this is, it's a reference type. So that means that users can't set stubDescriptors = newValue but they can [stubDescriptors append:…] though can't they?
Owner
There was a problem hiding this comment.
Oh wait it's in the private category so not exposed to the consumer is it? (Not easy to review from phone 😅)
Author
There was a problem hiding this comment.
(Forgot to reply originally) copy never works on properties of NSMutableCopying type, because the setter calls -copy, which returns an immutable copy, i.e. an NSArray in this case. So you’d set a mutable array, and the value that gets stored would be immutable. Fun edge case in Obj-C land that should probably be a compile error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
Fixes #290
Also does more idiomatic error handling:
Wrong:
Correct:
Motivation and Context
The main motivation was addressing static analysis warnings I encountered when analyzing an Objective-C project. The error handling was just something I fixed along the way.
Note: I also added a couple of missing generics annotations which may affect the public interface. If they are imported into Swift, they will go from
[Any]to[OHHTTPStubsDescriptor].This is a breaking change for anyone who is using the output of this method in Swift.Actually, it may not be breaking, since in Swift, they were probably already doing something likefor descriptor in descriptors as! [OHHTTPStubsDescriptor], and after this update, that line will throw a compile warning, not an error. So this can probably be a bugfix, not a major release.Testing: I added a couple of missing tests for error throwing cases, and made sure all the tests were passing.