Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-Scala 2.13 Scalafix #197

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rules = [
ExplicitResultTypes,
ProcedureSyntax,
]
ExplicitResultTypes.onlyImplicits = true
2 changes: 1 addition & 1 deletion app/conf/Configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ object Properties extends AutomaticResourceManagement {
}

trait AutomaticResourceManagement {
def withCloseable[T <: { def close() }](closeable: T) = new {
def withCloseable[T <: { def close(): Unit }](closeable: T) = new {
def apply[S](body: T => S) = try {
body(closeable)
} finally {
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/DefaultsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import conf.ApplicationConfiguration
import play.api.Mode.Dev
import play.api.libs.ws.WSClient
import story_packages.switchboard.SwitchManager
import play.api.libs.json.OWrites

object Defaults {
implicit val jsonFormat = Json.writes[Defaults]
implicit val jsonFormat: OWrites[Defaults] = Json.writes[Defaults]
}

case class Defaults(
Expand Down
4 changes: 2 additions & 2 deletions app/story_packages/metrics/CloudWatch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class CloudWatch(config: ApplicationConfiguration) extends Logging {
}

trait LoggingAsyncHandler extends AsyncHandler[PutMetricDataRequest, PutMetricDataResult] {
def onError(exception: Exception)
def onError(exception: Exception): Unit =
{
Logger.info(s"CloudWatch PutMetricDataRequest error: ${exception.getMessage}}")
}
def onSuccess(request: PutMetricDataRequest, result: PutMetricDataResult )
def onSuccess(request: PutMetricDataRequest, result: PutMetricDataResult ): Unit =
{
Logger.info("CloudWatch PutMetricDataRequest - success")
}
Expand Down
2 changes: 1 addition & 1 deletion app/story_packages/metrics/metrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class CloudWatchApplicationMetrics(appName: String, stage: String, cloudWatch: C
)
)}

private def report() {
private def report(): Unit = {
val allMetrics: List[FrontendMetric] = this.systemMetrics ::: this.applicationMetrics
if (!isDev) {
val stageDimension = new Dimension().withName("Stage").withValue(stage)
Expand Down
7 changes: 4 additions & 3 deletions app/story_packages/model/StoryPackage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package story_packages.model

import org.joda.time.{DateTime, DateTimeZone}
import play.api.libs.json.Json
import play.api.libs.json.OFormat

case class StoryPackage(
id: Option[String],
Expand All @@ -15,11 +16,11 @@ case class StoryPackage(
deleted: Option[Boolean]
) {}
object StoryPackage {
implicit val jsonFormat = Json.format[StoryPackage]
implicit val jsonFormat: OFormat[StoryPackage] = Json.format[StoryPackage]
}

object SortByLastModify {
implicit val sortByModifyDate = new Ordering[StoryPackage] {
implicit val sortByModifyDate: Ordering[StoryPackage] = new Ordering[StoryPackage] {
def compare(a: StoryPackage, b: StoryPackage) = (a.lastModify, b.lastModify) match {
case (None, None) => 0
case (Some(_), None) => -1
Expand All @@ -29,7 +30,7 @@ object SortByLastModify {
}
}
object SortByName {
implicit val sortByModifyDate = new Ordering[StoryPackage] {
implicit val sortByModifyDate: Ordering[StoryPackage] = new Ordering[StoryPackage] {
def compare(a: StoryPackage, b: StoryPackage) = (a.name, b.name) match {
case (None, None) => 0
case (Some(_), None) => -1
Expand Down
2 changes: 1 addition & 1 deletion app/story_packages/model/frontsapi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait UpdateActionsTrait extends Logging {
def frontsApi: FrontsApi
def config: ApplicationConfiguration

implicit val updateListWrite = Json.writes[UpdateList]
implicit val updateListWrite: OWrites[UpdateList] = Json.writes[UpdateList]

def insertIntoLive(update: UpdateList, identity: User, collectionJson: CollectionJson): CollectionJson = {
val live = updateList(update, identity, collectionJson.live)
Expand Down
4 changes: 2 additions & 2 deletions app/story_packages/services/S3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ trait S3 extends Logging {
result => new DateTime(result.getObjectMetadata.getLastModified)
}

def putPrivate(key: String, value: String, contentType: String) {
def putPrivate(key: String, value: String, contentType: String): Unit = {
put(key: String, value: String, contentType: String, Private)
}

private def put(key: String, value: String, contentType: String, accessControlList: CannedAccessControlList) {
private def put(key: String, value: String, contentType: String, accessControlList: CannedAccessControlList): Unit = {
val metadata = new ObjectMetadata()
metadata.setCacheControl("no-cache,no-store")
metadata.setContentType(contentType)
Expand Down
2 changes: 1 addition & 1 deletion app/story_packages/switchboard/Switchboard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Lifecycle(conf: SwitchboardConfiguration, scheduler: Scheduler) extends Lo
Logger.info("Starting switchboard cache")
scheduler.scheduleWithFixedDelay(initialDelay = 1.seconds, delay = 1.minute) { () => refreshSwitches() }

def refreshSwitches() {
def refreshSwitches(): Unit = {
Logger.info("Refreshing switches from switchboard")
client.getSwitches() foreach { response => SwitchManager.updateSwitches(response) }
}
Expand Down
2 changes: 1 addition & 1 deletion app/story_packages/updates/KinesisEventSender.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class KinesisEventSender(config: ApplicationConfiguration) extends Logging {
articles = createUpdatePayload(collectionJson)))
}

def sendUpdate(streamName: String, collectionId: String, event: Event) {
def sendUpdate(streamName: String, collectionId: String, event: Event): Unit = {
val request = new PutRecordsRequest().withStreamName(streamName)
val bytes = ThriftSerializer.serializeToBytes(event, Some(GzipType), Some(128))
if (bytes.length > config.updates.maxDataSize) {
Expand Down
3 changes: 2 additions & 1 deletion app/story_packages/updates/Reindex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.duration._
import scala.util.control.NonFatal
import play.api.libs.json.OFormat

case class ReindexPage(
totalCount: Int,
Expand Down Expand Up @@ -39,7 +40,7 @@ case class ReindexProgress(
documentsExpected: Int
)
object ReindexProgress {
implicit val jsonFormat = Json.format[ReindexProgress]
implicit val jsonFormat: OFormat[ReindexProgress] = Json.format[ReindexProgress]
}

sealed trait ReindexStatus{val label: String}
Expand Down
2 changes: 1 addition & 1 deletion app/story_packages/updates/UpdateMessage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ case class Remove(remove: UpdateList) extends UpdateMessage

/* Macro - Watch out, this needs to be after the case classes */
object UpdateMessage {
implicit val format = derived.flat.oformat[UpdateMessage]((__ \ "type").format[String])
implicit val format: OFormat[UpdateMessage] = derived.flat.oformat[UpdateMessage]((__ \ "type").format[String])
}

/* Kinesis messages */
Expand Down
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.19")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")

libraryDependencies += "org.vafer" % "jdeb" % "1.3" artifacts (Artifact("jdeb", "jar", "jar"))

addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1")
Loading