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

chore: Scalafmt upgrade #32187

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
149 changes: 101 additions & 48 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,52 +1,105 @@
version = 2.1.0

style = defaultWithAlign

docstrings = JavaDoc
indentOperator = spray
maxColumn = 120
lineEndings = preserve
rewrite.rules = [RedundantParens, SortImports, AvoidInfix]
unindentTopLevelOperators = true
align.tokens = [{code = "=>", owner = "Case"}]
align.openParenDefnSite = false
align.openParenCallSite = false
optIn.breakChainOnFirstMethodDot = false
optIn.configStyleArguments = false
danglingParentheses = false
version = 3.7.4

runner.dialect = scala213

fileOverride {
"glob:**/scala-3*/**" {
runner.dialect = scala3
}
}

# Only format files tracked by git
project.git = true

# f/k/a style =
preset = defaultWithAlign

# f/k/a JavaDoc
docstrings {
style = Asterisk
oneline = fold
wrap = no
}

indentOperator {
preset = akka

# f/f/k/a unindentTopLevelOperators = true
# f/k/a topLevelOnly=false
exemptScope = all
}

maxColumn = 120
lineEndings = preserve

rewrite {
rules = [
AvoidInfix,
RedundantParens,
Imports
]

neverInfix.excludeFilters = [
and
min
max
until
to
by
eq
ne
"should.*"
"contain.*"
"must.*"
in
ignore
be
taggedAs
thrownBy
synchronized
have
when
size
only
noneOf
oneElementOf
noElementsOf
atLeastOneElementOf
atMostOneElementOf
allElementsOf
inOrderElementsOf
theSameElementsAs
theSameElementsInOrderAs
]

imports {
sort = original
}
}

spaces.inImportCurlyBraces = true
rewrite.neverInfix.excludeFilters = [
and
min
max
until
to
by
eq
ne
"should.*"
"contain.*"
"must.*"
in
ignore
be
taggedAs
thrownBy
synchronized
have
when
size
only
noneOf
oneElementOf
noElementsOf
atLeastOneElementOf
atMostOneElementOf
allElementsOf
inOrderElementsOf
theSameElementsAs
theSameElementsInOrderAs
]

align {
tokens = [
{ code = "=>", owner = "Case" }
]
openParenCallSite = false
openParenDefnSite = false
}

optIn {
breakChainOnFirstMethodDot = false
encloseClassicChains = true
configStyleArguments = false
}

danglingParentheses {
defnSite = false
callSite = false
ctrlSite = false
tupleSite = false
}

rewriteTokens = {
"⇒": "=>"
"→": "->"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import akka.util.OptionVal
*/
final case class CapturedLogEvent(level: Level, message: String, cause: Option[Throwable], marker: Option[Marker]) {

/**
* Constructor for Java API
*/
/** Constructor for Java API */
def this(
level: Level,
message: String,
Expand All @@ -32,27 +30,19 @@ final case class CapturedLogEvent(level: Level, message: String, cause: Option[T
mdc: java.util.Map[String, Any]) =
this(level, message, errorCause.asScala, marker.asScala)

/**
* Constructor for Java API
*/
/** Constructor for Java API */
def this(level: Level, message: String) =
this(level, message, Option.empty, Option.empty)

/**
* Constructor for Java API
*/
/** Constructor for Java API */
def this(level: Level, message: String, errorCause: Throwable) =
this(level, message, Some(errorCause), Option.empty[Marker])

/**
* Constructor for Java API
*/
/** Constructor for Java API */
def this(level: Level, message: String, marker: Marker) =
this(level, message, Option.empty[Throwable], Some(marker))

/**
* Constructor for Java API
*/
/** Constructor for Java API */
def this(level: Level, message: String, errorCause: Throwable, marker: Marker) =
this(level, message, Some(errorCause), Some(marker))

Expand All @@ -63,9 +53,7 @@ final case class CapturedLogEvent(level: Level, message: String, cause: Option[T

object CapturedLogEvent {

/**
* Helper method to convert [[OptionVal]] to [[Option]]
*/
/** Helper method to convert [[OptionVal]] to [[Option]] */
private def toOption[A](optionVal: OptionVal[A]): Option[A] = optionVal match {
case OptionVal.Some(x) => Some(x)
case _ => None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ object Effect {
def adaptTimeout(msg: String): T = mapResponse(timeoutTry(msg))
def adaptTimeout: T = adaptTimeout(timeoutMsg)

/**
* Java API
*/
/** Java API */
def getResponseTimeout: java.time.Duration = responseTimeout.asJava

private var sentResponse: Boolean = false
Expand All @@ -82,9 +80,7 @@ object Effect {
}
}

/**
* The behavior spawned a named child with the given behavior (and optionally specific props)
*/
/** The behavior spawned a named child with the given behavior (and optionally specific props) */
final class Spawned[T](val behavior: Behavior[T], val childName: String, val props: Props, val ref: ActorRef[T])
extends Effect
with Product3[Behavior[T], String, Props]
Expand Down Expand Up @@ -113,9 +109,7 @@ object Effect {
def unapply[T](s: Spawned[T]): Option[(Behavior[T], String, Props)] = Some((s.behavior, s.childName, s.props))
}

/**
* The behavior spawned an anonymous child with the given behavior (and optionally specific props)
*/
/** The behavior spawned an anonymous child with the given behavior (and optionally specific props) */
final class SpawnedAnonymous[T](val behavior: Behavior[T], val props: Props, val ref: ActorRef[T])
extends Effect
with Product2[Behavior[T], Props]
Expand Down Expand Up @@ -196,54 +190,36 @@ object Effect {
override def canEqual(o: Any): Boolean = o.isInstanceOf[SpawnedAnonymousAdapter[_]]
}

/**
* INTERNAL API
*/
/** INTERNAL API */
@InternalApi
private[akka] object SpawnedAnonymousAdapter {
def apply[T]() = new SpawnedAnonymousAdapter[T](null)
def unapply[T](@unused s: SpawnedAnonymousAdapter[T]): Boolean = true
}

/**
* The behavior create a message adapter for the messages of type clazz
*/
/** The behavior create a message adapter for the messages of type clazz */
final case class MessageAdapter[A, T](messageClass: Class[A], adapt: A => T) extends Effect {

/**
* JAVA API
*/
/** JAVA API */
def adaptFunction: java.util.function.Function[A, T] = adapt.asJava
}

/**
* The behavior stopped `childName`
*/
/** The behavior stopped `childName` */
final case class Stopped(childName: String) extends Effect

/**
* The behavior started watching `other`, through `context.watch(other)`
*/
/** The behavior started watching `other`, through `context.watch(other)` */
final case class Watched[T](other: ActorRef[T]) extends Effect

/**
* The behavior started watching `other`, through `context.watchWith(other, message)`
*/
/** The behavior started watching `other`, through `context.watchWith(other, message)` */
final case class WatchedWith[U, T](other: ActorRef[U], message: T) extends Effect

/**
* The behavior stopped watching `other`, through `context.unwatch(other)`
*/
/** The behavior stopped watching `other`, through `context.unwatch(other)` */
final case class Unwatched[T](other: ActorRef[T]) extends Effect

/**
* The behavior set a new receive timeout, with `message` as timeout notification
*/
/** The behavior set a new receive timeout, with `message` as timeout notification */
final case class ReceiveTimeoutSet[T](d: FiniteDuration, message: T) extends Effect {

/**
* Java API
*/
/** Java API */
def duration(): java.time.Duration = d.asJava
}

Expand Down Expand Up @@ -292,13 +268,9 @@ object Effect {

final case class TimerCancelled(key: Any) extends Effect

/**
* Used to represent an empty list of effects - in other words, the behavior didn't do anything observable
*/
/** Used to represent an empty list of effects - in other words, the behavior didn't do anything observable */
case object NoEffects extends NoEffects

/**
* Used for NoEffects expectations by type
*/
/** Used for NoEffects expectations by type */
sealed abstract class NoEffects extends Effect
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@ import akka.util.ccompat.JavaConverters._

object LoggingEvent {

/**
* Scala API
*/
/** Scala API */
def apply(level: Level, loggerName: String, threadName: String, message: String, timeStamp: Long): LoggingEvent =
new LoggingEvent(level, loggerName, threadName, message, timeStamp, None, None, Map.empty)

/**
* Java API
*/
/** Java API */
def create(level: Level, loggerName: String, threadName: String, message: String, timeStamp: Long): LoggingEvent =
apply(level, loggerName, threadName, message, timeStamp)

/**
* Java API
*/
/** Java API */
def create(
level: Level,
loggerName: String,
Expand All @@ -56,21 +50,15 @@ final case class LoggingEvent(
throwable: Option[Throwable],
mdc: Map[String, String]) {

/**
* Java API
*/
/** Java API */
def getMarker: Optional[Marker] =
marker.asJava

/**
* Java API
*/
/** Java API */
def getThrowable: Optional[Throwable] =
throwable.asJava

/**
* Java API
*/
/** Java API */
def getMdc: java.util.Map[String, String] = {
import akka.util.ccompat.JavaConverters._
mdc.asJava
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ package akka.actor.testkit.typed

import scala.util.control.NoStackTrace

/**
* A predefined exception that can be used in tests. It doesn't include a stack trace.
*/
/** A predefined exception that can be used in tests. It doesn't include a stack trace. */
final case class TestException(message: String) extends RuntimeException(message) with NoStackTrace