Permalink
Browse files

Replace some "null" cases with Some

  • Loading branch information...
Dinduks committed Sep 13, 2012
1 parent 0250aed commit a881122705f659dabc04360e319c293de43d31ce
Showing with 11 additions and 5 deletions.
  1. +5 −4 app/controllers/Application.scala
  2. +6 −1 app/models/Contributor.scala
@@ -50,12 +50,13 @@ object Application extends Controller {
val commitAuthor = commit \ "commit" \ "author"
val author = commit \ "author"
val contributor = Contributor(
- Some((author \ "login").toString),
- Some((commitAuthor \ "name").toString),
- Some((commitAuthor \ "email").toString),
- Some((author \ "avatar_url").toString),
+ (author \ "login").asOpt[String],
+ (commitAuthor \ "name").asOpt[String],
+ (commitAuthor \ "email").asOpt[String],
+ (author \ "avatar_url").asOpt[String],
1
)
+
committersList += ((commitAuthor \ "email").toString -> contributor)
}
}
@@ -26,11 +26,16 @@ object Contributor {
avatarUrl: Option[String],
contributionsCounter: Int
) = {
+ val url = username match {
+ case None => None
+ case Some(username) => Some("https://github.com/%s" format Util.trim(username, '"'))
+ }
+
new Contributor(
username,
name,
email,
- Some("https://github.com/" + Util.trim(username.get, '"')),
+ url,
(avatarUrl),
contributionsCounter
)

0 comments on commit a881122

Please sign in to comment.