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

SwiftLint に則って Caution 対応したい #4

Closed
zdogma opened this issue Feb 21, 2017 · 0 comments · Fixed by #6
Closed

SwiftLint に則って Caution 対応したい #4

zdogma opened this issue Feb 21, 2017 · 0 comments · Fixed by #6

Comments

@zdogma
Copy link
Owner

zdogma commented Feb 21, 2017

Caution の数が多そうであれば種類別に PR を分けて対応する。
#1 (comment)

特に
force_cast
force_try
force_unwrapping
をなるべく避けるようにするとよりSwiftらしくなると思います。

例えばこの辺のforce unwrappingを治すとしたら、
var dataを暗黙的アンラップ型で定義して、dataに値が渡ってなかったら非正常系というのを型で表現し、try ~ catchで例外を補足して適当にエラー表示する
Optional Chaining、Optional Bindingを使って、dataにデータが渡されてるとき(正常系)と、渡されてないとき(非正常系)を表示分けする
if let thumbnailUlr = data?.thumbnailUrl, !thumbNailUrl.isEmpty {
// データがあるとき
} else {
// データがないとき
}
のどちらかといった感じです。

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