diff --git a/common-lib/src/main/scala/com/gu/mediaservice/lib/Files.scala b/common-lib/src/main/scala/com/gu/mediaservice/lib/Files.scala index 045a1c8987..48076eed82 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/lib/Files.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/lib/Files.scala @@ -4,13 +4,12 @@ import java.io.{File, FileOutputStream} import java.net.URL import java.nio.channels.Channels import java.util.concurrent.Executors - -import scala.concurrent.{ExecutionContext, Future} +import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future} object Files { - private implicit val ctx = ExecutionContext.fromExecutor(Executors.newCachedThreadPool) + private implicit val ctx: ExecutionContextExecutor = ExecutionContext.fromExecutor(Executors.newCachedThreadPool) def createTempFile(prefix: String, suffix: String, tempDir: File): Future[File] = Future { diff --git a/common-lib/src/main/scala/com/gu/mediaservice/lib/aws/ThrallMessageSender.scala b/common-lib/src/main/scala/com/gu/mediaservice/lib/aws/ThrallMessageSender.scala index c78be09f74..a7fa790454 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/lib/aws/ThrallMessageSender.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/lib/aws/ThrallMessageSender.scala @@ -5,8 +5,8 @@ import com.gu.mediaservice.model._ import com.gu.mediaservice.model.leases.MediaLease import com.gu.mediaservice.model.usage.UsageNotice import org.joda.time.{DateTime, DateTimeZone} -import play.api.libs.functional.syntax.{toFunctionalBuilderOps} -import play.api.libs.json.{JodaReads, JodaWrites, Json, __} +import play.api.libs.functional.syntax.toFunctionalBuilderOps +import play.api.libs.json.{JodaReads, JodaWrites, Json, OWrites, Reads, Writes, __} // TODO MRB: replace this with the simple Kinesis class once we migrate off SNS class ThrallMessageSender(config: KinesisSenderConfig) { @@ -27,17 +27,17 @@ case class BulkIndexRequest( ) object BulkIndexRequest { - implicit val reads = Json.reads[BulkIndexRequest] - implicit val writes = Json.writes[BulkIndexRequest] + implicit val reads: Reads[BulkIndexRequest] = Json.reads[BulkIndexRequest] + implicit val writes: OWrites[BulkIndexRequest] = Json.writes[BulkIndexRequest] } object UpdateMessage extends GridLogging { - implicit val yourJodaDateReads = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC)) - implicit val yourJodaDateWrites = JodaWrites.JodaDateTimeWrites - implicit val unw = Json.writes[UsageNotice] - implicit val unr = Json.reads[UsageNotice] - implicit val writes = Json.writes[UpdateMessage] - implicit val reads = + implicit val yourJodaDateReads: Reads[DateTime] = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC)) + implicit val yourJodaDateWrites: Writes[DateTime] = JodaWrites.JodaDateTimeWrites + implicit val unw: OWrites[UsageNotice] = Json.writes[UsageNotice] + implicit val unr: Reads[UsageNotice] = Json.reads[UsageNotice] + implicit val writes: OWrites[UpdateMessage] = Json.writes[UpdateMessage] + implicit val reads: Reads[UpdateMessage] = ( (__ \ "subject").read[String] ~ (__ \ "image").readNullable[Image] ~ diff --git a/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ElasticSearchClient.scala b/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ElasticSearchClient.scala index 8fa5ced648..ee6ca13fbd 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ElasticSearchClient.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ElasticSearchClient.scala @@ -65,7 +65,7 @@ trait ElasticSearchClient extends ElasticSearchExecutions with GridLogging { } def healthCheck(): Future[Boolean] = { - implicit val logMarker = MarkerMap() + implicit val logMarker: MarkerMap = MarkerMap() val request = search(imagesCurrentAlias) limit 0 executeAndLog(request, "Healthcheck").map { _ => true}.recover { case _ => false} } @@ -81,7 +81,7 @@ trait ElasticSearchClient extends ElasticSearchExecutions with GridLogging { } def countImages(indexName: String = imagesCurrentAlias): Future[ElasticSearchImageCounts] = { - implicit val logMarker = MarkerMap() + implicit val logMarker: MarkerMap = MarkerMap() val queryCatCount = catCount(indexName) // document count only of index including live documents, not deleted documents which have not yet been removed by the merge process val queryImageSearch = search(indexName) trackTotalHits true limit 0 // hits that match the query defined in the request val uploadedInLastFiveMinutes = count(indexName) query rangeQuery("uploadTime").gte("now-5m") diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/Collection.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/Collection.scala index ff9823006f..bf7e450a84 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/Collection.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/Collection.scala @@ -36,7 +36,7 @@ object Collection { case class ActionData(author: String, date: DateTime) object ActionData { // TODO: Use the generic formats for DateTime - implicit val dateWrites = jodaDateWrites("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") - implicit val dateReads = jodaDateReads("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") + implicit val dateWrites: Writes[DateTime] = jodaDateWrites("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") + implicit val dateReads: Reads[DateTime] = jodaDateReads("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") implicit def formats: Format[ActionData] = Json.format[ActionData] } diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationRights.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationRights.scala index f9fb250d17..aea1a2c810 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationRights.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationRights.scala @@ -17,8 +17,8 @@ case class SyndicationRights( def isAvailableForSyndication: Boolean = isRightsAcquired && published.exists(_.isBeforeNow) } object SyndicationRights { - implicit val dateWrites = jodaDateWrites("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") - implicit val dateReads = jodaDateReads("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") + implicit val dateWrites: Writes[DateTime] = jodaDateWrites("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") + implicit val dateReads: Reads[DateTime] = jodaDateReads("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") val reads: Reads[SyndicationRights] = ( @@ -73,8 +73,8 @@ case class Property( expiresOn: Option[DateTime], value: Option[String]) object Property { - implicit val dateWrites = jodaDateWrites("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") - implicit val dateReads = jodaDateReads("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") + implicit val dateWrites: Writes[DateTime] = jodaDateWrites("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") + implicit val dateReads: Reads[DateTime] = jodaDateReads("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") val reads: Reads[Property] = Json.reads[Property] val writes: Writes[Property] = ( diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationStatus.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationStatus.scala index 0a48d641fa..351e9d4f32 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationStatus.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/SyndicationStatus.scala @@ -23,7 +23,7 @@ object SyndicationStatus { implicit val reads: Reads[SyndicationStatus] = JsPath.read[String].map(SyndicationStatus(_)) - implicit val writer = new Writes[SyndicationStatus] { + implicit val writer: Writes[SyndicationStatus] = new Writes[SyndicationStatus] { def writes(status: SyndicationStatus) = JsString(status.toString) } } diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/ThrallMessage.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/ThrallMessage.scala index 41370db7d5..ee7ba270df 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/ThrallMessage.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/ThrallMessage.scala @@ -3,8 +3,7 @@ package com.gu.mediaservice.model import com.gu.mediaservice.model.leases.MediaLease import com.gu.mediaservice.model.usage.UsageNotice import org.joda.time.{DateTime, DateTimeZone} -import play.api.libs.json -import play.api.libs.json.{JodaReads, JodaWrites, JsValue, Json, Reads} +import play.api.libs.json.{JodaReads, JodaWrites, JsValue, Json, OFormat, OWrites, Reads, Writes} import com.gu.mediaservice.lib.logging.{GridLogging, LogMarker} import org.joda.time.format.DateTimeFormat @@ -43,7 +42,7 @@ object MigrateImageMessage { sealed trait ExternalThrallMessage extends ThrallMessage { implicit val yourJodaDateReads: Reads[DateTime] = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC)) - implicit val yourJodaDateWrites: json.JodaWrites.JodaDateTimeWrites.type = JodaWrites.JodaDateTimeWrites + implicit val yourJodaDateWrites: Writes[DateTime] = JodaWrites.JodaDateTimeWrites val id: String val lastModified: DateTime def toJson: JsValue = Json.toJson(this)(ExternalThrallMessage.writes) @@ -59,35 +58,35 @@ sealed trait ExternalThrallMessage extends ThrallMessage { } object ExternalThrallMessage{ - implicit val yourJodaDateReads = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC)) - implicit val yourJodaDateWrites = JodaWrites.JodaDateTimeWrites - - implicit val usageNoticeFormat = Json.format[UsageNotice] - - implicit val replaceImageLeasesMessageFormat = Json.format[ReplaceImageLeasesMessage] - implicit val deleteImageMessageFormat = Json.format[DeleteImageMessage] - implicit val updateImageSyndicationMetadataMessageFormat = Json.format[UpdateImageSyndicationMetadataMessage] - implicit val setImageCollectionsMessageFormat = Json.format[SetImageCollectionsMessage] - implicit val updateImageUserMetadataMessageFormat = Json.format[UpdateImageUserMetadataMessage] - implicit val deleteImageExportsMessageFormat = Json.format[DeleteImageExportsMessage] - implicit val softDeleteImageMessageFormat = Json.format[SoftDeleteImageMessage] - implicit val unSoftDeleteImageMessageFormat = Json.format[UnSoftDeleteImageMessage] - implicit val imageMessageFormat = Json.format[ImageMessage] - implicit val updateImagePhotoshootMetadataMessage = Json.format[UpdateImagePhotoshootMetadataMessage] - implicit val deleteUsagesMessage = Json.format[DeleteUsagesMessage] - implicit val deleteSingleUsageMessage = Json.format[DeleteSingleUsageMessage] - implicit val updateUsageStatusMessage = Json.format[UpdateUsageStatusMessage] - implicit val updateImageUsagesMessage = Json.format[UpdateImageUsagesMessage] - implicit val addImageLeaseMessage = Json.format[AddImageLeaseMessage] - implicit val removeImageLeaseMessage = Json.format[RemoveImageLeaseMessage] - implicit val updateImageExportsMessage = Json.format[UpdateImageExportsMessage] - - implicit val createMigrationIndexMessage = Json.format[CreateMigrationIndexMessage] - implicit val completeMigrationMessage = Json.format[CompleteMigrationMessage] - implicit val upsertFromProjectionMessage = Json.format[UpsertFromProjectionMessage] - - implicit val writes = Json.writes[ExternalThrallMessage] - implicit val reads = Json.reads[ExternalThrallMessage] + implicit val yourJodaDateReads: Reads[DateTime] = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC)) + implicit val yourJodaDateWrites: Writes[DateTime] = JodaWrites.JodaDateTimeWrites + + implicit val usageNoticeFormat: OFormat[UsageNotice] = Json.format[UsageNotice] + + implicit val replaceImageLeasesMessageFormat: OFormat[ReplaceImageLeasesMessage] = Json.format[ReplaceImageLeasesMessage] + implicit val deleteImageMessageFormat: OFormat[DeleteImageMessage] = Json.format[DeleteImageMessage] + implicit val updateImageSyndicationMetadataMessageFormat: OFormat[UpdateImageSyndicationMetadataMessage] = Json.format[UpdateImageSyndicationMetadataMessage] + implicit val setImageCollectionsMessageFormat: OFormat[SetImageCollectionsMessage] = Json.format[SetImageCollectionsMessage] + implicit val updateImageUserMetadataMessageFormat: OFormat[UpdateImageUserMetadataMessage] = Json.format[UpdateImageUserMetadataMessage] + implicit val deleteImageExportsMessageFormat: OFormat[DeleteImageExportsMessage] = Json.format[DeleteImageExportsMessage] + implicit val softDeleteImageMessageFormat: OFormat[SoftDeleteImageMessage] = Json.format[SoftDeleteImageMessage] + implicit val unSoftDeleteImageMessageFormat: OFormat[UnSoftDeleteImageMessage] = Json.format[UnSoftDeleteImageMessage] + implicit val imageMessageFormat: OFormat[ImageMessage] = Json.format[ImageMessage] + implicit val updateImagePhotoshootMetadataMessage: OFormat[UpdateImagePhotoshootMetadataMessage] = Json.format[UpdateImagePhotoshootMetadataMessage] + implicit val deleteUsagesMessage: OFormat[DeleteUsagesMessage] = Json.format[DeleteUsagesMessage] + implicit val deleteSingleUsageMessage: OFormat[DeleteSingleUsageMessage] = Json.format[DeleteSingleUsageMessage] + implicit val updateUsageStatusMessage: OFormat[UpdateUsageStatusMessage] = Json.format[UpdateUsageStatusMessage] + implicit val updateImageUsagesMessage: OFormat[UpdateImageUsagesMessage] = Json.format[UpdateImageUsagesMessage] + implicit val addImageLeaseMessage: OFormat[AddImageLeaseMessage] = Json.format[AddImageLeaseMessage] + implicit val removeImageLeaseMessage: OFormat[RemoveImageLeaseMessage] = Json.format[RemoveImageLeaseMessage] + implicit val updateImageExportsMessage: OFormat[UpdateImageExportsMessage] = Json.format[UpdateImageExportsMessage] + + implicit val createMigrationIndexMessage: OFormat[CreateMigrationIndexMessage] = Json.format[CreateMigrationIndexMessage] + implicit val completeMigrationMessage: OFormat[CompleteMigrationMessage] = Json.format[CompleteMigrationMessage] + implicit val upsertFromProjectionMessage: OFormat[UpsertFromProjectionMessage] = Json.format[UpsertFromProjectionMessage] + + implicit val writes: OWrites[ExternalThrallMessage] = Json.writes[ExternalThrallMessage] + implicit val reads: Reads[ExternalThrallMessage] = Json.reads[ExternalThrallMessage] } @@ -128,9 +127,9 @@ case class DeleteUsagesMessage(id: String, lastModified: DateTime) extends Exter case class UpdateUsageStatusMessage(id: String, usageNotice: UsageNotice, lastModified: DateTime) extends ExternalThrallMessage object DeleteUsagesMessage { - implicit val yourJodaDateReads = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC)) - implicit val yourJodaDateWrites = JodaWrites.JodaDateTimeWrites - implicit val what = Json.format[DeleteUsagesMessage] + implicit val yourJodaDateReads: Reads[DateTime] = JodaReads.DefaultJodaDateTimeReads.map(d => d.withZone(DateTimeZone.UTC)) + implicit val yourJodaDateWrites: Writes[DateTime] = JodaWrites.JodaDateTimeWrites + implicit val what: OFormat[DeleteUsagesMessage] = Json.format[DeleteUsagesMessage] } case class UpdateImageSyndicationMetadataMessage(id: String, lastModified: DateTime, maybeSyndicationRights: Option[SyndicationRights]) extends ExternalThrallMessage diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/UploadInfo.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/UploadInfo.scala index d98b1e0ff1..5b8beb6545 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/UploadInfo.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/UploadInfo.scala @@ -1,10 +1,10 @@ package com.gu.mediaservice.model -import play.api.libs.json.Json +import play.api.libs.json.{Json, OWrites, Reads} case class UploadInfo(filename: Option[String] = None) object UploadInfo { - implicit val jsonWrites = Json.writes[UploadInfo] - implicit val jsonReads = Json.reads[UploadInfo] + implicit val jsonWrites: OWrites[UploadInfo] = Json.writes[UploadInfo] + implicit val jsonReads: Reads[UploadInfo] = Json.reads[UploadInfo] } diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/leases/LeasesByMedia.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/leases/LeasesByMedia.scala index 0d035e1f5b..cb64dd365b 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/leases/LeasesByMedia.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/leases/LeasesByMedia.scala @@ -13,7 +13,7 @@ object LeasesByMedia { import JodaReads._ implicit val reader: Reads[LeasesByMedia] = Json.reads[LeasesByMedia] - implicit val writer = new Writes[LeasesByMedia] { + implicit val writer: Writes[LeasesByMedia] = new Writes[LeasesByMedia] { def writes(leaseByMedia: LeasesByMedia) = { Json.obj( "leases" -> leaseByMedia.leases, diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/usage/UsageStatus.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/usage/UsageStatus.scala index 3a356c1634..40ad7a63b2 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/usage/UsageStatus.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/usage/UsageStatus.scala @@ -28,7 +28,7 @@ object UsageStatus { implicit val reads: Reads[UsageStatus] = JsPath.read[String].map(UsageStatus(_)) - implicit val writer = new Writes[UsageStatus] { + implicit val writer: Writes[UsageStatus] = new Writes[UsageStatus] { def writes(usageStatus: UsageStatus) = JsString(usageStatus.toString) } } diff --git a/common-lib/src/main/scala/com/gu/mediaservice/syntax/PlayJsonSyntax.scala b/common-lib/src/main/scala/com/gu/mediaservice/syntax/PlayJsonSyntax.scala index fb6be7ea5d..aaf2e01f12 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/syntax/PlayJsonSyntax.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/syntax/PlayJsonSyntax.scala @@ -13,11 +13,11 @@ trait PlayJsonSyntax { def logParseErrors(): Unit = PlayJsonHelpers.logParseErrors(self) } - implicit val uriWrites = new Writes[URI] { + implicit val uriWrites: Writes[URI] = new Writes[URI] { override def writes(o: URI): JsValue = JsString(o.toString) } - implicit val uriReads = new Reads[URI] { + implicit val uriReads: Reads[URI] = new Reads[URI] { override def reads(json: JsValue): JsResult[URI] = json match { case JsString(uriInJson) => Try { new URI(uriInJson) diff --git a/common-lib/src/test/scala/com/gu/mediaservice/lib/imaging/ImageOperationsTest.scala b/common-lib/src/test/scala/com/gu/mediaservice/lib/imaging/ImageOperationsTest.scala index 12709790f2..8f78918f2d 100644 --- a/common-lib/src/test/scala/com/gu/mediaservice/lib/imaging/ImageOperationsTest.scala +++ b/common-lib/src/test/scala/com/gu/mediaservice/lib/imaging/ImageOperationsTest.scala @@ -16,7 +16,7 @@ import scala.concurrent.ExecutionContext.Implicits.global @Ignore class ImageOperationsTest extends AnyFunSpec with Matchers with ScalaFutures { - implicit override val patienceConfig = PatienceConfig(timeout = Span(1000, Millis), interval = Span(25, Millis)) + implicit override val patienceConfig: PatienceConfig = PatienceConfig(timeout = Span(1000, Millis), interval = Span(25, Millis)) implicit val logMarker: LogMarker = MarkerMap() describe("identifyColourModel") { diff --git a/common-lib/src/test/scala/com/gu/mediaservice/lib/json/JsonByteArrayUtilTest.scala b/common-lib/src/test/scala/com/gu/mediaservice/lib/json/JsonByteArrayUtilTest.scala index 7cdfea066c..fe1453434b 100644 --- a/common-lib/src/test/scala/com/gu/mediaservice/lib/json/JsonByteArrayUtilTest.scala +++ b/common-lib/src/test/scala/com/gu/mediaservice/lib/json/JsonByteArrayUtilTest.scala @@ -3,13 +3,13 @@ package com.gu.mediaservice.lib.json import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers -import play.api.libs.json.Json +import play.api.libs.json.{Json, OWrites, Reads} case class Shape(name: String, numberOfSides: Int) object Shape { - implicit val reads = Json.reads[Shape] - implicit val writes = Json.writes[Shape] + implicit val reads: Reads[Shape] = Json.reads[Shape] + implicit val writes: OWrites[Shape] = Json.writes[Shape] } class JsonByteArrayUtilTest extends AnyFunSuite with Matchers { diff --git a/image-loader/app/controllers/ImageLoaderController.scala b/image-loader/app/controllers/ImageLoaderController.scala index 3bcfcd90a4..bcee5a0468 100644 --- a/image-loader/app/controllers/ImageLoaderController.scala +++ b/image-loader/app/controllers/ImageLoaderController.scala @@ -181,7 +181,7 @@ class ImageLoaderController(auth: Authentication, tempFile, expectedSize = s3IngestObject.contentLength ) - implicit val logMarker = initialLogMarker ++ Map( + implicit val logMarker: LogMarker = initialLogMarker ++ Map( "mediaId" -> digestedFile.digest ) diff --git a/image-loader/test/scala/lib/imaging/FileMetadataReaderTest.scala b/image-loader/test/scala/lib/imaging/FileMetadataReaderTest.scala index cfe415d154..b55c7a6131 100644 --- a/image-loader/test/scala/lib/imaging/FileMetadataReaderTest.scala +++ b/image-loader/test/scala/lib/imaging/FileMetadataReaderTest.scala @@ -20,7 +20,7 @@ class FileMetadataReaderTest extends AnyFunSpec with Matchers with ScalaFutures import test.lib.ResourceHelpers._ - implicit override val patienceConfig = PatienceConfig(timeout = Span(1000, Millis), interval = Span(25, Millis)) + implicit override val patienceConfig: PatienceConfig = PatienceConfig(timeout = Span(1000, Millis), interval = Span(25, Millis)) implicit val logMarker: LogMarker = MarkerMap() it("should read the correct dimensions for a JPG image") { diff --git a/image-loader/test/scala/lib/imaging/MimeTypeDetectionTest.scala b/image-loader/test/scala/lib/imaging/MimeTypeDetectionTest.scala index 3b18158faf..783933449d 100644 --- a/image-loader/test/scala/lib/imaging/MimeTypeDetectionTest.scala +++ b/image-loader/test/scala/lib/imaging/MimeTypeDetectionTest.scala @@ -10,7 +10,7 @@ import org.scalatest.matchers.should.Matchers class MimeTypeDetectionTest extends AnyFunSpec with Matchers with ScalaFutures { import test.lib.ResourceHelpers._ - implicit val markers = MarkerMap() + implicit val markers: MarkerMap = MarkerMap() it("should detect jpeg mime types for images") { for (fileName <- List("getty.jpg", "corbis.jpg", "guardian-turner.jpg", "pa.jpg")) { diff --git a/leases/app/lib/LeaseStore.scala b/leases/app/lib/LeaseStore.scala index 2fc194b06b..3c06a71f8d 100644 --- a/leases/app/lib/LeaseStore.scala +++ b/leases/app/lib/LeaseStore.scala @@ -13,9 +13,9 @@ import scala.concurrent.{ExecutionContext, Future} class LeaseStore(config: LeasesConfig) { val client = config.withAWSCredentialsV2(DynamoDbAsyncClient.builder()).build() - implicit val dateTimeFormat = + implicit val dateTimeFormat: Typeclass[DateTime] = DynamoFormat.coercedXmap[DateTime, String, IllegalArgumentException](DateTime.parse, _.toString) - implicit val enumFormat = + implicit val enumFormat: Typeclass[MediaLeaseType] = DynamoFormat.coercedXmap[MediaLeaseType, String, IllegalArgumentException](MediaLeaseType(_), _.toString) private val leasesTable = Table[MediaLease](config.leasesTable) diff --git a/media-api/app/controllers/AggregationController.scala b/media-api/app/controllers/AggregationController.scala index 22bf3c8828..18e68ebe45 100644 --- a/media-api/app/controllers/AggregationController.scala +++ b/media-api/app/controllers/AggregationController.scala @@ -11,7 +11,7 @@ class AggregationController(auth: Authentication, elasticSearch: ElasticSearch, extends BaseController with AggregateResponses { def dateHistogram(field: String, q: Option[String]) = auth.async { request => - implicit val r = request + implicit val r: Authentication.Request[AnyContent] = request elasticSearch.dateHistogramAggregate(AggregateSearchParams(field, request)) .map(aggregateResponse) diff --git a/media-api/app/controllers/MediaApi.scala b/media-api/app/controllers/MediaApi.scala index 68a22d6a3b..aceeb0db2c 100644 --- a/media-api/app/controllers/MediaApi.scala +++ b/media-api/app/controllers/MediaApi.scala @@ -5,7 +5,7 @@ import com.google.common.net.HttpHeaders import com.gu.mediaservice.{GridClient, JsonDiff} import com.gu.mediaservice.lib.argo._ import com.gu.mediaservice.lib.argo.model.{Action, _} -import com.gu.mediaservice.lib.auth.Authentication._ +import com.gu.mediaservice.lib.auth.Authentication.{Request, _} import com.gu.mediaservice.lib.auth.Permissions.{ArchiveImages, DeleteCropsOrUsages, EditMetadata, UploadImages, DeleteImage => DeleteImagePermission} import com.gu.mediaservice.lib.auth._ import com.gu.mediaservice.lib.aws.{ContentDisposition, ThrallMessageSender, UpdateMessage} @@ -157,7 +157,7 @@ class MediaApi( } def uploadedBy(id: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageUploaderById(id) map { case Some(uploadedBy) => respond(uploadedBy) @@ -184,7 +184,7 @@ class MediaApi( } def getImageFileMetadata(id: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) map { case Some(image) if hasPermission(request.user, image) => @@ -197,7 +197,7 @@ class MediaApi( } def getImageExports(id: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) map { case Some(image) if hasPermission(request.user, image) => @@ -210,7 +210,7 @@ class MediaApi( } def getImageExport(imageId: String, exportId: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(imageId) map { case Some(source) if hasPermission(request.user, source) => @@ -232,7 +232,7 @@ class MediaApi( } def downloadImageExport(imageId: String, exportId: String, width: Int) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(imageId) map { case Some(source) if hasPermission(request.user, source) => @@ -255,7 +255,7 @@ class MediaApi( } def hardDeleteImage(id: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) map { case Some(image) if hasPermission(request.user, image) => @@ -280,7 +280,7 @@ class MediaApi( } def deleteImage(id: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) map { case Some(image) if hasPermission(request.user, image) => @@ -314,7 +314,7 @@ class MediaApi( } def unSoftDeleteImage(id: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) map { case Some(image) if hasPermission(request.user, image) => val canDelete = authorisation.isUploaderOrHasPermission(request.user, image.uploadedBy, DeleteImagePermission) @@ -337,7 +337,7 @@ class MediaApi( } def downloadOriginalImage(id: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) flatMap { case Some(image) if hasPermission(request.user, image) => { @@ -361,7 +361,7 @@ class MediaApi( } def syndicateImage(id: String, partnerName: String, startPending: String) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) flatMap { case Some(image) if hasPermission(request.user, image) => { @@ -380,7 +380,7 @@ class MediaApi( } def downloadOptimisedImage(id: String, width: Integer, height: Integer, quality: Integer) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.getImageById(id) flatMap { case Some(image) if hasPermission(request.user, image) => { @@ -433,12 +433,12 @@ class MediaApi( } def imageSearch() = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request val shouldFlagGraphicImages = request.cookies.get("SHOULD_BLUR_GRAPHIC_IMAGES") .map(_.value).getOrElse(config.defaultShouldBlurGraphicImages.toString) == "true" - implicit val logMarker = MarkerMap( + implicit val logMarker: MarkerMap = MarkerMap( "shouldFlagGraphicImages" -> shouldFlagGraphicImages, "user" -> r.user.accessor.identity ) diff --git a/media-api/app/controllers/SuggestionController.scala b/media-api/app/controllers/SuggestionController.scala index 278423f251..63220de27e 100644 --- a/media-api/app/controllers/SuggestionController.scala +++ b/media-api/app/controllers/SuggestionController.scala @@ -3,8 +3,9 @@ package controllers import com.gu.mediaservice.lib.ImageFields import com.gu.mediaservice.lib.argo.ArgoHelpers import com.gu.mediaservice.lib.auth.Authentication +import com.gu.mediaservice.lib.auth.Authentication.Request import lib.elasticsearch.{AggregateSearchParams, CompletionSuggestionResults, ElasticSearch} -import play.api.mvc.{BaseController, ControllerComponents} +import play.api.mvc.{AnyContent, BaseController, ControllerComponents} import scala.concurrent.{ExecutionContext, Future} @@ -20,19 +21,19 @@ class SuggestionController(auth: Authentication, elasticSearch: ElasticSearch, // TODO: recover with HTTP error if invalid field // TODO: Add validation, especially if you use length def metadataSearch(field: String, q: Option[String]) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.metadataSearch(AggregateSearchParams(field, request)) map aggregateResponse } def editsSearch(field: String, q: Option[String]) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request elasticSearch.editsSearch(AggregateSearchParams(field, request)) map aggregateResponse } private def suggestion(field: String, query: Option[String], size: Option[Int]) = auth.async { request => - implicit val r = request + implicit val r: Request[AnyContent] = request query.flatMap(q => if (q.nonEmpty) Some(q) else None).map { q => elasticSearch.completionSuggestion(field, q, size.getOrElse(10)) diff --git a/media-api/app/controllers/UsageController.scala b/media-api/app/controllers/UsageController.scala index b9e61f5966..d8a90e1b06 100644 --- a/media-api/app/controllers/UsageController.scala +++ b/media-api/app/controllers/UsageController.scala @@ -19,7 +19,7 @@ class UsageController(auth: Authentication, config: MediaApiConfig, elasticSearc val numberOfDayInPeriod = 30 def bySupplier = auth.async { request => - implicit val r = request + implicit val r: Authentication.Request[AnyContent] = request Future.sequence( Agencies.all.keys.map(elasticSearch.usageForSupplier(_, numberOfDayInPeriod))) @@ -31,7 +31,7 @@ class UsageController(auth: Authentication, config: MediaApiConfig, elasticSearc } def forSupplier(id: String) = auth.async { request => - implicit val r = request + implicit val r: Authentication.Request[AnyContent] = request elasticSearch.usageForSupplier(id, numberOfDayInPeriod) .map((s: SupplierUsageSummary) => respond(s)) @@ -53,7 +53,7 @@ class UsageController(auth: Authentication, config: MediaApiConfig, elasticSearc def quotaForImage(id: String) = auth.async { request => - implicit val r = request + implicit val r: Authentication.Request[AnyContent] = request usageStatusForImage(id) .map((u: UsageStatus) => respond(u)) diff --git a/media-api/app/lib/ImageResponse.scala b/media-api/app/lib/ImageResponse.scala index aa8df26577..b926b7121c 100644 --- a/media-api/app/lib/ImageResponse.scala +++ b/media-api/app/lib/ImageResponse.scala @@ -22,7 +22,7 @@ import scala.util.{Failure, Try} class ImageResponse(config: MediaApiConfig, s3Client: S3Client, usageQuota: UsageQuota) extends EditsResponse with GridLogging { - implicit val usageQuotas = usageQuota + implicit val usageQuotas: UsageQuota = usageQuota object Costing extends CostCalculator { override val freeSuppliers: List[String] = config.usageRightsConfig.freeSuppliers @@ -33,7 +33,7 @@ class ImageResponse(config: MediaApiConfig, s3Client: S3Client, usageQuota: Usag val customSpecialInstructions: Map[String, String] = config.customSpecialInstructions val customUsageRestrictions: Map[String, String] = config.customUsageRestrictions - implicit val costing = Costing + implicit val costing: CostCalculator = Costing val metadataBaseUri: String = config.services.metadataBaseUri diff --git a/media-api/app/lib/elasticsearch/ElasticSearch.scala b/media-api/app/lib/elasticsearch/ElasticSearch.scala index 623646f0a3..2e88cff363 100644 --- a/media-api/app/lib/elasticsearch/ElasticSearch.scala +++ b/media-api/app/lib/elasticsearch/ElasticSearch.scala @@ -73,7 +73,7 @@ class ElasticSearch( )( implicit ex: ExecutionContext ): Future[Option[T]] = { - implicit val logMarker = MarkerMap("id" -> id) + implicit val logMarker: MarkerMap = MarkerMap("id" -> id) def getFromCurrentIndex = executeAndLog( request = requestFromIndexName(imagesCurrentAlias), @@ -279,7 +279,7 @@ class ElasticSearch( } def usageForSupplier(id: String, numDays: Int)(implicit ex: ExecutionContext, request: AuthenticatedRequest[AnyContent, Principal]): Future[SupplierUsageSummary] = { - implicit val logMarker = MarkerMap() + implicit val logMarker: MarkerMap = MarkerMap() val supplier = Agencies.get(id) val supplierName = supplier.supplier @@ -330,7 +330,7 @@ class ElasticSearch( buckets.map(b => BucketResult(b.key, b.docCount)) private def aggregateSearch(name: String, params: AggregateSearchParams, aggregation: Aggregation, extract: (String, Aggregations) => Seq[BucketResult])(implicit ex: ExecutionContext): Future[AggregateSearchResults] = { - implicit val logMarker = MarkerMap() + implicit val logMarker: MarkerMap = MarkerMap() logger.info("aggregate search: " + name + " / " + params + " / " + aggregation) val query = queryBuilder.makeQuery(params.structuredQuery) val search = prepareSearch(query) aggregations aggregation size 0 @@ -348,7 +348,7 @@ class ElasticSearch( } def completionSuggestion(name: String, q: String, size: Int)(implicit ex: ExecutionContext, request: AuthenticatedRequest[AnyContent, Principal]): Future[CompletionSuggestionResults] = { - implicit val logMarker = MarkerMap() + implicit val logMarker: MarkerMap = MarkerMap() val completionSuggestion = ElasticDsl.completionSuggestion(name, name).text(q).skipDuplicates(true) val search = ElasticDsl.search(imagesCurrentAlias) suggestions completionSuggestion diff --git a/media-api/app/lib/elasticsearch/ElasticSearchModel.scala b/media-api/app/lib/elasticsearch/ElasticSearchModel.scala index cc9d46c9fa..193e74f682 100644 --- a/media-api/app/lib/elasticsearch/ElasticSearchModel.scala +++ b/media-api/app/lib/elasticsearch/ElasticSearchModel.scala @@ -6,7 +6,7 @@ import com.gu.mediaservice.model.usage.UsageStatus import com.gu.mediaservice.model.{Image, PrintUsageFilters, SyndicationStatus} import lib.querysyntax.{Condition, Parser} import org.joda.time.DateTime -import play.api.libs.json.Json +import play.api.libs.json.{Json, OWrites} import play.api.mvc.{AnyContent, Request} import scalaz.syntax.applicative._ import scalaz.syntax.std.list._ @@ -22,19 +22,19 @@ case class AggregateSearchResults(results: Seq[BucketResult], total: Long) case class CompletionSuggestionResult(key: String, score: Float) object CompletionSuggestionResult { - implicit val jsonWrites = Json.writes[CompletionSuggestionResult] + implicit val jsonWrites: OWrites[CompletionSuggestionResult] = Json.writes[CompletionSuggestionResult] } case class CompletionSuggestionResults(results: List[CompletionSuggestionResult]) object CompletionSuggestionResults { - implicit val jsonWrites = Json.writes[CompletionSuggestionResults] + implicit val jsonWrites: OWrites[CompletionSuggestionResults] = Json.writes[CompletionSuggestionResults] } case class BucketResult(key: String, count: Long) object BucketResult { - implicit val jsonWrites = Json.writes[BucketResult] + implicit val jsonWrites: OWrites[BucketResult] = Json.writes[BucketResult] } case class AggregateSearchParams(field: String, diff --git a/media-api/test/lib/elasticsearch/ElasticSearchTest.scala b/media-api/test/lib/elasticsearch/ElasticSearchTest.scala index 1ffef260ac..e70d1b1cf2 100644 --- a/media-api/test/lib/elasticsearch/ElasticSearchTest.scala +++ b/media-api/test/lib/elasticsearch/ElasticSearchTest.scala @@ -28,7 +28,7 @@ import scala.concurrent.ExecutionContext.Implicits.global class ElasticSearchTest extends ElasticSearchTestBase with Eventually with ElasticSearchExecutions with MockitoSugar { - implicit val request = mock[AuthenticatedRequest[AnyContent, Principal]] + implicit val request: AuthenticatedRequest[AnyContent, Principal] = mock[AuthenticatedRequest[AnyContent, Principal]] private val index = "images" diff --git a/scripts/src/main/scala/com/gu/mediaservice/scripts/BucketMetadata.scala b/scripts/src/main/scala/com/gu/mediaservice/scripts/BucketMetadata.scala index 6d82f90b99..c79af1bb27 100644 --- a/scripts/src/main/scala/com/gu/mediaservice/scripts/BucketMetadata.scala +++ b/scripts/src/main/scala/com/gu/mediaservice/scripts/BucketMetadata.scala @@ -3,7 +3,7 @@ package com.gu.mediaservice.scripts import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream import org.joda.time.DateTime -import play.api.libs.json.Json +import play.api.libs.json.{Json, OFormat} import software.amazon.awssdk.auth.credentials.{DefaultCredentialsProvider, ProfileCredentialsProvider} import software.amazon.awssdk.regions.Region import software.amazon.awssdk.services.s3.S3Client @@ -15,7 +15,7 @@ import scala.collection.JavaConverters.{asScalaIteratorConverter, iterableAsScal case class ObjectMetadata(key: String, lastModified: Instant, metadata: Map[String, String]) object ObjectMetadata { - implicit val format = Json.format[ObjectMetadata] + implicit val format: OFormat[ObjectMetadata] = Json.format[ObjectMetadata] } /** diff --git a/thrall/app/controllers/ThrallController.scala b/thrall/app/controllers/ThrallController.scala index 68691e9011..6bf464c9ed 100644 --- a/thrall/app/controllers/ThrallController.scala +++ b/thrall/app/controllers/ThrallController.scala @@ -132,7 +132,7 @@ class ThrallController( } } - implicit val pollingMaterializer = Materializer.matFromSystem(actorSystem) + implicit val pollingMaterializer: Materializer = Materializer.matFromSystem(actorSystem) def startMigration = withLoginRedirectAsync { implicit request => diff --git a/thrall/app/lib/RetryHandler.scala b/thrall/app/lib/RetryHandler.scala index af956fde6e..5cd0594ea2 100644 --- a/thrall/app/lib/RetryHandler.scala +++ b/thrall/app/lib/RetryHandler.scala @@ -1,7 +1,7 @@ package lib -import akka.actor.ActorSystem +import akka.actor.{ActorSystem, Scheduler} import akka.pattern.{after, retry} import com.gu.mediaservice.lib.logging.{GridLogging, LogMarker, MarkerMap, combineMarkers} import play.api.{Logger, MarkerContext} @@ -45,7 +45,7 @@ object RetryHandler extends GridLogging { } def handleWithRetry[T](f: WithMarkers[T], retries: Int, delay: FiniteDuration): WithMarkers[T] = (marker) => { - implicit val scheduler = actorSystem.scheduler + implicit val scheduler: Scheduler = actorSystem.scheduler var count = 0 def attempt = () => { diff --git a/thrall/app/lib/ThrallStreamProcessor.scala b/thrall/app/lib/ThrallStreamProcessor.scala index 20739ef0be..eb9c7b89d0 100644 --- a/thrall/app/lib/ThrallStreamProcessor.scala +++ b/thrall/app/lib/ThrallStreamProcessor.scala @@ -12,7 +12,7 @@ import com.gu.mediaservice.lib.logging._ import com.gu.mediaservice.model.{ExternalThrallMessage, InternalThrallMessage, ThrallMessage} import lib.kinesis.{MessageTranslator, ThrallEventConsumer} -import scala.concurrent.Future +import scala.concurrent.{ExecutionContextExecutor, Future} import scala.util.{Failure, Success} sealed trait Priority @@ -55,8 +55,8 @@ class ThrallStreamProcessor( actorSystem: ActorSystem ) extends GridLogging { - implicit val mat = Materializer.matFromSystem(actorSystem) - implicit val dispatcher = actorSystem.getDispatcher + implicit val mat: Materializer = Materializer.matFromSystem(actorSystem) + implicit val dispatcher: ExecutionContextExecutor = actorSystem.getDispatcher val mergedKinesisSource: Source[TaggedRecord[ThrallMessage], NotUsed] = Source.fromGraph(GraphDSL.create() { implicit graphBuilder => import GraphDSL.Implicits._ diff --git a/thrall/app/lib/elasticsearch/EsInfo.scala b/thrall/app/lib/elasticsearch/EsInfo.scala index c0b934bea4..03f4775270 100644 --- a/thrall/app/lib/elasticsearch/EsInfo.scala +++ b/thrall/app/lib/elasticsearch/EsInfo.scala @@ -1,12 +1,12 @@ package lib.elasticsearch -import play.api.libs.json.{Json, Writes} +import play.api.libs.json.{Json, OFormat, Reads, Writes} import scala.collection.compat._ case class MigrationInfo(failures: Option[Map[String, String]] = None, migratedTo: Option[String] = None) object MigrationInfo { - implicit val reads = Json.reads[MigrationInfo] + implicit val reads: Reads[MigrationInfo] = Json.reads[MigrationInfo] implicit val writes: Writes[MigrationInfo] = (migrationInfo: MigrationInfo) => Json.obj( "migratedTo" -> migrationInfo.migratedTo, "failures" -> migrationInfo.failures.map(_.view.mapValues { @@ -20,5 +20,5 @@ object MigrationInfo { case class EsInfo(migration: Option[MigrationInfo] = None) object EsInfo { - implicit val format = Json.format[EsInfo] + implicit val format: OFormat[EsInfo] = Json.format[EsInfo] } diff --git a/thrall/test/lib/OrderedFutureRunnerTest.scala b/thrall/test/lib/OrderedFutureRunnerTest.scala index acc11951cb..1c6478aac8 100644 --- a/thrall/test/lib/OrderedFutureRunnerTest.scala +++ b/thrall/test/lib/OrderedFutureRunnerTest.scala @@ -10,7 +10,7 @@ import scala.util.Success class OrderedFutureRunnerTest extends AnyFlatSpec with Matchers { private val order = (0 to 10).toList private var current = 0 - implicit val executionContext = ExecutionContext.Implicits.global + implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global "OrderedFutureRunner.run" should "execute the futures in order" in { diff --git a/usage/app/lib/CrierEventProcessor.scala b/usage/app/lib/CrierEventProcessor.scala index 0fa64ee462..3b761c9f3f 100644 --- a/usage/app/lib/CrierEventProcessor.scala +++ b/usage/app/lib/CrierEventProcessor.scala @@ -10,6 +10,7 @@ import com.gu.crier.model.event.v1.{Event, EventPayload, EventType} import com.gu.mediaservice.lib.logging.{GridLogging, LogMarker, MarkerMap} import com.gu.mediaservice.model.usage.{PendingUsageStatus, PublishedUsageStatus} import com.gu.thrift.serializer.ThriftDeserializer +import com.twitter.scrooge.ThriftStructCodec import model.{UsageGroup, UsageGroupOps} import org.joda.time.DateTime import rx.lang.scala.Subject @@ -66,7 +67,7 @@ case class PreviewContentItem(content: Content, lastModified: DateTime, isReinde abstract class CrierEventProcessor(config: UsageConfig, usageGroupOps: UsageGroupOps) extends IRecordProcessor with GridLogging { - implicit val codec = Event + implicit val codec: ThriftStructCodec[Event] = Event val contentApiClient: UsageContentApiClient