Skip to content

Commit b32a366

Browse files
committed
scalafmt ran
1 parent c8ba505 commit b32a366

File tree

12 files changed

+57
-43
lines changed

12 files changed

+57
-43
lines changed

Diff for: internal-scripts/ClassRenamer.scala

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** This is an internal scala-cli script written just to reduce manual work of
2-
* renaming files and class names to follow naming standards. This doesn't fully correct all the class names,
3-
* however reduces the manual effort by 90%.
2+
* renaming files and class names to follow naming standards. This doesn't
3+
* fully correct all the class names, however reduces the manual effort by 90%.
44
*/
55
//> using toolkit default
66
import os._
@@ -14,7 +14,10 @@ object RenameClassNames {
1414
.filter(_.toString.contains("src/test/scala"))
1515
.filterNot(_.toString.endsWith("UnitTest.scala"))
1616
.filter(f =>
17-
f.toString.endsWith("Test.scala") || f.toString.endsWith("Spec.scala") || f.toString.endsWith("Tests.scala") || f.toString.endsWith("Suite.scala")
17+
f.toString.endsWith("Test.scala") || f.toString.endsWith(
18+
"Spec.scala"
19+
) || f.toString.endsWith("Tests.scala") || f.toString
20+
.endsWith("Suite.scala")
1821
)
1922
.foreach { _filePath =>
2023
val _fileName = _filePath.last

Diff for: sbt-standalone/build.sbt

+9-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ scalacOptions += "-target:17"
1010
// Setting source and target for Java
1111
javacOptions ++= Seq("-source", "17", "-target", "17")
1212

13-
1413
// Enforcing the minimum JVM version
1514
initialize := {
16-
val _ = initialize.value // Ensure previous initializations are run
17-
18-
val required = VersionNumber("17")
19-
val current = VersionNumber(sys.props("java.specification.version"))
20-
println(current)
21-
assert(CompatibleJavaVersion(current, required), s"Java $required or above is required to run this project.")
15+
val _ = initialize.value // Ensure previous initializations are run
16+
17+
val required = VersionNumber("17")
18+
val current = VersionNumber(sys.props("java.specification.version"))
19+
println(current)
20+
assert(
21+
CompatibleJavaVersion(current, required),
22+
s"Java $required or above is required to run this project."
23+
)
2224
}
23-

Diff for: sbt-standalone/project/CompatibleJavaVersion.scala

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import sbt._
22

33
// Define a custom object for Java specification version compatibility
44
object CompatibleJavaVersion extends VersionNumberCompatibility {
5-
def name = "Java specification compatibility"
5+
def name = "Java specification compatibility"
66

7-
def isCompatible(current: VersionNumber, required: VersionNumber): Boolean =
8-
current.numbers.zip(required.numbers)
9-
.foldRight(required.numbers.size <= current.numbers.size) {
10-
case ((curr, req), acc) => (curr > req) || (curr == req && acc)
11-
}
7+
def isCompatible(current: VersionNumber, required: VersionNumber): Boolean =
8+
current.numbers
9+
.zip(required.numbers)
10+
.foldRight(required.numbers.size <= current.numbers.size) {
11+
case ((curr, req), acc) => (curr > req) || (curr == req && acc)
12+
}
1213

13-
def apply(current: VersionNumber, required: VersionNumber): Boolean =
14-
isCompatible(current, required)
15-
}
14+
def apply(current: VersionNumber, required: VersionNumber): Boolean =
15+
isCompatible(current, required)
16+
}

Diff for: sbt-standalone/src/main/scala/Main.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
object Main extends App {
22
println("Hello from Scala!")
3-
}
3+
}

Diff for: scala-2-modules/scala2-libraries/src/finch/todo/src/main/scala/com/baeldung/finch/todo/Main.scala

+10-11
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,16 @@ object Main extends IOApp {
5555
} yield Created(created)
5656
}
5757

58-
val getTodo: Endpoint[IO, Todo] = get(todosPath :: path[Int]) {
59-
id: Int =>
60-
for {
61-
todos <- sql"select * from todo where id = $id"
62-
.query[Todo]
63-
.to[Set]
64-
.transact(xa)
65-
} yield todos.headOption match {
66-
case None => NotFound(new Exception("Record not found"))
67-
case Some(todo) => Ok(todo)
68-
}
58+
val getTodo: Endpoint[IO, Todo] = get(todosPath :: path[Int]) { id: Int =>
59+
for {
60+
todos <- sql"select * from todo where id = $id"
61+
.query[Todo]
62+
.to[Set]
63+
.transact(xa)
64+
} yield todos.headOption match {
65+
case None => NotFound(new Exception("Record not found"))
66+
case Some(todo) => Ok(todo)
67+
}
6968
}
7069

7170
val updateTodo: Endpoint[IO, Todo] =

Diff for: scala-akka-2/src/test/scala-2/com/baeldung/scala/akka_2/persistence/BankAccountUnitTest.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import akka.actor.testkit.typed.scaladsl.ScalaTestWithActorTestKit
44
import akka.pattern.StatusReply
55
import org.scalatest.wordspec.AnyWordSpecLike
66

7-
class BankAccountUnitTest extends ScalaTestWithActorTestKit with AnyWordSpecLike {
7+
class BankAccountUnitTest
8+
extends ScalaTestWithActorTestKit
9+
with AnyWordSpecLike {
810

911
"A Bank Account" should {
1012
"deposit money to a bank account" in {

Diff for: scala-akka-2/src/test/scala/com/baeldung/scala/akka/http/routetesting/AkkaRoutesUnitTest.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import com.baeldung.scala.akka.http.routetesting.AkkaRoutes.routes
77
import org.scalatest.flatspec.AnyFlatSpec
88
import org.scalatest.matchers.should.Matchers
99

10-
class AkkaRoutesUnitTest extends AnyFlatSpec with Matchers with ScalatestRouteTest {
10+
class AkkaRoutesUnitTest
11+
extends AnyFlatSpec
12+
with Matchers
13+
with ScalatestRouteTest {
1114
"/hello" should "return Hello World!" in {
1215
Get("/hello") ~> routes ~> check {
1316
status shouldEqual StatusCodes.OK

Diff for: scala-akka-3/src/test/scala/com/baeldung/scala/akka/TestServiceUnitTest.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import org.scalatest.matchers.should.Matchers
55
import org.scalatest.wordspec.AnyWordSpec
66
import akka.actor.testkit.typed.scaladsl.ActorTestKit
77

8-
class TestServiceUnitTest extends AnyWordSpec with BeforeAndAfterAll with Matchers {
8+
class TestServiceUnitTest
9+
extends AnyWordSpec
10+
with BeforeAndAfterAll
11+
with Matchers {
912
val testKit = ActorTestKit()
1013
implicit val system = testKit.system
1114

Diff for: scala-test-junit4/src/test/scala/com/baeldung/scala/junit4/TypesTestUnitTest.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ import org.junit.runner.RunWith
44
import org.junit.runners.Suite
55

66
@RunWith(classOf[Suite])
7-
@Suite.SuiteClasses(Array(classOf[IntJunitUnitTest], classOf[StringJunitUnitTest]))
7+
@Suite.SuiteClasses(
8+
Array(classOf[IntJunitUnitTest], classOf[StringJunitUnitTest])
9+
)
810
class TypesTestUnitTest

Diff for: scala-with-maven/hello-rest/src/main/scala/HelloRest.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import org.http4s.HttpRoutes
22
import org.http4s.dsl.io._
33
import cats.effect._
44

5-
val helloWorldService = HttpRoutes.of[IO] {
6-
case GET -> Root / "hello" => Ok("Hello, World!")
7-
}
5+
val helloWorldService = HttpRoutes.of[IO] { case GET -> Root / "hello" =>
6+
Ok("Hello, World!")
7+
}

Diff for: scala-with-maven/hello-world/src/main/scala/HelloWorld.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ object HelloWorld {
55
def message: String = "Hello, World!"
66

77
def main(args: Array[String]): Unit = println(message)
8-
9-
}
8+
9+
}

Diff for: scala-with-maven/hello-world/src/test/scala/HelloWorldUnitTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import org.scalatest.flatspec.AnyFlatSpec
44
import org.scalatest.matchers.should.Matchers
55

66
class HelloWorldUnitTest extends AnyFlatSpec with Matchers {
7-
7+
88
"The HelloWorld object" should "say hello" in {
99
val greeting = HelloWorld.message
1010
greeting shouldEqual "Hello, World!"
1111
}
12-
}
12+
}

0 commit comments

Comments
 (0)