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

Removing force unwrapping #732

Open
TomasLinhart opened this issue Sep 22, 2020 · 1 comment
Open

Removing force unwrapping #732

TomasLinhart opened this issue Sep 22, 2020 · 1 comment
Assignees
Labels

Comments

@TomasLinhart
Copy link
Contributor

TomasLinhart commented Sep 22, 2020

Currently, there are a lot of force-unwraps of optionals in the codebase. For example, SVGParser contains a few unchecked force-unwraps that can result in a crash for non-ideal SVGs. We had a chance to experience these crashes.

Would you be open to removing these force-unwraps?

It also seems it is more prevalent use x != nil ... x! instead of using if let or guard let.

Would you accept a pull request that addresses the force-unwraps and replaces them with safer options (errors, logging, fallbacks)?

@ystrot ystrot self-assigned this Sep 23, 2020
@ystrot
Copy link
Member

ystrot commented Sep 23, 2020

Hi Tomas!

That's definitely a must-have parser improvement. I'd like to use logger during parsing and provide different methods in SVGParser:

  1. Safe parse which ignores all errors and return what it can get.
  2. Usual parse which throws error when something logged.
  3. Provide Logger as an argument to handle all cases on your own.

I'd be happy to accept such a pull request. There are probably a lot of work, so it makes sense to split it to different PRs. Also we need to keep backward compatibility, so existing API should work as before (except logging to console, this should be avoided no doubt).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants