predictionio-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From don...@apache.org
Subject incubator-predictionio git commit: Add Scala style rules, FileTabChecker, NonASCIICharacterChecker and SpaceAfterCommentStartChecker
Date Mon, 25 Jul 2016 20:12:12 GMT
Repository: incubator-predictionio
Updated Branches:
  refs/heads/develop 034f5a0d8 -> c6be80071


Add Scala style rules, FileTabChecker, NonASCIICharacterChecker and SpaceAfterCommentStartChecker


Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/commit/c6be8007
Tree: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/tree/c6be8007
Diff: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/diff/c6be8007

Branch: refs/heads/develop
Commit: c6be800712cc978dffccd8406c1650e068628c97
Parents: 034f5a0
Author: hyukjinkwon <gurwls223@gmail.com>
Authored: Sat Jul 23 13:11:34 2016 +0900
Committer: hyukjinkwon <gurwls223@gmail.com>
Committed: Sat Jul 23 13:11:34 2016 +0900

----------------------------------------------------------------------
 .../predictionio/data/api/EventServer.scala     | 10 ++--
 .../webhooks/segmentio/SegmentIOConnector.scala | 58 ++++++++++----------
 scalastyle-config.xml                           |  9 +++
 3 files changed, 43 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/c6be8007/data/src/main/scala/org/apache/predictionio/data/api/EventServer.scala
----------------------------------------------------------------------
diff --git a/data/src/main/scala/org/apache/predictionio/data/api/EventServer.scala b/data/src/main/scala/org/apache/predictionio/data/api/EventServer.scala
index 7174ec8..39d5210 100644
--- a/data/src/main/scala/org/apache/predictionio/data/api/EventServer.scala
+++ b/data/src/main/scala/org/apache/predictionio/data/api/EventServer.scala
@@ -110,17 +110,17 @@ class  EventServiceActor(
           }.getOrElse(FailedAuth)
         }.getOrElse {
           // with accessKey in header, return appId if succeed
-          ctx.request.headers.find(_.name == "Authorization").map { authHeader ⇒
+          ctx.request.headers.find(_.name == "Authorization").map { authHeader =>
             authHeader.value.split("Basic ") match {
-              case Array(_, value) ⇒
+              case Array(_, value) =>
                 val appAccessKey =
                   new String(base64Decoder.decodeBuffer(value)).trim.split(":")(0)
                 accessKeysClient.get(appAccessKey) match {
-                  case Some(k) ⇒ Right(AuthData(k.appid, None, k.events))
-                  case None ⇒ FailedAuth
+                  case Some(k) => Right(AuthData(k.appid, None, k.events))
+                  case None => FailedAuth
                 }
 
-              case _ ⇒ FailedAuth
+              case _ => FailedAuth
             }
           }.getOrElse(MissedAuth)
         }

http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/c6be8007/data/src/main/scala/org/apache/predictionio/data/webhooks/segmentio/SegmentIOConnector.scala
----------------------------------------------------------------------
diff --git a/data/src/main/scala/org/apache/predictionio/data/webhooks/segmentio/SegmentIOConnector.scala
b/data/src/main/scala/org/apache/predictionio/data/webhooks/segmentio/SegmentIOConnector.scala
index 99ecb90..33b33b5 100644
--- a/data/src/main/scala/org/apache/predictionio/data/webhooks/segmentio/SegmentIOConnector.scala
+++ b/data/src/main/scala/org/apache/predictionio/data/webhooks/segmentio/SegmentIOConnector.scala
@@ -35,57 +35,57 @@ private[predictionio] object SegmentIOConnector extends JsonConnector
{
         )
       }
 */
-    } catch { case _: Throwable ⇒
+    } catch { case _: Throwable =>
       throw new ConnectorException(s"Failed to get segment.io API version.")
     }
 
     val common = try {
       data.extract[Common]
     } catch {
-      case e: Throwable ⇒ throw new ConnectorException(
+      case e: Throwable => throw new ConnectorException(
         s"Cannot extract Common field from $data. ${e.getMessage}", e
       )
     }
 
     try {
       common.`type` match {
-        case "identify" ⇒
+        case "identify" =>
           toEventJson(
             common = common,
             identify = data.extract[Events.Identify]
           )
 
-        case "track" ⇒
+        case "track" =>
           toEventJson(
             common = common,
             track = data.extract[Events.Track]
           )
 
-        case "alias" ⇒
+        case "alias" =>
           toEventJson(
             common = common,
             alias = data.extract[Events.Alias]
           )
 
-        case "page" ⇒
+        case "page" =>
           toEventJson(
             common = common,
             page = data.extract[Events.Page]
           )
 
-        case "screen" ⇒
+        case "screen" =>
           toEventJson(
             common = common,
             screen = data.extract[Events.Screen]
           )
 
-        case "group" ⇒
+        case "group" =>
           toEventJson(
             common = common,
             group = data.extract[Events.Group]
           )
 
-        case _ ⇒
+        case _ =>
           throw new ConnectorException(
             s"Cannot convert unknown type ${common.`type`} to event JSON."
           )
@@ -101,59 +101,59 @@ private[predictionio] object SegmentIOConnector extends JsonConnector
{
 
   def toEventJson(common: Common, identify: Events.Identify ): JObject = {
     import org.json4s.JsonDSL._
-    val eventProperties = "traits" → identify.traits
+    val eventProperties = "traits" -> identify.traits
     toJson(common, eventProperties)
   }
 
   def toEventJson(common: Common, track: Events.Track): JObject = {
     import org.json4s.JsonDSL._
     val eventProperties =
-      ("properties" → track.properties) ~
-      ("event" → track.event)
+      ("properties" -> track.properties) ~
+      ("event" -> track.event)
     toJson(common, eventProperties)
   }
 
   def toEventJson(common: Common, alias: Events.Alias): JObject = {
     import org.json4s.JsonDSL._
-    toJson(common, "previous_id" → alias.previous_id)
+    toJson(common, "previous_id" -> alias.previous_id)
   }
 
   def toEventJson(common: Common, screen: Events.Screen): JObject = {
     import org.json4s.JsonDSL._
     val eventProperties =
-      ("name" → screen.name) ~
-      ("properties" → screen.properties)
+      ("name" -> screen.name) ~
+      ("properties" -> screen.properties)
     toJson(common, eventProperties)
   }
 
   def toEventJson(common: Common, page: Events.Page): JObject = {
     import org.json4s.JsonDSL._
     val eventProperties =
-      ("name" → page.name) ~
-      ("properties" → page.properties)
+      ("name" -> page.name) ~
+      ("properties" -> page.properties)
     toJson(common, eventProperties)
   }
 
   def toEventJson(common: Common, group: Events.Group): JObject = {
     import org.json4s.JsonDSL._
     val eventProperties =
-      ("group_id" → group.group_id) ~
-      ("traits" → group.traits)
+      ("group_id" -> group.group_id) ~
+      ("traits" -> group.traits)
     toJson(common, eventProperties)
   }
 
   private def toJson(common: Common, props: JObject): JsonAST.JObject = {
     val commonFields = commonToJson(common)
-    JObject(("properties" → properties(common, props)) :: commonFields.obj)
+    JObject(("properties" -> properties(common, props)) :: commonFields.obj)
   }
 
   private def properties(common: Common, eventProps: JObject): JObject = {
     import org.json4s.JsonDSL._
-    common.context map { context ⇒
+    common.context map { context =>
       try {
-        ("context" → Extraction.decompose(context)) ~ eventProps
+        ("context" -> Extraction.decompose(context)) ~ eventProps
       } catch {
-        case e: Throwable ⇒
+        case e: Throwable =>
           throw new ConnectorException(
             s"Cannot convert $context to event JSON. ${e.getMessage }", e
           )
@@ -167,13 +167,13 @@ private[predictionio] object SegmentIOConnector extends JsonConnector
{
   private def commonToJson(common: Common, typ: String): JObject = {
     import org.json4s.JsonDSL._
       common.user_id.orElse(common.anonymous_id) match {
-        case Some(userId) ⇒
-          ("event" → typ) ~
-            ("entityType" → "user") ~
-            ("entityId" → userId) ~
-            ("eventTime" → common.timestamp)
+        case Some(userId) =>
+          ("event" -> typ) ~
+            ("entityType" -> "user") ~
+            ("entityId" -> userId) ~
+            ("eventTime" -> common.timestamp)
 
-        case None ⇒
+        case None =>
           throw new ConnectorException(
             "there was no `userId` or `anonymousId` in the common fields."
           )

http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/c6be8007/scalastyle-config.xml
----------------------------------------------------------------------
diff --git a/scalastyle-config.xml b/scalastyle-config.xml
index 0f9b0b2..4c75337 100644
--- a/scalastyle-config.xml
+++ b/scalastyle-config.xml
@@ -98,4 +98,13 @@ limitations under the License.
     <check level="error"
            class="org.scalastyle.file.WhitespaceEndOfLineChecker"
            enabled="true"/>
+    <check level="error"
+           class="org.scalastyle.file.FileTabChecker"
+           enabled="true"/>
+    <check level="error"
+           class="org.scalastyle.scalariform.NonASCIICharacterChecker"
+           enabled="true"/>
+    <check level="error"
+           class="org.scalastyle.scalariform.SpaceAfterCommentStartChecker"
+           enabled="true"/>
 </scalastyle>


Mime
View raw message