Skip to content

Commit

Permalink
Merge pull request #162 from scala-steward/update/scalafmt-core-3.0.0
Browse files Browse the repository at this point in the history
Update scalafmt-core to 3.0.0
  • Loading branch information
eikek authored Aug 19, 2021
2 parents 3511478 + f064290 commit 03185b9
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "2.7.5"
version = "3.0.0"

preset = defaultWithAlign

Expand Down
20 changes: 10 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ val sharedSettings = Seq(
)
else
Nil),
crossScalaVersions := Seq(scala212, scala213, scala3),
Test / console / scalacOptions := Seq(),
crossScalaVersions := Seq(scala212, scala213, scala3),
Test / console / scalacOptions := Seq(),
Compile / console / scalacOptions := Seq(),
licenses := Seq("MIT" -> url("http://spdx.org/licenses/MIT")),
homepage := Some(url("https://github.com/eikek/calev")),
versionScheme := Some("early-semver")
licenses := Seq("MIT" -> url("http://spdx.org/licenses/MIT")),
homepage := Some(url("https://github.com/eikek/calev")),
versionScheme := Some("early-semver")
) ++ publishSettings

lazy val publishSettings = Seq(
Expand All @@ -76,8 +76,8 @@ lazy val publishSettings = Seq(
)

lazy val noPublish = Seq(
publish := {},
publishLocal := {},
publish := {},
publishLocal := {},
publishArtifact := false
)

Expand Down Expand Up @@ -173,7 +173,7 @@ lazy val jacksonJVM = project
.settings(testSettings)
.settings(scalafixSettings)
.settings(
name := "calev-jackson",
name := "calev-jackson",
crossScalaVersions := Seq(scala212, scala213),
developers += Developer(
id = "pawelkaczor",
Expand All @@ -191,7 +191,7 @@ lazy val akkaJVM = project
.settings(sharedSettings)
.settings(scalafixSettings)
.settings(
name := "calev-akka",
name := "calev-akka",
crossScalaVersions := Seq(scala212, scala213),
developers += Developer(
id = "pawelkaczor",
Expand Down Expand Up @@ -233,7 +233,7 @@ val root = project
.settings(sharedSettings)
.settings(noPublish)
.settings(
name := "calev-root",
name := "calev-root",
crossScalaVersions := Nil
)
.aggregate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ trait CalevActorScheduling {

implicit class CalevActorSchedulingDsl(ctx: ActorContext[_]) {

/** Schedule the sending of a message to the given target Actor
* at the time of the upcoming event according to the given
* calendar event definition.
/** Schedule the sending of a message to the given target Actor at the time of the
* upcoming event according to the given calendar event definition.
*
* The scheduled action can be cancelled
* by invoking Cancellable#cancel on the returned
* handle.
* The scheduled action can be cancelled by invoking Cancellable#cancel on the
* returned handle.
*
* This method is thread-safe and can be called from other threads than the ordinary
* actor message processing thread, such as Future callbacks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import com.github.eikek.calev.akka.internal.{CalevInterceptor, CalevTimerSchedul

object CalevBehaviors {

/** Support for scheduled `self` messages in an actor.
* It takes care of the lifecycle of the timers such as cancelling them when the actor
* is restarted or stopped.
/** Support for scheduled `self` messages in an actor. It takes care of the lifecycle of
* the timers such as cancelling them when the actor is restarted or stopped.
*
* @see [[CalevTimerScheduler]]
* @see
* [[CalevTimerScheduler]]
*/
def withCalevTimers[T](
minInterval: Option[FiniteDuration] = None,
Expand All @@ -26,8 +26,8 @@ object CalevBehaviors {
factory(new CalevTimerSchedulerImpl[T](scheduler, clock, minInterval))
}

/** Schedule the sending of a message at a time of the upcoming event
* according to the given calendar event definition.
/** Schedule the sending of a message at a time of the upcoming event according to the
* given calendar event definition.
*/
def withCalendarEvent[I, O <: I: ClassTag](
calEvent: CalEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import com.github.eikek.calev.CalEvent

trait CalevScheduler {

/** Schedules a Runnable to be run at a time of the upcoming
* event according to the given calendar event definition.
/** Schedules a Runnable to be run at a time of the upcoming event according to the
* given calendar event definition.
*
* Throws IllegalArgumentException if the calculated delay exceed the maximum
* reach (calculated as: `delay / tickNanos > Int.MaxValue`).
* Throws IllegalArgumentException if the calculated delay exceed the maximum reach
* (calculated as: `delay / tickNanos > Int.MaxValue`).
*/
def scheduleOnceWithCalendarEvent(calEvent: CalEvent, runnable: Runnable)(implicit
executor: ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@ import com.github.eikek.calev.CalEvent

trait CalevTimerScheduler[T] {

/** Start an Akka Timer that will send a message to the self actor
* when the upcoming event occurs as defined by given calendar event.
/** Start an Akka Timer that will send a message to the self actor when the upcoming
* event occurs as defined by given calendar event.
*
* If a new timer is started with the same message
* the previous is cancelled. It is guaranteed that a message from the
* previous timer is not received, even if it was already enqueued
* in the mailbox when the new timer was started. If you do not want this,
* you can start start them as individual timers by specifying distinct keys.
* If a new timer is started with the same message the previous is cancelled. It is
* guaranteed that a message from the previous timer is not received, even if it was
* already enqueued in the mailbox when the new timer was started. If you do not want
* this, you can start start them as individual timers by specifying distinct keys.
*/
def startSingleTimer(calEvent: CalEvent, msgFactory: ZonedDateTime => T): Unit

/** Start an Akka Timer that will send a message to the self actor
* when the upcoming event occurs as defined by given calendar event.
/** Start an Akka Timer that will send a message to the self actor when the upcoming
* event occurs as defined by given calendar event.
*
* Each timer has a key and if a new timer with same key is started
* the previous is cancelled. It is guaranteed that a message from the
* previous timer is not received, even if it was already enqueued
* in the mailbox when the new timer was started.
* Each timer has a key and if a new timer with same key is started the previous is
* cancelled. It is guaranteed that a message from the previous timer is not received,
* even if it was already enqueued in the mailbox when the new timer was started.
*/
def startSingleTimer[K](
key: K,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object Main {

case Opts(Some(ce), reps, ref, _) =>
println(s"Normalized: ${ce.asString}")
println(s"Reference: ${ref}")
println(s"Reference: $ref")
println("Next Elapses:")
val next = ce.nextElapses(ref, reps)
next.foreach(zd => println(s"- $zd"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,26 @@ import java.time._

import com.github.eikek.calev._

/** Generate the next date-time that matches a calendar event and is
* closest but after a give reference date-time.
/** Generate the next date-time that matches a calendar event and is closest but after a
* give reference date-time.
*
* This is done as follows: The reference date is divided into its
* components, like day, month, year, hour, minute and second. For
* each component, starting from the least significant one, a value
* matching the corresponding calendar event component is chosen. For
* example, if the reference minute is 16 and the minute component is
* 0/10, the closest possible value is 20.
* This is done as follows: The reference date is divided into its components, like day,
* month, year, hour, minute and second. For each component, starting from the least
* significant one, a value matching the corresponding calendar event component is
* chosen. For example, if the reference minute is 16 and the minute component is 0/10,
* the closest possible value is 20.
*
* There are three possible outcomes for each decision (stop after
* first result):
* There are three possible outcomes for each decision (stop after first result):
*
* 1. the current value matches as is
* 2. there is one greater than the current value
* 3. use the first possible value (which is lower than current)
* 1. the current value matches as is 2. there is one greater than the current value 3.
* use the first possible value (which is lower than current)
*
* If the result is 1) go to the next component. If the result is 2)
* the date has moved into the future. Then all previous results must
* be set to the first possible value, in order to get the closest
* date. If the result is 3) the next component may only check for 2)
* and 3). If the result 3) carries through to the year component,
* the year must be set to the next value. If that is not possible,
* there is no date-time and a `None' is returned.
* If the result is 1) go to the next component. If the result is 2) the date has moved
* into the future. Then all previous results must be set to the first possible value, in
* order to get the closest date. If the result is 3) the next component may only check
* for 2) and 3). If the result 3) carries through to the year component, the year must
* be set to the next value. If that is not possible, there is no date-time and a `None'
* is returned.
*/
object DefaultTrigger extends Trigger {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ object Parser {
final case class P[A](run: String => Either[String, (String, A)]) {

def map[B](f: A => B): P[B] =
P(str => run(str).map({ case (rest, a) => (rest, f(a)) }))
P(str => run(str).map { case (rest, a) => (rest, f(a)) })

def emap[B](f: A => Either[String, B]): P[B] =
P(str => run(str).flatMap({ case (rest, a) => f(a).map(b => (rest, b)) }))
P(str => run(str).flatMap { case (rest, a) => f(a).map(b => (rest, b)) })

def opt: P[Option[A]] =
P(str =>
Expand All @@ -186,7 +186,7 @@ object Parser {
P(str =>
run(str) match {
case Right((rest, a)) =>
p.run(rest).map({ case (r, b) => (r, (a, b)) })
p.run(rest).map { case (r, b) => (r, (a, b)) }
case Left(err) =>
Left(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import java.time.ZonedDateTime

import com.github.eikek.calev._

/** Evaluates a calendar event against a reference date to provide the
* next date-time matching the calendar event.
/** Evaluates a calendar event against a reference date to provide the next date-time
* matching the calendar event.
*/
trait Trigger {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import munit._
class CalEventTest extends FunSuite {

implicit val CS: ContextShift[IO] = IO.contextShift(ExecutionContext.global)
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)

test("contains") {
val ce = CalEvent(Mon ~ Tue, DateEvent.All, time(0.c, 10.c ++ 20.c, 0.c))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ComponentTest extends FunSuite {

test("contains") {
assert(!2.c.contains(3))
for (n <- 1 to 59; if n % 2 == 0) {
for (n <- 1 to 59 if n % 2 == 0) {
assert(All.contains(n))
assert(n.c.contains(n))
assert(!n.c.contains(n + 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ValueTest extends FunSuite {

test("contains (ranges)") {
val r0 = Value.Range(1, 12, Some(2))
for (n <- 1 until 12; if n % 2 == 1)
for (n <- 1 until 12 if n % 2 == 1)
assert(r0.contains(n))
assert(!r0.contains(4))
assert(!r0.contains(17))
Expand Down

0 comments on commit 03185b9

Please sign in to comment.