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

Update scalafmt-core to 3.8.4 #370

Merged
merged 3 commits into from
Jan 15, 2025
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.8.4
f02d45a6f6abeed0724ab0224e05437fc58cbd56
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.8.3
version = 3.8.4
maxColumn = 120
runner.dialect = scala213
fileOverride {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class AppApplicationLoader extends ApplicationLoader {
}

trait AppComponents
extends BuiltInComponents
with NingWSComponents // for wsClient
with DatabaseModule // Database injection
with DaoModule
with ControllerModule // Application controllers
{
extends BuiltInComponents
with NingWSComponents // for wsClient
with DatabaseModule // Database injection
with DaoModule
with ControllerModule // Application controllers
{
implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

lazy val assets: Assets = wire[Assets]
Expand All @@ -48,4 +48,3 @@ with ControllerModule // Application controllers
}

class Z(as: ActorSystem)

18 changes: 9 additions & 9 deletions examples/play24/app/com/softwaremill/play24/Seed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import scala.concurrent.duration._
import scala.language.postfixOps

class Seed(
val dbConfig: DatabaseConfig[JdbcProfile],
val coffeeDao: CoffeeDao,
val supplierDao: SupplierDao
val dbConfig: DatabaseConfig[JdbcProfile],
val coffeeDao: CoffeeDao,
val supplierDao: SupplierDao
) {

import dbConfig.driver.api._
Expand All @@ -26,17 +26,17 @@ class Seed(

// Insert some suppliers
supplierDao.query += Supplier(101, "Acme, Inc.", "99 Market Street", "Groundsville", "CA", "95199"),
supplierDao.query += Supplier( 49, "Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460"),
supplierDao.query += Supplier(150, "The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966"),
supplierDao.query += Supplier(49, "Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460"),
supplierDao.query += Supplier(150, "The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966"),
// Equivalent SQL code:
// insert into SUPPLIERS(SUP_ID, SUP_NAME, STREET, CITY, STATE, ZIP) values (?,?,?,?,?,?)

// Insert some coffees (using JDBC's batch insert feature, if supported by the DB)
coffeeDao.query ++= Seq(
Coffee("Colombian", 101, 7.99, 0, 0),
Coffee("French_Roast", 49, 8.99, 0, 0),
Coffee("Espresso", 150, 9.99, 0, 0),
Coffee("Colombian_Decaf", 101, 8.99, 0, 0),
Coffee("Colombian", 101, 7.99, 0, 0),
Coffee("French_Roast", 49, 8.99, 0, 0),
Coffee("Espresso", 150, 9.99, 0, 0),
Coffee("Colombian_Decaf", 101, 8.99, 0, 0),
Coffee("French_Roast_Decaf", 49, 9.99, 0, 0)
)
// Equivalent SQL code:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import play.api.mvc.{Action, Controller}
import scala.concurrent.ExecutionContext

class CoffeeController(
coffeeDao: CoffeeDao
)(implicit ec: ExecutionContext) extends Controller {
coffeeDao: CoffeeDao
)(implicit ec: ExecutionContext)
extends Controller {

def fetchAll() = Action.async { request =>
coffeeDao.all.map { coffees =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import play.api.mvc.{Action, Controller}
import scala.concurrent.ExecutionContext

class SupplierController(
supplierDao: SupplierDao
)(implicit ec: ExecutionContext) extends Controller {
supplierDao: SupplierDao
)(implicit ec: ExecutionContext)
extends Controller {

def fetchAll() = Action.async { request =>
supplierDao.all.map { suppliers =>
Expand Down
15 changes: 7 additions & 8 deletions examples/play24/app/com/softwaremill/play24/models/Coffee.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ package com.softwaremill.play24.models
import play.api.libs.json.Json
import slick.driver.H2Driver.api._

case class Coffee (
name: String,
supId: Int,
price: Double,
sales: Int,
total: Int
case class Coffee(
name: String,
supId: Int,
price: Double,
sales: Int,
total: Int
)

object Coffee {
implicit val format = Json.format[Coffee]
}


class CoffeeTable(tag: Tag) extends Table[Coffee](tag, "COFFEES") {
def name = column[String]("COF_NAME", O.PrimaryKey)
def supID = column[Int]("SUP_ID")
Expand All @@ -25,4 +24,4 @@ class CoffeeTable(tag: Tag) extends Table[Coffee](tag, "COFFEES") {
def * = (name, supID, price, sales, total) <> ((Coffee.apply _).tupled, Coffee.unapply)
// A reified foreign key relation that can be navigated to create a join
def supplier = foreignKey("SUP_FK", supID, TableQuery[SupplierTable])(_.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import play.api.libs.json.Json
import slick.driver.H2Driver.api._

case class Supplier(
id: Int,
name: String,
street: String,
city: String,
state: String,
zip: String
id: Int,
name: String,
street: String,
city: String,
state: String,
zip: String
)

object Supplier {
Expand All @@ -24,5 +24,5 @@ class SupplierTable(tag: Tag) extends Table[Supplier](tag, "SUPPLIERS") {
def state = column[String]("STATE")
def zip = column[String]("ZIP")
// Every table needs a * projection with the same type as the table's type parameter
def * = (id, name, street, city, state, zip) <> ((Supplier.apply _).tupled, Supplier.unapply)
def * = (id, name, street, city, state, zip) <> ((Supplier.apply _).tupled, Supplier.unapply)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import play.api.test.Helpers._

import scala.concurrent.Future

/**
* Spec for testing controller logic, independent of external dependencies. Since our controllers don't really have any
* logic, just testing the output
*/
/** Spec for testing controller logic, independent of external dependencies. Since our controllers don't really have any
* logic, just testing the output
*/
class CoffeeControllerSpec extends Specification {
"Coffee Controller" should {
"return all" in new ControllerContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import org.specs2.specification.Scope
import scala.concurrent.ExecutionContext

trait ControllerContext
extends ControllerModule
with MockDaoModule
with MockWsClient
with Scope
with MustThrownExpectations
{
extends ControllerModule
with MockDaoModule
with MockWsClient
with Scope
with MustThrownExpectations {
implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class CoffeeSpec extends PlaySpecification {

println(status(response.get))

response must beSome.which (status(_) == OK)
response must beSome.which(status(_) == OK)
}
}

"/coffee/priced/" should {
"return priced coffees" in new IntegrationContext {
val response = route(FakeRequest(GET, "/coffee/priced/9"))

response must beSome.which (status(_) == OK)
response must beSome.which(status(_) == OK)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.softwaremill.play24.it
import com.softwaremill.play24.AppApplicationLoader
import play.api.test.WithApplicationLoader

class IntegrationContext extends WithApplicationLoader(
applicationLoader = new AppApplicationLoader
)
class IntegrationContext
extends WithApplicationLoader(
applicationLoader = new AppApplicationLoader
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package com.softwaremill.play24.it

class SupplierSpec {

}
class SupplierSpec {}
2 changes: 1 addition & 1 deletion examples/scalajs/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ scalaVersion := "2.11.7"

libraryDependencies += "com.softwaremill.macwire" %% "macros" % "2.2.0"

libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.8.2"
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.8.2"
2 changes: 1 addition & 1 deletion examples/scalajs/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.5")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.5")
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ object MacwireScalajsExample extends JSApp with MainModule {
}

override def main() {}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.softwaremill.macwire.examples.scalatra.logic

class Service2(submittedData: SubmittedData,
service3: Service3,
loggedInUser: LoggedInUser) {
def fetchStatus = {
Thread.sleep(20L)
s"This is Service2. " +
s"Logged in user: ${loggedInUser.username}, " +
s"submitted data: ${submittedData.data}, " +
s"service 3: ${service3.fetchStatus}"
}
}
class Service2(submittedData: SubmittedData, service3: Service3, loggedInUser: LoggedInUser) {
def fetchStatus = {
Thread.sleep(20L)
s"This is Service2. " +
s"Logged in user: ${loggedInUser.username}, " +
s"submitted data: ${submittedData.data}, " +
s"service 3: ${service3.fetchStatus}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import org.scalatra.ScalatraServlet
import org.scalatra.scalate.ScalateSupport
import com.softwaremill.macwire.examples.scalatra.logic.{SubmittedData, Service2, Service1}

class Servlet1(service1: Service1, service2: Service2, submittedData: SubmittedData) extends ScalatraServlet with ScalateSupport {
class Servlet1(service1: Service1, service2: Service2, submittedData: SubmittedData)
extends ScalatraServlet
with ScalateSupport {
get("/") {
submittedData.data = params.getOrElse("data", null)
contentType = "text/html"
ssp("index",
"service1status" -> service1.fetchStatus,
"service2status" -> service2.fetchStatus)
ssp("index", "service1status" -> service1.fetchStatus, "service2status" -> service2.fetchStatus)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object TimingInterceptor extends ProxyingInterceptor {
ctx.proceed()
} finally {
val end = System.currentTimeMillis()
println(s"Invocation of $classWithMethodName took: ${end-start}ms")
println(s"Invocation of $classWithMethodName took: ${end - start}ms")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.softwaremill.macwire
object WireWithCodeGen {

def main(args: Array[String]) = {
for(idx <- 0 until 22) {
for (idx <- 0 until 22) {
val tpes = (0 to idx).map(i => ('A' + i).toChar).mkString(",")
println(s"def wireWith[$tpes,RES](factory: ($tpes) => RES): RES = macro MacwireMacros.wireWith_impl[RES]")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.softwaremill.macwire
object WireWithCodeGen {

def main(args: Array[String]) = {
for(idx <- 0 until 22) {
for (idx <- 0 until 22) {
val tpes = (0 to idx).map(i => ('A' + i).toChar).mkString(",")
println(s"inline def wireWith[$tpes,RES](inline factory: ($tpes) => RES): RES = $${ MacwireMacros.wireWith_impl[RES]('factory) }")
println(
s"inline def wireWith[$tpes,RES](inline factory: ($tpes) => RES): RES = $${ MacwireMacros.wireWith_impl[RES]('factory) }"
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ import scala.concurrent.duration._

object AfterAllTerminate {

/**
* We need to terminate ActorSystem.
* It can be done in test script in last line by simply calling `system.terminate()`.
* However above solution can terminate the `actorSystem` sooner than all messages are being delivered.
* That will result in ugly messages in test logs which are not related to bugs:
/** We need to terminate ActorSystem. It can be done in test script in last line by simply calling
* `system.terminate()`. However above solution can terminate the `actorSystem` sooner than all messages are being
* delivered. That will result in ugly messages in test logs which are not related to bugs:
*
* {{{[INFO] [01/31/2017 19:33:21.407] [wireProps-9-subtypeDependencyInScope-akka.actor.default-dispatcher-6] [akka://wireProps-9-subtypeDependencyInScope/user/someActor] Message [java.lang.String] from Actor[akka://wireProps-9-subtypeDependencyInScope/deadLetters] to Actor[akka://wireProps-9-subtypeDependencyInScope/user/someActor#-2046131540] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.[info] wireActor-11-toManyInjectAnnotations.failure}}}
*
* If we terminate `ActorSystem` using this hook the system will be terminated after all messages
* are being delivered. Logs become cleaner.
* If we terminate `ActorSystem` using this hook the system will be terminated after all messages are being
* delivered. Logs become cleaner.
*/
def apply(system: ActorSystem): Unit = Runtime.getRuntime.addShutdownHook(
MonitorableThreadFactory(
name = "monitoring-thread-factory",
daemonic = false,
contextClassLoader = Some(Thread.currentThread().getContextClassLoader)).newThread(new Runnable {
contextClassLoader = Some(Thread.currentThread().getContextClassLoader)
).newThread(new Runnable {
override def run(): Unit = {
val terminate = system.terminate()
Await.result(terminate, 10.seconds)
Expand Down
Loading