-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from codacy/scala-2.12
Use Scala 2.12
- Loading branch information
Showing
28 changed files
with
776 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,5 @@ dist | |
*.iml | ||
codacy.pylint.conf | ||
npm-debug.log | ||
config | ||
config | ||
.ensime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
machine: | ||
pre: | ||
- mkdir -p $HOME/.sbt/.lib/1.1.6 && wget http://central.maven.org/maven2/org/scala-sbt/sbt-launch/1.1.6/sbt-launch-1.1.6.jar -O $HOME/.sbt/.lib/1.1.6/sbt-launch.jar | ||
java: | ||
version: oraclejdk8 | ||
|
||
test: | ||
pre: | ||
- sbt mimaReportBinaryIssues | ||
override: | ||
- sbt +test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#Activator-generated Properties | ||
#Sat Jul 12 15:51:18 WEST 2014 | ||
template.uuid=a855816c-0367-44ba-9adb-6a903f6ad599 | ||
sbt.version=0.13.8 | ||
sbt.version=1.1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package play.api.libs | ||
|
||
import java.time.{Instant, LocalDateTime, ZoneOffset} | ||
|
||
import play.api.data.validation.ValidationError | ||
|
||
package object json { | ||
val JsonValidationError: ValidationError.type = play.api.data.validation.ValidationError | ||
val __ : JsPath.type = play.api.libs.json.JsPath | ||
|
||
implicit class ReadsMethods(json: Reads.type) { | ||
def localDateTimeReads[T](parsing: T, corrector: String => String = identity) | ||
(implicit p: T => TemporalParser[LocalDateTime]): Reads[LocalDateTime] = | ||
new TemporalReads[T, LocalDateTime](parsing, corrector, p, { millis: Long => | ||
LocalDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneOffset.UTC) | ||
}) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/scala-2.11/play/api/libs/json/TemporalParser.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package play.api.libs.json | ||
|
||
import java.time.temporal.Temporal | ||
|
||
import play.api.data.validation.ValidationError | ||
|
||
import scala.language.implicitConversions | ||
|
||
trait TemporalParser[T <: Temporal] { | ||
def parse(input: String): Option[T] | ||
} | ||
|
||
private[json] final class TemporalReads[A, B <: Temporal]( | ||
parsing: A, | ||
corrector: String => String, | ||
p: A => TemporalParser[B], | ||
epoch: Long => B | ||
) extends Reads[B] { | ||
def reads(json: JsValue): JsResult[B] = json match { | ||
case JsNumber(d) => JsSuccess(epoch(d.toLong)) | ||
case JsString(s) => p(parsing).parse(corrector(s)) match { | ||
case Some(d) => JsSuccess(d) | ||
case None => JsError(Seq(JsPath -> | ||
Seq(ValidationError("error.expected.date.isoformat", parsing)))) | ||
} | ||
case _ => JsError(Seq(JsPath -> | ||
Seq(ValidationError("error.expected.date")))) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/scala-2.11/play/api/libs/ws/JsonBodyReadables.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package play.api.libs.ws | ||
|
||
/** | ||
* Provides implicit for converting a response to JsValue. | ||
* | ||
* See https://github.com/playframework/play-json for details of Play-JSON. | ||
*/ | ||
trait JsonBodyReadables { | ||
|
||
import play.api.libs.json._ | ||
|
||
/** | ||
* Converts a response body into Play JSON format: | ||
* | ||
* {{{ | ||
* val json = response.body[play.api.libs.json.JsValue] | ||
* }}} | ||
*/ | ||
implicit val readableAsJson: BodyReadable[JsValue] = BodyReadable { response => | ||
Json.parse(response.bodyAsBytes.toArray) | ||
} | ||
} | ||
|
||
object JsonBodyReadables extends JsonBodyReadables |
20 changes: 20 additions & 0 deletions
20
src/main/scala-2.11/play/api/libs/ws/JsonBodyWritables.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package play.api.libs.ws | ||
|
||
import akka.util.ByteString | ||
import com.fasterxml.jackson.databind.{ JsonNode, ObjectMapper } | ||
import play.api.libs.json.{ JsValue, Json } | ||
|
||
trait JsonBodyWritables { | ||
|
||
/** | ||
* Creates an InMemoryBody with "application/json" content type, using the static ObjectMapper. | ||
*/ | ||
implicit val writeableOf_JsValue: BodyWritable[JsValue] = { | ||
BodyWritable(a => InMemoryBody(ByteString.fromString(Json.stringify(a))), "application/json") | ||
} | ||
|
||
def body(objectMapper: ObjectMapper): BodyWritable[JsonNode] = BodyWritable(json => | ||
InMemoryBody(ByteString.fromArrayUnsafe(objectMapper.writeValueAsBytes(json))), "application/json") | ||
} | ||
|
||
object JsonBodyWritables extends JsonBodyWritables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletions
13
src/main/scala/com/codacy/client/bitbucket/CommitComment.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package com.codacy.client.bitbucket | ||
|
||
import org.joda.time.DateTime | ||
import java.time.LocalDateTime | ||
|
||
import play.api.libs.functional.syntax._ | ||
import play.api.libs.json._ | ||
|
||
case class CommitComment(id: Long, username: String, commit: String, display_name: String, content: String, created_on: DateTime) | ||
case class CommitComment(id: Long, username: String, commit: String, display_name: String, content: String, created_on: LocalDateTime) | ||
|
||
object CommitComment { | ||
val dateFormat = "yyyy-MM-dd HH:mm:ssZZ" | ||
implicit val jodaDateTimeReads = Reads.jodaDateReads(dateFormat) | ||
val dateFormat = "yyyy-MM-dd HH:mm:ssXXX" | ||
implicit val dateTimeReads: Reads[LocalDateTime] = Reads.localDateTimeReads(dateFormat) | ||
|
||
implicit val reader: Reads[CommitComment] = ( | ||
(__ \ "comment_id").read[Long] and | ||
(__ \ "username").read[String] and | ||
(__ \ "node").read[String] and | ||
(__ \ "display_name").read[String] and | ||
(__ \ "content").read[String] and | ||
(__ \ "utc_created_on").read[DateTime] | ||
(__ \ "utc_created_on").read[LocalDateTime] | ||
)(CommitComment.apply _) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletions
13
src/main/scala/com/codacy/client/bitbucket/PullRequestComment.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
package com.codacy.client.bitbucket | ||
|
||
import org.joda.time.DateTime | ||
import java.time.LocalDateTime | ||
|
||
import play.api.libs.functional.syntax._ | ||
import play.api.libs.json._ | ||
|
||
case class PullRequestComment(id: Long, username: String, display_name: String, content: String, created_on: DateTime) | ||
case class PullRequestComment(id: Long, username: String, display_name: String, content: String, created_on: LocalDateTime) | ||
|
||
object PullRequestComment { | ||
val dateFormat = "yyyy-MM-dd HH:mm:ssZZ" | ||
implicit val jodaDateTimeReads = Reads.jodaDateReads(dateFormat) | ||
val dateFormat = "yyyy-MM-dd HH:mm:ssXXX" | ||
implicit val dateTimeReads: Reads[LocalDateTime] = Reads.localDateTimeReads(dateFormat) | ||
|
||
implicit val reader: Reads[PullRequestComment] = ( | ||
(__ \ "comment_id").read[Long] and | ||
(__ \ "username").read[String] and | ||
(__ \ "display_name").read[String] and | ||
(__ \ "content").read[String] and | ||
(__ \ "utc_created_on").read[DateTime] | ||
(__ \ "utc_created_on").read[LocalDateTime] | ||
)(PullRequestComment.apply _) | ||
} | ||
} |
20 changes: 11 additions & 9 deletions
20
src/main/scala/com/codacy/client/bitbucket/Repository.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.