Skip to content

Commit cae069a

Browse files
authored
Merge pull request #557 from yadavan88/scalafmt-styling
Scalafmt on the entire project
2 parents 5cf1dc8 + 7a76062 commit cae069a

File tree

381 files changed

+4328
-3032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+4328
-3032
lines changed

.scalafmt.conf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
version = 3.5.9
2-
runner.dialect = scala3
1+
version = 3.7.1
2+
runner.dialect = scala213
3+
fileOverride {
4+
"glob:**/scala3-*/**" {
5+
runner.dialect = scala3
6+
}
7+
}
38
continuationIndent.defnSite = 2
49
continuationIndent.ctorSite = 2
510
continuationIndent.extendSite = 2

cats-effects/src/main/scala/com/baeldung/scala/catseffects/LazyIO.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package com.baeldung.scala.catseffects
22

33
case class LazyIO[A](runEffect: () => A) {
44
def map[B](fn: A => B): LazyIO[B] = LazyIO.io(fn(runEffect()))
5-
6-
def flatMap[B](fn: A => LazyIO[B]): LazyIO[B] = LazyIO.io(fn(runEffect()).runEffect())
5+
6+
def flatMap[B](fn: A => LazyIO[B]): LazyIO[B] =
7+
LazyIO.io(fn(runEffect()).runEffect())
78
}
89

910
object LazyIO {

cats-effects/src/main/scala/com/baeldung/scala/catseffects/MissileLaucher.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import cats.effect.{ExitCode, IO, IOApp}
44

55
object MissileLaucher extends IOApp {
66
def putStr(str: String): IO[Unit] = IO.delay(println(str))
7-
7+
88
val launch: IO[Unit] = for {
99
_ <- putStr("Lauch missiles")
1010
_ <- putStr("Lauch missiles")
1111
} yield ()
12-
13-
override def run(args: List[String]): IO[ExitCode] = launch.as(ExitCode.Success)
12+
13+
override def run(args: List[String]): IO[ExitCode] =
14+
launch.as(ExitCode.Success)
1415
}

cats-effects/src/main/scala/com/baeldung/scala/catseffects/NotParallelApp.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import com.baeldung.scala.catseffects.Utils.ShowThread
77
object NotParallelApp extends IOApp {
88
val tasks: List[IO[Int]] = (1 to 10).map(IO.pure).map(_.showThread).toList
99

10-
val incremented: IO[List[Int]] = tasks.traverse {
11-
ioi => for (i <- ioi) yield i + 1
10+
val incremented: IO[List[Int]] = tasks.traverse { ioi =>
11+
for (i <- ioi) yield i + 1
1212
}
13-
13+
1414
val parallelOrNot: IO[List[Int]] = incremented.showThread
15-
16-
override def run(args: List[String]): IO[ExitCode] = parallelOrNot.as(ExitCode.Success)
17-
15+
16+
override def run(args: List[String]): IO[ExitCode] =
17+
parallelOrNot.as(ExitCode.Success)
18+
1819
}

cats-effects/src/main/scala/com/baeldung/scala/catseffects/ParallelApp.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import com.baeldung.scala.catseffects.Utils.ShowThread
77
object ParallelApp extends IOApp {
88
val tasks: List[IO[Int]] = (1 to 10).map(IO.pure).map(_.showThread).toList
99

10-
val incremented: IO[List[Int]] = tasks.parTraverse {
11-
ioi => for (i <- ioi) yield i + 1
10+
val incremented: IO[List[Int]] = tasks.parTraverse { ioi =>
11+
for (i <- ioi) yield i + 1
1212
}
1313

1414
val parallelOrNot: IO[List[Int]] = incremented.showThread
1515

16-
override def run(args: List[String]): IO[ExitCode] = parallelOrNot.as(ExitCode.Success)
16+
override def run(args: List[String]): IO[ExitCode] =
17+
parallelOrNot.as(ExitCode.Success)
1718
}

cats-effects/src/main/scala/com/baeldung/scala/catseffects/SequenceApp.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ object SequenceApp extends IOApp {
88

99
val tasks: List[IO[Int]] = (1 to 1000).map(IO.pure).toList
1010
val sequenceAllTasks: IO[List[Int]] = tasks.sequence
11-
val printTaskSequence: IO[Unit] = sequenceAllTasks.map(_.mkString(", ")).flatMap(putStr)
12-
13-
override def run(args: List[String]): IO[ExitCode] = sequenceAllTasks.as(ExitCode.Success)
11+
val printTaskSequence: IO[Unit] =
12+
sequenceAllTasks.map(_.mkString(", ")).flatMap(putStr)
13+
14+
override def run(args: List[String]): IO[ExitCode] =
15+
sequenceAllTasks.as(ExitCode.Success)
1416
}

cats-effects/src/main/scala/com/baeldung/scala/catseffects/Substitution.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ object Substitution {
1111
}
1212

1313
def effectfulWithFuture(): Unit = {
14-
implicit val ec: ExecutionContextExecutor = ExecutionContext.global
15-
Future(println("Launch missiles")).map(_ => Future(println("Launch missiles")))
14+
implicit val ec: ExecutionContextExecutor = ExecutionContext.global
15+
Future(println("Launch missiles")).map(_ =>
16+
Future(println("Launch missiles"))
17+
)
1618
}
1719

1820
def effectfulWithFutureRefactored(): Unit = {

cats-effects/src/main/scala/com/baeldung/scala/catseffects/TraverseApp.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ object TraverseApp extends IOApp {
99
val tasks: List[Int] = (1 to 1000).toList
1010
def taskExecutor(i: Int): String = s"Executing task $i"
1111
val runAllTasks: IO[List[Unit]] = tasks.traverse(i => putStr(taskExecutor(i)))
12-
13-
override def run(args: List[String]): IO[ExitCode] = runAllTasks.as(ExitCode.Success)
12+
13+
override def run(args: List[String]): IO[ExitCode] =
14+
runAllTasks.as(ExitCode.Success)
1415
}

cats-effects/src/main/scala/com/baeldung/scala/catseffects/Utils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import cats.effect.IO
55
object Utils {
66
implicit class ShowThread[T](io: IO[T]) {
77
def showThread: IO[T] = for {
8-
thunk <- io
8+
thunk <- io
99
thread = Thread.currentThread.getName
1010
_ = println(s"[$thread] $thunk")
1111
} yield thunk

cats-effects/src/main/scala/com/baeldung/scala/differences/Differences.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ object Differences extends IOApp.Simple {
1111

1212
val delayedDurationIO = io.delayBy(3.seconds)
1313

14-
//This will fail with Stackoverflow Exception
14+
// This will fail with Stackoverflow Exception
1515
def neverEnding(io: IO[Int]): IO[Unit] = { io *> neverEnding(io) }
1616

17-
//This will run forever without any StackOverflowException
17+
// This will run forever without any StackOverflowException
1818
def neverEndingV2(io: IO[Int]): IO[Unit] = {
1919
io *> IO.defer(neverEndingV2(io))
2020
}

0 commit comments

Comments
 (0)