DEV Community

Discussion on: Force unwrapping is not just “not Swift-like.” It’s wrong.

Collapse
halileohalilei profile image
Halil Ibrahim Kayim

The points made in this post are very real. What we did to enforce these rules was to use SwiftLint so that people were forced to refactor their code and not use any force unwrapping, otherwise the build process would fail. If the developer was %100 sure that using force unwrapping was the only way to write that piece of code, then they could ignore the error with a specific SwiftLint comment, and we would decide whether it was absolutely necessary to use force unwrapping or not, during code review.

Collapse
evandeaubl profile image
Evan Deaubl Author

That's a great combination of several different techniques! Adding review layers where somebody needs to justify their use of an unsafe language function adds that mindfulness. And Lint+code review generalizes nicely to catch this general kind of code smell.