scalafix: ProcedureSyntax

cli
Thibault Duplessis 2017-10-21 15:06:14 -05:00
parent 8c79c860cb
commit dd1cb47ceb
57 changed files with 147 additions and 147 deletions

View File

@ -17,12 +17,12 @@ object Global extends GlobalSettings {
}
}
override def onStart(app: Application) {
override def onStart(app: Application): Unit = {
kamon.Kamon.start()
lila.app.Env.current
}
override def onStop(app: Application) {
override def onStop(app: Application): Unit = {
kamon.Kamon.shutdown()
}

View File

@ -8,7 +8,7 @@ import lila.hub.actorApi.{ DeployPre, DeployPost }
private final class InfluxEvent(endpoint: String, env: String) extends Actor {
override def preStart() {
override def preStart(): Unit = {
context.system.lilaBus.subscribe(self, 'deploy)
event("lila_start", "Lila starts")
}

View File

@ -13,7 +13,7 @@ private final class KamonPusher(
import KamonPusher._
override def preStart() {
override def preStart(): Unit = {
scheduleTick
}

View File

@ -16,7 +16,7 @@ class JsonStringifyPerfTest extends Specification {
def stringify = Json stringify jsonObj
def runOne = stringify
def run { for (i 1 to nb) runOne }
def run: Unit = { for (i 1 to nb) runOne }
"stringify a hook" should {
"many times" in {

View File

@ -10,7 +10,7 @@ final class Bus private (system: ActorSystem) extends Extension with EventBus {
type Classifier = Symbol
type Subscriber = ActorRef
def publish(payload: Any, channel: Classifier) {
def publish(payload: Any, channel: Classifier): Unit = {
publish(Bus.Event(payload, channel))
}
@ -40,7 +40,7 @@ final class Bus private (system: ActorSystem) extends Extension with EventBus {
/**
* Attempts to deregister the subscriber from all Classifiers it may be subscribed to
*/
def unsubscribe(subscriber: Subscriber) {
def unsubscribe(subscriber: Subscriber): Unit = {
// log(s"[UN]subscribe ALL $subscriber")
bus unsubscribe subscriber
}
@ -48,7 +48,7 @@ final class Bus private (system: ActorSystem) extends Extension with EventBus {
/**
* Publishes the specified Event to this bus
*/
def publish(event: Event) {
def publish(event: Event): Unit = {
// log(event.toString)
bus publish event
}

View File

@ -31,7 +31,7 @@ object PimpedFuture {
def injectAnyway[B](b: => B): Fu[B] = fold(_ => b, _ => b)
def effectFold(fail: Exception => Unit, succ: A => Unit) {
def effectFold(fail: Exception => Unit, succ: A => Unit): Unit = {
fua onComplete {
case scala.util.Failure(e: Exception) => fail(e)
case scala.util.Failure(e) => throw e // Throwables

View File

@ -13,11 +13,11 @@ object ResilientScheduler {
atMost: FiniteDuration,
system: ActorSystem,
logger: lila.log.Logger
)(f: => Funit) {
)(f: => Funit): Unit = {
system.actorOf(Props(new Actor {
override def preStart {
override def preStart: Unit = {
context setReceiveTimeout (atMost + 2.second)
scheduleNext
}

View File

@ -7,7 +7,7 @@ import ornicar.scalalib.Random.{ approximatly, nextString }
final class Scheduler(scheduler: akka.actor.Scheduler, enabled: Boolean, debug: Boolean) {
def throttle[A](delay: FiniteDuration)(batch: Seq[A])(op: A => Unit) {
def throttle[A](delay: FiniteDuration)(batch: Seq[A])(op: A => Unit): Unit = {
batch.zipWithIndex foreach {
case (a, i) => try {
scheduler.scheduleOnce((1 + i) * delay) { op(a) }
@ -18,21 +18,21 @@ final class Scheduler(scheduler: akka.actor.Scheduler, enabled: Boolean, debug:
}
}
def message(freq: FiniteDuration)(to: => (ActorRef, Any)) {
def message(freq: FiniteDuration)(to: => (ActorRef, Any)): Unit = {
enabled ! scheduler.schedule(freq, randomize(freq), to._1, to._2)
}
def messageToSelection(freq: FiniteDuration)(to: => (ActorSelection, Any)) {
def messageToSelection(freq: FiniteDuration)(to: => (ActorSelection, Any)): Unit = {
enabled ! scheduler.schedule(freq, randomize(freq)) {
to._1 ! to._2
}
}
def effect(freq: FiniteDuration, name: String)(op: => Unit) {
def effect(freq: FiniteDuration, name: String)(op: => Unit): Unit = {
enabled ! future(freq, name)(fuccess(op))
}
def future(freq: FiniteDuration, name: String)(op: => Funit) {
def future(freq: FiniteDuration, name: String)(op: => Funit): Unit = {
enabled ! {
val f = randomize(freq)
val doDebug = debug && freq > 5.seconds
@ -49,7 +49,7 @@ final class Scheduler(scheduler: akka.actor.Scheduler, enabled: Boolean, debug:
}
}
def once(delay: FiniteDuration)(op: => Unit) {
def once(delay: FiniteDuration)(op: => Unit): Unit = {
enabled ! scheduler.scheduleOnce(delay)(op)
}

View File

@ -30,7 +30,7 @@ final class PimpedFuture[A](private val fua: Fu[A]) extends AnyVal {
def injectAnyway[B](b: => B): Fu[B] = fold(_ => b, _ => b)
def effectFold(fail: Exception => Unit, succ: A => Unit) {
def effectFold(fail: Exception => Unit, succ: A => Unit): Unit = {
fua onComplete {
case scala.util.Failure(e: Exception) => fail(e)
case scala.util.Failure(e) => throw e // Throwables

View File

@ -86,7 +86,7 @@ private final class ExplorerIndexer(
private object flowBuffer {
private val max = 30
private val buf = scala.collection.mutable.ArrayBuffer.empty[String]
def apply(pgn: String) {
def apply(pgn: String): Unit = {
buf += pgn
val startAt = nowMillis
if (buf.size >= max) {

View File

@ -45,7 +45,7 @@ private final class Captcher extends Actor {
private val capacity = 512
private var challenges: NonEmptyList[Captcha] = NonEmptyList(Captcha.default)
private def add(c: Captcha) {
private def add(c: Captcha): Unit = {
find(c.gameId) ifNone {
challenges = NonEmptyList.nel(c, challenges.list take capacity)
}

View File

@ -23,7 +23,7 @@ private[game] object GameDiff {
val setBuilder = scala.collection.mutable.ListBuffer[Set]()
val unsetBuilder = scala.collection.mutable.ListBuffer[Unset]()
def d[A, B <: BSONValue](name: String, getter: Game => A, toBson: A => B) {
def d[A, B <: BSONValue](name: String, getter: Game => A, toBson: A => B): Unit = {
val (va, vb) = (getter(a), getter(b))
if (va != vb) {
if (vb == None || vb == null || vb == "") unsetBuilder += (name -> bTrue)
@ -31,7 +31,7 @@ private[game] object GameDiff {
}
}
def dOpt[A, B <: BSONValue](name: String, getter: Game => A, toBson: A => Option[B]) {
def dOpt[A, B <: BSONValue](name: String, getter: Game => A, toBson: A => Option[B]): Unit = {
val (va, vb) = (getter(a), getter(b))
if (va != vb) {
if (vb == None || vb == null || vb == "") unsetBuilder += (name -> bTrue)

View File

@ -198,10 +198,10 @@ object GameRepo {
.cursor[Game]()
.gather[List](nb)
def setAnalysed(id: ID) {
def setAnalysed(id: ID): Unit = {
coll.updateFieldUnchecked($id(id), F.analysed, true)
}
def setUnanalysed(id: ID) {
def setUnanalysed(id: ID): Unit = {
coll.updateFieldUnchecked($id(id), F.analysed, false)
}

View File

@ -31,8 +31,8 @@ class BinaryPerfTest extends Specification {
type Run = () => Unit
def readDataset() { encodedDataset foreach format.read }
def writeDataset() { dataset foreach format.write }
def readDataset(): Unit = { encodedDataset foreach format.read }
def writeDataset(): Unit = { dataset foreach format.write }
def runTests(run: Run, name: String, iterations: Int) = {
println(s"$name warming up")

View File

@ -65,7 +65,7 @@ object FutureSequencer {
private case object Done
private def processThenDone(work: Any) {
private def processThenDone(work: Any): Unit = {
work match {
case ReceiveTimeout => self ! PoisonPill
case FSequencer.Work(run, promise, timeoutOption) =>

View File

@ -38,7 +38,7 @@ final class Sequencer(
private case object Done
private def processThenDone(work: Any) {
private def processThenDone(work: Any): Unit = {
work match {
case ReceiveTimeout => self ! PoisonPill
case Sequencer.Work(run, promiseOption, timeoutOption) =>

View File

@ -34,7 +34,7 @@ trait SequentialActor extends Actor {
def receive = idle
def onFailure(e: Exception) {}
def onFailure(e: Exception): Unit = {}
private val queue = collection.mutable.Queue[Any]()
private def dequeue: Option[Any] = Try(queue.dequeue).toOption
@ -45,7 +45,7 @@ trait SequentialActor extends Actor {
case _ => funit
}
private def processThenDone(work: Any) {
private def processThenDone(work: Any): Unit = {
work match {
// we don't want to send Done after actor death
case SequentialActor.Terminate => self ! PoisonPill

View File

@ -49,7 +49,7 @@ trait SequentialProvider extends Actor {
private val queue = collection.mutable.Queue[Envelope]()
private def dequeue: Option[Any] = Try(queue.dequeue).toOption
private def debugQueue {
private def debugQueue: Unit = {
if (debug) queue.size match {
case size if (size == 50 || (size >= 100 && size % 100 == 0)) =>
logger.branch("SequentialProvider").warn(s"Seq[$name] queue = $size")
@ -63,7 +63,7 @@ trait SequentialProvider extends Actor {
case _ => fuccess(Status.Failure)
}
private def processThenDone(signal: Any) {
private def processThenDone(signal: Any): Unit = {
signal match {
// we don't want to send Done after actor death
case SequentialProvider.Terminate => self ! PoisonPill

View File

@ -8,7 +8,7 @@ final class TimeBomb(delayDuration: Duration) {
private var delayedAt: Double = nowMillis
def delay {
def delay: Unit = {
delayedAt = nowMillis
}

View File

@ -30,11 +30,11 @@ object HookRepo {
def notInUids(uids: Set[String]): Vector[Hook] = hooks.filterNot(h => uids(h.uid))
def save(hook: Hook) {
def save(hook: Hook): Unit = {
hooks = hooks.filterNot(_.id == hook.id) :+ hook
}
def remove(hook: Hook) {
def remove(hook: Hook): Unit = {
hooks = hooks.filterNot(_.id == hook.id)
}

View File

@ -131,7 +131,7 @@ private[lobby] final class Lobby(
HookRepo byIds ids.toSet foreach remove
}
private def NoPlayban(user: Option[LobbyUser])(f: => Unit) {
private def NoPlayban(user: Option[LobbyUser])(f: => Unit): Unit = {
user.?? { u => playban(u.id) } foreach {
case None => f
case _ =>

View File

@ -22,14 +22,14 @@ private[lobby] final class Socket(
case object Cleanup
override def preStart() {
override def preStart(): Unit = {
super.preStart()
context.system.lilaBus.subscribe(self, 'changeFeaturedGame, 'streams, 'nbMembers, 'nbRounds, 'poolGame)
context.system.scheduler.scheduleOnce(3 seconds, self, SendHookRemovals)
context.system.scheduler.schedule(1 minute, 1 minute, self, Cleanup)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
context.system.lilaBus.unsubscribe(self)
}
@ -165,11 +165,11 @@ private[lobby] final class Socket(
case (uid, member) => if (!idleUids(uid)) member push msg
}
def withActiveMember(uid: String)(f: Member => Unit) {
def withActiveMember(uid: String)(f: Member => Unit): Unit = {
if (!idleUids(uid)) members get uid foreach f
}
override def quit(uid: String) {
override def quit(uid: String): Unit = {
super.quit(uid)
idleUids -= uid
hookSubscriberUids -= uid

View File

@ -67,7 +67,7 @@ private[puzzle] final class Finisher(
def incPuzzleAttempts(puzzle: Puzzle) =
puzzleColl.incFieldUnchecked($id(puzzle.id), Puzzle.BSONFields.attempts)
private def updateRatings(u1: Rating, u2: Rating, result: Glicko.Result) {
private def updateRatings(u1: Rating, u2: Rating, result: Glicko.Result): Unit = {
val results = new RatingPeriodResults()
result match {
case Glicko.Result.Draw => results.addDraw(u1, u2)

View File

@ -12,12 +12,12 @@ private[qa] final class Notifier(
timeline: ActorSelection
) {
private[qa] def createQuestion(q: Question, u: User) {
private[qa] def createQuestion(q: Question, u: User): Unit = {
val msg = Propagate(QaQuestion(u.id, q.id, q.title))
timeline ! (msg toFollowersOf u.id)
}
private[qa] def createAnswer(q: Question, a: Answer, u: User) {
private[qa] def createAnswer(q: Question, a: Answer, u: User): Unit = {
val msg = Propagate(QaAnswer(u.id, q.id, q.title, a.id))
timeline ! (msg toFollowersOf u.id toUser q.userId exceptUser u.id)
if (u.id != q.userId) notifyAsker(q, a)
@ -37,12 +37,12 @@ private[qa] final class Notifier(
notifyApi.addNotification(notification)
}
private[qa] def createQuestionComment(q: Question, c: Comment, u: User) {
private[qa] def createQuestionComment(q: Question, c: Comment, u: User): Unit = {
val msg = Propagate(QaComment(u.id, q.id, q.title, c.id))
timeline ! (msg toFollowersOf u.id toUser q.userId exceptUser u.id)
}
private[qa] def createAnswerComment(q: Question, a: Answer, c: Comment, u: User) {
private[qa] def createAnswerComment(q: Question, a: Answer, c: Comment, u: User): Unit = {
val msg = Propagate(QaComment(u.id, q.id, q.title, c.id))
timeline ! (msg toFollowersOf u.id toUser a.userId exceptUser u.id)
}

View File

@ -172,7 +172,7 @@ final class RelationApi(
def searchFollowedBy(u: User, term: String, max: Int): Fu[List[User.ID]] =
RelationRepo.followingLike(u.id, term) map { _.sorted take max }
private def reloadOnlineFriends(u1: ID, u2: ID) {
private def reloadOnlineFriends(u1: ID, u2: ID): Unit = {
import lila.hub.actorApi.relation.ReloadOnlineFriends
List(u1, u2).foreach(actor ! ReloadOnlineFriends(_))
}

View File

@ -17,7 +17,7 @@ private final class RelayFetch(
val frequency = 1.seconds
override def preStart {
override def preStart: Unit = {
logger.info("Start RelaySync")
context setReceiveTimeout 20.seconds
context.system.scheduler.scheduleOnce(10.seconds)(scheduleNext)

View File

@ -29,7 +29,7 @@ private final class CorresAlarm(
private implicit val AlarmHandler = reactivemongo.bson.Macros.handler[Alarm]
override def preStart() {
override def preStart(): Unit = {
scheduleNext
context setReceiveTimeout 1.minute
}

View File

@ -230,12 +230,12 @@ final class Env(
val tvBroadcast = system.actorOf(Props(classOf[TvBroadcast]))
bus.subscribe(tvBroadcast, 'moveEvent, 'changeFeaturedGame)
def checkOutoftime(game: Game) {
def checkOutoftime(game: Game): Unit = {
if (game.playable && game.started && !game.isUnlimited)
roundMap ! Tell(game.id, actorApi.round.QuietFlag)
}
def resign(pov: Pov) {
def resign(pov: Pov): Unit = {
if (pov.game.abortable)
roundMap ! Tell(pov.game.id, actorApi.round.Abort(pov.playerId))
else if (pov.game.playable)

View File

@ -48,7 +48,7 @@ private[round] final class History(
vevs.reverse
}
private def waitForLoadedEvents {
private def waitForLoadedEvents: Unit = {
if (events == null) {
events = load awaitSeconds 3
}
@ -56,7 +56,7 @@ private[round] final class History(
private var persistenceEnabled = withPersistence
def enablePersistence {
def enablePersistence: Unit = {
if (!persistenceEnabled) {
persistenceEnabled = true
if (events != null) persist(events)

View File

@ -11,13 +11,13 @@ import lila.i18n.{ I18nKeys, enLang }
final class Messenger(val chat: ActorSelection) {
def system(game: Game, message: SelectI18nKey, args: Any*) {
def system(game: Game, message: SelectI18nKey, args: Any*): Unit = {
val translated = message(I18nKeys).literalTxtTo(enLang, args)
chat ! SystemTalk(Chat.Id(watcherId(game.id)), translated)
if (game.nonAi) chat ! SystemTalk(Chat.Id(game.id), translated)
}
def systemForOwners(gameId: Game.ID, message: SelectI18nKey, args: Any*) {
def systemForOwners(gameId: Game.ID, message: SelectI18nKey, args: Any*): Unit = {
val translated = message(I18nKeys).literalTxtTo(enLang, args)
chat ! SystemTalk(Chat.Id(gameId), translated)
}

View File

@ -111,7 +111,7 @@ final class PerfsUpdater(
case None => Glicko.Result.Draw
}
private def updateRatings(white: Rating, black: Rating, result: Glicko.Result, system: RatingCalculator) {
private def updateRatings(white: Rating, black: Rating, result: Glicko.Result, system: RatingCalculator): Unit = {
val results = new RatingPeriodResults()
result match {
case Glicko.Result.Draw => results.addDraw(white, black)

View File

@ -31,11 +31,11 @@ private[round] final class Round(
context setReceiveTimeout activeTtl
override def preStart() {
override def preStart(): Unit = {
context.system.lilaBus.subscribe(self, 'deploy)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
context.system.lilaBus.unsubscribe(self)
}

View File

@ -54,12 +54,12 @@ private[round] final class Socket(
var userId = none[String]
def ping {
def ping: Unit = {
isGone foreach { _ ?? notifyGone(color, false) }
if (bye > 0) bye = bye - 1
time = nowMillis
}
def setBye {
def setBye: Unit = {
bye = 3
}
private def isBye = bye > 0
@ -77,13 +77,13 @@ private[round] final class Socket(
private val whitePlayer = new Player(White)
private val blackPlayer = new Player(Black)
override def preStart() {
override def preStart(): Unit = {
super.preStart()
buscriptions.all
GameRepo game gameId map SetGame.apply pipeTo self
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
lilaBus.unsubscribe(self)
}
@ -233,14 +233,14 @@ private[round] final class Socket(
}
}
def notifyCrowd {
def notifyCrowd: Unit = {
if (!delayedCrowdNotification) {
delayedCrowdNotification = true
context.system.scheduler.scheduleOnce(1 second, self, NotifyCrowd)
}
}
def notify(events: Events) {
def notify(events: Events): Unit = {
val vevents = history addEvents events
members.foreachValue { m => batch(m, vevents) }
}
@ -256,7 +256,7 @@ private[round] final class Socket(
_ push makeMessage(t, data)
}
def notifyGone(color: Color, gone: Boolean) {
def notifyGone(color: Color, gone: Boolean): Unit = {
notifyOwner(!color, "gone", gone)
}
@ -285,7 +285,7 @@ private[round] final class Socket(
private def playerGet[A](color: Color, getter: Player => A): A =
getter(color.fold(whitePlayer, blackPlayer))
private def playerDo(color: Color, effect: Player => Unit) {
private def playerDo(color: Color, effect: Player => Unit): Unit = {
effect(color.fold(whitePlayer, blackPlayer))
}
}

View File

@ -41,7 +41,7 @@ private[round] final class SocketHandler(
me: Option[User]
): Handler.Controller = {
def send(msg: Any) { roundMap ! Tell(gameId, msg) }
def send(msg: Any): Unit = { roundMap ! Tell(gameId, msg) }
member.playerIdOption.fold[Handler.Controller](({
case ("p", o) => socket ! Ping(uid, o)

View File

@ -24,7 +24,7 @@ private[round] final class Titivate(
object Schedule
object Run
override def preStart() {
override def preStart(): Unit = {
scheduleNext
context setReceiveTimeout 30.seconds
}

View File

@ -18,7 +18,7 @@ class StepBuilderPerfTest extends Specification {
def runOne(moves: Vector[String]) =
StepBuilder("abcd1234", moves, chess.variant.Standard, format.Forsyth.initial)
def run() { gameMoves foreach runOne }
def run(): Unit = { gameMoves foreach runOne }
def runTests() = {
runOne(gameMoves.head)

View File

@ -12,7 +12,7 @@ final class DisposableEmailDomain(
private var matchers = List.empty[Matcher]
private[security] def refresh {
private[security] def refresh: Unit = {
WS.url(providerUrl).get() map { res =>
setDomains(textToDomains(res.body))
lila.mon.email.disposableDomain(matchers.size)
@ -38,7 +38,7 @@ final class DisposableEmailDomain(
private var failed = false
private def onError(e: Exception) {
private def onError(e: Exception): Unit = {
logger.error("Can't update disposable emails", e)
if (!failed) {
failed = true

View File

@ -20,7 +20,7 @@ final class Flood(duration: Duration) {
.expireAfterAccess(duration)
.build[String, Messages]
def filterMessage[A](uid: String, text: String)(op: => Unit) {
def filterMessage[A](uid: String, text: String)(op: => Unit): Unit = {
if (allowMessage(uid, text)) op
}

View File

@ -9,7 +9,7 @@ final class Tor(providerUrl: String) {
private var ips = Set.empty[IpAddress]
private[security] def refresh(withIps: Iterable[IpAddress] => Funit) {
private[security] def refresh(withIps: Iterable[IpAddress] => Funit): Unit = {
WS.url(providerUrl).get() map { res =>
ips = res.body.lines.filterNot(_ startsWith "#").map(IpAddress.apply).toSet
withIps(ips)

View File

@ -57,7 +57,7 @@ final class SimulApi(
} inject simul
}
def addApplicant(simulId: Simul.ID, user: User, variantKey: String) {
def addApplicant(simulId: Simul.ID, user: User, variantKey: String): Unit = {
WithSimul(repo.findCreated, simulId) { simul =>
if (simul.nbAccepted >= Game.maxPlayingRealtime) simul
else {
@ -79,11 +79,11 @@ final class SimulApi(
}
}
def removeApplicant(simulId: Simul.ID, user: User) {
def removeApplicant(simulId: Simul.ID, user: User): Unit = {
WithSimul(repo.findCreated, simulId) { _ removeApplicant user.id }
}
def accept(simulId: Simul.ID, userId: String, v: Boolean) {
def accept(simulId: Simul.ID, userId: String, v: Boolean): Unit = {
UserRepo byId userId foreach {
_ foreach { user =>
WithSimul(repo.findCreated, simulId) { _.accept(user.id, v) }
@ -91,7 +91,7 @@ final class SimulApi(
}
}
def start(simulId: Simul.ID) {
def start(simulId: Simul.ID): Unit = {
Sequence(simulId) {
repo.findCreated(simulId) flatMap {
_ ?? { simul =>
@ -115,14 +115,14 @@ final class SimulApi(
}
}
def onPlayerConnection(game: Game, user: Option[User])(simul: Simul) {
def onPlayerConnection(game: Game, user: Option[User])(simul: Simul): Unit = {
user.filter(_.id == simul.hostId) ifTrue simul.isRunning foreach { host =>
repo.setHostGameId(simul, game.id)
sendTo(simul.id, actorApi.HostIsOn(game.id))
}
}
def abort(simulId: Simul.ID) {
def abort(simulId: Simul.ID): Unit = {
Sequence(simulId) {
repo.findCreated(simulId) flatMap {
_ ?? { simul =>
@ -132,7 +132,7 @@ final class SimulApi(
}
}
def finishGame(game: Game) {
def finishGame(game: Game): Unit = {
game.simulId foreach { simulId =>
Sequence(simulId) {
repo.findStarted(simulId) flatMap {
@ -161,7 +161,7 @@ final class SimulApi(
)
}
def ejectCheater(userId: String) {
def ejectCheater(userId: String): Unit = {
repo.allNotFinished foreach {
_ foreach { oldSimul =>
Sequence(oldSimul.id) {
@ -214,7 +214,7 @@ final class SimulApi(
private def WithSimul(
finding: Simul.ID => Fu[Option[Simul]],
simulId: Simul.ID
)(updating: Simul => Simul) {
)(updating: Simul => Simul): Unit = {
Sequence(simulId) {
finding(simulId) flatMap {
_ ?? { simul => update(updating(simul)) }
@ -222,7 +222,7 @@ final class SimulApi(
}
}
private def Sequence(simulId: Simul.ID)(work: => Funit) {
private def Sequence(simulId: Simul.ID)(work: => Funit): Unit = {
sequencers ! Tell(simulId, lila.hub.Sequencer work work)
}
@ -237,14 +237,14 @@ final class SimulApi(
} pipeToSelection lobby
}
})))
def apply() { debouncer ! Debouncer.Nothing }
def apply(): Unit = { debouncer ! Debouncer.Nothing }
}
private def sendTo(simulId: Simul.ID, msg: Any) {
private def sendTo(simulId: Simul.ID, msg: Any): Unit = {
socketHub ! Tell(simulId, msg)
}
private def socketReload(simulId: Simul.ID) {
private def socketReload(simulId: Simul.ID): Unit = {
sendTo(simulId, actorApi.Reload)
}
}

View File

@ -12,7 +12,7 @@ private[simul] final class SimulCleaner(
socketHub: ActorRef
) {
def apply {
def apply: Unit = {
repo.allCreated foreach { simuls =>
simuls.map { simul =>
socketHub ? Ask(simul.id, Socket.GetUserIds) mapTo

View File

@ -20,12 +20,12 @@ private[simul] final class Socket(
socketTimeout: Duration
) extends SocketActor[Member](uidTimeout) with Historical[Member, Messadata] {
override def preStart() {
override def preStart(): Unit = {
super.preStart()
lilaBus.subscribe(self, Symbol(s"chat-$simulId"))
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
lilaBus.unsubscribe(self)
}
@ -34,7 +34,7 @@ private[simul] final class Socket(
private var delayedCrowdNotification = false
private def redirectPlayer(game: lila.game.Game, colorOption: Option[chess.Color]) {
private def redirectPlayer(game: lila.game.Game, colorOption: Option[chess.Color]): Unit = {
colorOption foreach { color =>
val player = game player color
player.userId foreach { userId =>
@ -100,7 +100,7 @@ private[simul] final class Socket(
send = (t, d, trollish) => notifyVersion(t, d, Messadata(trollish))
)
def notifyCrowd {
def notifyCrowd: Unit = {
if (!delayedCrowdNotification) {
delayedCrowdNotification = true
context.system.scheduler.scheduleOnce(500 millis, self, NotifyCrowd)

View File

@ -36,13 +36,13 @@ private[site] final class Socket(timeout: Duration) extends SocketActor[Member](
}
// don't eject non-pinging API socket clients
override def broom {
override def broom: Unit = {
members foreach {
case (uid, member) => if (!aliveUids.get(uid) && !member.isApi) eject(uid)
}
}
override def quit(uid: String) {
override def quit(uid: String): Unit = {
members get uid foreach { flags.remove(uid, _) }
super.quit(uid)
}

View File

@ -6,11 +6,11 @@ import play.api.libs.json.JsValue
final class Channel extends Actor {
override def preStart() {
override def preStart(): Unit = {
context.system.lilaBus.subscribe(self, 'socketDoor)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
context.system.lilaBus.unsubscribe(self)
}

View File

@ -8,11 +8,11 @@ import lila.hub.actorApi.round.MoveEvent
private final class MoveBroadcast extends Actor {
override def preStart() {
override def preStart(): Unit = {
context.system.lilaBus.subscribe(self, 'moveEvent, 'socketDoor)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
context.system.lilaBus.unsubscribe(self)
}

View File

@ -9,11 +9,11 @@ private[socket] final class Population extends Actor {
var nb = 0
val bus = context.system.lilaBus
override def preStart() {
override def preStart(): Unit = {
bus.subscribe(self, 'socketDoor)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
bus.unsubscribe(self)
}

View File

@ -25,7 +25,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
// to ensure the listener is ready (sucks, I know)
val startsOnApplicationBoot: Boolean = false
override def preStart {
override def preStart: Unit = {
if (startsOnApplicationBoot)
context.system.scheduler.scheduleOnce(1 second) {
lilaBus.publish(lila.socket.SocketHub.Open(self), 'socket)
@ -33,7 +33,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
else lilaBus.publish(lila.socket.SocketHub.Open(self), 'socket)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
lilaBus.publish(lila.socket.SocketHub.Close(self), 'socket)
members foreachKey eject
@ -75,15 +75,15 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
if (condition(member)) member push msg
}
def notifyMember[A: Writes](t: String, data: A)(member: M) {
def notifyMember[A: Writes](t: String, data: A)(member: M): Unit = {
member push makeMessage(t, data)
}
def notifyUid[A: Writes](t: String, data: A)(uid: Socket.Uid) {
def notifyUid[A: Writes](t: String, data: A)(uid: Socket.Uid): Unit = {
withMember(uid.value)(_ push makeMessage(t, data))
}
def ping(uid: String, lagCentis: Option[Centis]) {
def ping(uid: String, lagCentis: Option[Centis]): Unit = {
setAlive(uid)
withMember(uid) { member =>
member push pong
@ -94,55 +94,55 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
}
}
def broom {
def broom: Unit = {
members.keys foreach { uid =>
if (!aliveUids.get(uid)) eject(uid)
}
}
def eject(uid: String) {
def eject(uid: String): Unit = {
withMember(uid) { member =>
member.end
quit(uid)
}
}
def quit(uid: String) {
def quit(uid: String): Unit = {
members get uid foreach { member =>
members -= uid
lilaBus.publish(SocketLeave(uid, member), 'socketDoor)
}
}
def onDeploy(d: Deploy) {
def onDeploy(d: Deploy): Unit = {
notifyAll(makeMessage(d.key))
}
private val resyncMessage = makeMessage("resync")
protected def resync(member: M) {
protected def resync(member: M): Unit = {
import scala.concurrent.duration._
context.system.scheduler.scheduleOnce((Random nextInt 2000).milliseconds) {
resyncNow(member)
}
}
protected def resync(uid: String) {
protected def resync(uid: String): Unit = {
withMember(uid)(resync)
}
protected def resyncNow(member: M) {
protected def resyncNow(member: M): Unit = {
member push resyncMessage
}
def addMember(uid: String, member: M) {
def addMember(uid: String, member: M): Unit = {
eject(uid)
members += (uid -> member)
setAlive(uid)
lilaBus.publish(SocketEnter(uid, member), 'socketDoor)
}
def setAlive(uid: String) { aliveUids put uid }
def setAlive(uid: String): Unit = { aliveUids put uid }
def membersByUserId(userId: String): Iterable[M] = members collect {
case (_, member) if member.userId.contains(userId) => member
@ -177,7 +177,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
}
}
def withMember(uid: String)(f: M => Unit) {
def withMember(uid: String)(f: M => Unit): Unit = {
members get uid foreach f
}
}

View File

@ -6,11 +6,11 @@ final class SocketHub extends Actor {
private val sockets = collection.mutable.Set[ActorRef]()
override def preStart() {
override def preStart(): Unit = {
context.system.lilaBus.subscribe(self, 'deploy, 'socket)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
context.system.lilaBus.unsubscribe(self)
}

View File

@ -8,11 +8,11 @@ import lila.hub.actorApi.{ SendTo, SendTos, WithUserIds }
private final class UserRegister extends Actor {
override def preStart() {
override def preStart(): Unit = {
context.system.lilaBus.subscribe(self, 'users, 'socketDoor)
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
context.system.lilaBus.unsubscribe(self)
}
@ -35,7 +35,7 @@ private final class UserRegister extends Actor {
case SocketLeave(uid, member) => users.remove(uid, member)
}
private def sendTo(userId: String, msg: JsObject) {
private def sendTo(userId: String, msg: JsObject): Unit = {
users get userId foreach { members =>
members.foreachValue(_ push msg)
}

View File

@ -33,12 +33,12 @@ private final class Socket(
private var delayedCrowdNotification = false
override def preStart() {
override def preStart(): Unit = {
super.preStart()
lilaBus.subscribe(self, Symbol(s"chat-$studyId"))
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
lilaBus.unsubscribe(self)
}
@ -229,7 +229,7 @@ private final class Socket(
send = (t, d, _) => notifyVersion(t, d, noMessadata)
)
def notifyCrowd {
def notifyCrowd: Unit = {
if (!delayedCrowdNotification) {
delayedCrowdNotification = true
context.system.scheduler.scheduleOnce(500 millis, self, NotifyCrowd)

View File

@ -61,11 +61,11 @@ final class AutoPairing(
game2
}
private def scheduleIdleCheck(povRef: PovRef, secondsToMove: Int, thenAgain: Boolean) {
private def scheduleIdleCheck(povRef: PovRef, secondsToMove: Int, thenAgain: Boolean): Unit = {
system.scheduler.scheduleOnce(secondsToMove seconds)(idleCheck(povRef, secondsToMove, thenAgain))
}
private def idleCheck(povRef: PovRef, secondsToMove: Int, thenAgain: Boolean) {
private def idleCheck(povRef: PovRef, secondsToMove: Int, thenAgain: Boolean): Unit = {
GameRepo pov povRef foreach {
_.filter(_.game.playable) foreach { pov =>
if (pov.game.playerHasMoved(pov.color)) {

View File

@ -8,7 +8,7 @@ private final class CreatedOrganizer(
isOnline: String => Boolean
) extends Actor {
override def preStart {
override def preStart: Unit = {
pairingLogger.info("Start CreatedOrganizer")
context setReceiveTimeout 15.seconds
scheduleNext

View File

@ -30,13 +30,13 @@ private[tournament] final class Socket(
private var waitingUsers = WaitingUsers.empty
override def preStart() {
override def preStart(): Unit = {
super.preStart()
lilaBus.subscribe(self, Symbol(s"chat-$tournamentId"))
TournamentRepo byId tournamentId map SetTournament.apply pipeTo self
}
override def postStop() {
override def postStop(): Unit = {
super.postStop()
lilaBus.unsubscribe(self)
}
@ -101,14 +101,14 @@ private[tournament] final class Socket(
send = (t, d, trollish) => notifyVersion(t, d, Messadata(trollish))
)
def notifyCrowd {
def notifyCrowd: Unit = {
if (!delayedCrowdNotification) {
delayedCrowdNotification = true
context.system.scheduler.scheduleOnce(1000 millis, self, NotifyCrowd)
}
}
def notifyReload {
def notifyReload: Unit = {
if (!delayedReloadNotification) {
delayedReloadNotification = true
// keep the delay low for immediate response to join/withdraw,

View File

@ -15,7 +15,7 @@ private final class StartedOrganizer(
socketHub: ActorRef
) extends Actor {
override def preStart {
override def preStart: Unit = {
pairingLogger.info("Start StartedOrganizer")
context setReceiveTimeout 15.seconds
scheduleNext

View File

@ -70,7 +70,7 @@ final class TournamentApi(
TournamentRepo.insert(tournament).void >>- publish()
}
private[tournament] def makePairings(oldTour: Tournament, users: WaitingUsers, startAt: Long) {
private[tournament] def makePairings(oldTour: Tournament, users: WaitingUsers, startAt: Long): Unit = {
Sequencing(oldTour.id)(TournamentRepo.startedById) { tour =>
cached ranking tour flatMap { ranking =>
tour.system.pairingSystem.createPairings(tour, users, ranking).flatMap {
@ -128,7 +128,7 @@ final class TournamentApi(
}
}
def start(oldTour: Tournament) {
def start(oldTour: Tournament): Unit = {
Sequencing(oldTour.id)(TournamentRepo.createdById) { tour =>
TournamentRepo.setStatus(tour.id, Status.Started) >>-
sendTo(tour.id, Reload) >>-
@ -141,7 +141,7 @@ final class TournamentApi(
PairingRepo.removeByTour(tour.id) >>
PlayerRepo.removeByTour(tour.id) >>- publish() >>- socketReload(tour.id)
def finish(oldTour: Tournament) {
def finish(oldTour: Tournament): Unit = {
Sequencing(oldTour.id)(TournamentRepo.startedById) { tour =>
PairingRepo count tour.id flatMap {
case 0 => wipe(tour)
@ -166,7 +166,7 @@ final class TournamentApi(
}
}
def kill(tour: Tournament) {
def kill(tour: Tournament): Unit = {
if (tour.isStarted) finish(tour)
else if (tour.isCreated) wipe(tour)
}
@ -188,7 +188,7 @@ final class TournamentApi(
case Some(user) => verify(tour.conditions, user)
}
def join(tourId: String, me: User, p: Option[String]) {
def join(tourId: String, me: User, p: Option[String]): Unit = {
Sequencing(tourId)(TournamentRepo.enterableById) { tour =>
if (tour.password == p) {
verdicts(tour, me.some) flatMap {
@ -218,7 +218,7 @@ final class TournamentApi(
private def updateNbPlayers(tourId: String) =
PlayerRepo count tourId flatMap { TournamentRepo.setNbPlayers(tourId, _) }
private def withdrawOtherTournaments(tourId: String, userId: String) {
private def withdrawOtherTournaments(tourId: String, userId: String): Unit = {
TournamentRepo toursToWithdrawWhenEntering tourId foreach {
_ foreach { other =>
PlayerRepo.exists(other.id, userId) foreach {
@ -228,7 +228,7 @@ final class TournamentApi(
}
}
def withdraw(tourId: String, userId: String) {
def withdraw(tourId: String, userId: String): Unit = {
Sequencing(tourId)(TournamentRepo.enterableById) {
case tour if tour.isCreated =>
PlayerRepo.remove(tour.id, userId) >> updateNbPlayers(tour.id) >>- socketReload(tour.id) >>- publish()
@ -238,7 +238,7 @@ final class TournamentApi(
}
}
def withdrawAll(user: User) {
def withdrawAll(user: User): Unit = {
TournamentRepo.nonEmptyEnterable foreach {
_ foreach { tour =>
PlayerRepo.exists(tour.id, user.id) foreach {
@ -248,7 +248,7 @@ final class TournamentApi(
}
}
def berserk(gameId: String, userId: String) {
def berserk(gameId: String, userId: String): Unit = {
GameRepo game gameId foreach {
_.flatMap(_.tournamentId) foreach { tourId =>
Sequencing(tourId)(TournamentRepo.startedById) { tour =>
@ -270,7 +270,7 @@ final class TournamentApi(
}
}
def finishGame(game: Game) {
def finishGame(game: Game): Unit = {
game.tournamentId foreach { tourId =>
Sequencing(tourId)(TournamentRepo.startedById) { tour =>
PairingRepo.finish(game) >>
@ -315,7 +315,7 @@ final class TournamentApi(
}.sequenceFu.void
}
def ejectLame(userId: String) {
def ejectLame(userId: String): Unit = {
TournamentRepo.recentAndNext foreach {
_ foreach { tour =>
PlayerRepo.exists(tour.id, userId) foreach {
@ -325,7 +325,7 @@ final class TournamentApi(
}
}
def ejectLame(tourId: String, userId: String) {
def ejectLame(tourId: String, userId: String): Unit = {
Sequencing(tourId)(TournamentRepo.byId) { tour =>
PlayerRepo.remove(tour.id, userId) >> {
if (tour.isStarted)
@ -409,11 +409,11 @@ final class TournamentApi(
}
}
private def sequence(tourId: String)(work: => Funit) {
private def sequence(tourId: String)(work: => Funit): Unit = {
sequencers ! Tell(tourId, Sequencer work work)
}
private def Sequencing(tourId: String)(fetch: String => Fu[Option[Tournament]])(run: Tournament => Funit) {
private def Sequencing(tourId: String)(fetch: String => Fu[Option[Tournament]])(run: Tournament => Funit): Unit = {
sequence(tourId) {
fetch(tourId) flatMap {
case Some(t) => run(t)
@ -422,7 +422,7 @@ final class TournamentApi(
}
}
private def socketReload(tourId: String) {
private def socketReload(tourId: String): Unit = {
sendTo(tourId, Reload)
}
@ -438,7 +438,7 @@ final class TournamentApi(
} pipeToSelection lobby
}
})))
def apply() { debouncer ! Debouncer.Nothing }
def apply(): Unit = { debouncer ! Debouncer.Nothing }
}
private object updateTournamentStanding {

View File

@ -46,7 +46,7 @@ private[tv] final class ChannelActor(channel: Tv.Channel) extends Actor {
}
}
def elect(gameOption: Option[Game]) {
def elect(gameOption: Option[Game]): Unit = {
gameOption foreach { self ! SetGame(_) }
}

View File

@ -349,7 +349,7 @@ object UserRepo {
}(scala.collection.breakOut)
}
def setSeenAt(id: ID) {
def setSeenAt(id: ID): Unit = {
coll.updateFieldUnchecked($id(id), "seenAt", DateTime.now)
}