exyte/Macaw

Removing force unwrapping

Opened this issue · 1 comments

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)?

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).