Skip to content

Commit

Permalink
Option.get is a lie
Browse files Browse the repository at this point in the history
Never use Option.get, it throws exceptions.
Instead of checking if the value is available with Option.isEmpty,
then using Option.get, you should get the value while you check for its existence.
  • Loading branch information
ornicar committed Feb 27, 2024
1 parent 44a5f89 commit 86c7349
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/api/src/main/ForumAccess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class ForumAccess(
def isReplyBlockedOnUBlog(topic: lila.forum.ForumTopic, canModCateg: Boolean)(using
meOpt: Option[Me]
): Fu[Boolean] = meOpt.so: me =>
if topic.ublogId.isEmpty then fuFalse
else if topic.userId.isEmpty then fuFalse
else if canModCateg then fuFalse
else relationApi.fetchRelation(topic.userId.get, me).map(_.contains(Block))
topic.userId.so: topicAuthor =>
if topic.ublogId.isEmpty then fuFalse
else if canModCateg then fuFalse
else relationApi.fetchRelation(topicAuthor, me).map(_.contains(Block))

0 comments on commit 86c7349

Please sign in to comment.