Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all force unwraps / force try #22

Open
stefanomondino opened this issue Jan 25, 2022 · 0 comments · May be fixed by #25
Open

Remove all force unwraps / force try #22

stefanomondino opened this issue Jan 25, 2022 · 0 comments · May be fixed by #25

Comments

@stefanomondino
Copy link
Contributor

After #18 is merged, we should work on SDK safety.

Code is still full of force unwraps (someVar!.something()) and force try (try! something) which is dangerous as it could lead to crashes.

We should remove all of them, apps should not crash because of our SDK.

Fixing strategy should be:

  • if a method is already throwing, simply use try instead of try!. If error is not blocking, use try? and provide a fallback value
  • if a method is not marked as throwing, use try? and provide fallback value with nil coalescing operator (let value = (try? something()) ?? defaultValue)
  • in testSomething methods (Unit tests with XCTest, in Tests folder), simply add throws to method declaration

It's not easy to spot them all, but using Xcode looking glass and searching for try! can be a good start.

@Jesulonimi21 Jesulonimi21 linked a pull request Feb 7, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant