Skip to content

Commit

Permalink
more code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Aug 16, 2020
1 parent 08781d1 commit 1d0e445
Show file tree
Hide file tree
Showing 33 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class LilaComponents(ctx: ApplicationLoader.Context) extends BuiltInCompon
implicit def system = actorSystem
implicit lazy val ws: StandaloneWSClient = {
import play.shaded.ahc.org.asynchttpclient.DefaultAsyncHttpClient
import play.api.libs.ws.{ WSConfigParser }
import play.api.libs.ws.WSConfigParser
import play.api.libs.ws.ahc.{ AhcConfigBuilder, AhcWSClientConfigParser, StandaloneAhcWSClient }
new StandaloneAhcWSClient(
new DefaultAsyncHttpClient(
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/LilaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ abstract private[controllers] class LilaController(val env: Env)
} map {
case (
(pref, hasClas),
(teamNbRequests ~ nbChallenges ~ nbNotifications ~ inquiry)
teamNbRequests ~ nbChallenges ~ nbNotifications ~ inquiry
) =>
PageData(
teamNbRequests,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Team.scala
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ final class Team(
_ => fuccess(routes.Team.show(team.id).toString),
{
case (decision, url) =>
api.processRequest(team, request, (decision == "accept")) inject url
api.processRequest(team, request, decision == "accept") inject url
}
)
}
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/Tournament.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ final class Tournament(
negotiate(
html = tourOption
.fold(tournamentNotFound.fuccess) { tour =>
(for {
for {
verdicts <- api.verdicts(tour, ctx.me, getUserTeamIds)
version <- env.tournament.version(tour.id)
json <- jsonView(
Expand All @@ -119,7 +119,7 @@ final class Tournament(
}
streamers <- streamerCache get tour.id
shieldOwner <- env.tournament.shieldApi currentOwner tour
} yield Ok(html.tournament.show(tour, verdicts, json, chat, streamers, shieldOwner)))
} yield Ok(html.tournament.show(tour, verdicts, json, chat, streamers, shieldOwner))
}
.monSuccess(_.tournament.apiShowPartial(partial = false, HTTPRequest clientName ctx.req)),
api = _ =>
Expand Down
2 changes: 1 addition & 1 deletion app/views/report/list.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object list {
)(shorten(atom.text, 200))
)
},
r.atoms.size > 3 option i(cls := "more")("And ", (r.atoms.size - 3), " more")
r.atoms.size > 3 option i(cls := "more")("And ", r.atoms.size - 3, " more")
),
td(
r.inquiry match {
Expand Down
2 changes: 1 addition & 1 deletion app/views/tournament/homepageSpotlight.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object homepageSpotlight {
def apply(tour: lila.tournament.Tournament)(implicit ctx: Context) = {
val schedClass = tour.schedule ?? { sched =>
val invert = (sched.freq.isWeeklyOrBetter && tour.isNowOrSoon) ?? " invert"
val distant = (tour.isDistant) ?? " distant little"
val distant = tour.isDistant ?? " distant little"
s"${sched.freq} ${sched.speed} ${sched.variant.key}$invert$distant"
}
val tourClass = s"tour-spotlight id_${tour.id} $schedClass"
Expand Down
2 changes: 1 addition & 1 deletion modules/coach/src/main/CoachPager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import play.api.i18n.Lang

import lila.common.paginator.Paginator
import lila.db.dsl._
import lila.db.paginator.{ Adapter }
import lila.db.paginator.Adapter
import lila.user.{ User, UserRepo }

final class CoachPager(
Expand Down
8 changes: 4 additions & 4 deletions modules/common/src/main/WMMatching.scala
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ object WMMatching {
val l1 = blossomchilds(b).length - 1
val (jstep, endptrick) =
// Start index is odd; go forward and wrap.
if ((j & 1) != 0) ((j: Int) => { if (j == l1) 0 else (j + 1) }, 0)
if ((j & 1) != 0) ((j: Int) => { if (j == l1) 0 else j + 1 }, 0)
// Start index is even; go backward.
else ((j: Int) => { if (j == 0) l1 else (j - 1) }, 1)
else ((j: Int) => { if (j == 0) l1 else j - 1 }, 1)
// Move along the blossom until we get to the base.
var p = labelend(b)
while (j != 0) {
Expand Down Expand Up @@ -534,8 +534,8 @@ object WMMatching {
val i = blossomchilds(b).indexOf(t)
var j = i
val (jstep, endptrick) =
if ((j & 1) != 0) ((j: Int) => { if (j == l1) 0 else (j + 1) }, 0)
else ((j: Int) => { if (j == 0) l1 else (j - 1) }, 1)
if ((j & 1) != 0) ((j: Int) => { if (j == l1) 0 else j + 1 }, 0)
else ((j: Int) => { if (j == 0) l1 else j - 1 }, 1)
// Move along the blossom until we get to the base.
while (j != 0) {
// Step to the next sub-blossom and augment it recursively.
Expand Down
2 changes: 1 addition & 1 deletion modules/common/src/main/base/Levenshtein.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object Levenshtein {
if (i == 0) j
else {
val t0 = if (i < prevr.end) prev(i) else inf
val t1 = 1 + (if (i > q.start) t0 min (next(i - 1)) else t0)
val t1 = 1 + (if (i > q.start) t0 min next(i - 1) else t0)
if (prevr.start < i) {
val t = prev(i - 1)
t1 min (if (c != a(i - 1)) 1 + t else t)
Expand Down
2 changes: 1 addition & 1 deletion modules/common/src/main/base/PimpedFutures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class PimpedFuture[A](private val fua: Fu[A]) extends AnyVal {

def addFailureEffect(effect: Throwable => Unit)(implicit ec: EC) = {
fua.failed.foreach {
case e: Throwable => effect(e)
e: Throwable => effect(e)
}
fua
}
Expand Down
2 changes: 1 addition & 1 deletion modules/db/src/main/dsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ trait dsl {
}

trait LogicalOperators { self: ElementBuilder =>
def $not(f: (String => Expression[Bdoc])): SimpleExpression[Bdoc] = {
def $not(f: String => Expression[Bdoc]): SimpleExpression[Bdoc] = {
val expression = f(field)
SimpleExpression(field, $doc("$not" -> expression.value))
}
Expand Down
4 changes: 2 additions & 2 deletions modules/evaluation/src/main/Assessible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ case class Assessible(analysed: Analysed, color: Color) {
lazy val alwaysHasAdvantage: Boolean =
!analysis.infos.exists { info =>
info.cp.fold(info.mate.fold(false) { a =>
(a.signum == color.fold(-1, 1))
a.signum == color.fold(-1, 1)
}) { cp =>
color.fold(cp.centipawns < -100, cp.centipawns > 100)
}
Expand Down Expand Up @@ -128,7 +128,7 @@ case class Assessible(analysed: Analysed, color: Color) {
_id = game.id + "/" + color.name,
gameId = game.id,
userId = ~game.player(color).userId,
white = (color == Color.White),
white = color == Color.White,
assessment = rankCheating,
date = DateTime.now,
// meta
Expand Down
8 changes: 4 additions & 4 deletions modules/forum/src/main/PostApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ final class PostApi(
shouldHideOnPost(topic) ?? env.topicRepo.hide(topic.id, value = true)
} >>
env.categRepo.coll.update.one($id(categ.id), categ withTopic post) >>- {
(!categ.quiet ?? (indexer ! InsertPost(post)))
(!categ.quiet ?? env.recent.invalidate())
!categ.quiet ?? (indexer ! InsertPost(post))
!categ.quiet ?? env.recent.invalidate()
promotion.save(me, post.text)
shutup ! {
if (post.isTeam) lila.hub.actorApi.shutup.RecordTeamForumMessage(me.id, post.text)
Expand Down Expand Up @@ -199,7 +199,7 @@ final class PostApi(
_ ?? { post =>
viewOf(post) flatMap {
_ ?? { view =>
(for {
for {
first <- env.postRepo.isFirstPost(view.topic.id, view.post.id)
_ <-
if (first) env.topicApi.delete(view.categ, view.topic)
Expand All @@ -215,7 +215,7 @@ final class PostApi(
post.author,
text = "%s / %s / %s".format(view.categ.name, view.topic.name, post.text)
)
} yield ())
} yield ()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/forum/src/main/TopicApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ final private[forum] class TopicApi(
env.postRepo.coll.insert.one(post) >>
env.topicRepo.coll.insert.one(topic withPost post) >>
env.categRepo.coll.update.one($id(categ.id), categ withTopic post) >>- {
(!categ.quiet ?? (indexer ! InsertPost(post)))
(!categ.quiet ?? env.recent.invalidate())
!categ.quiet ?? (indexer ! InsertPost(post))
!categ.quiet ?? env.recent.invalidate()
promotion.save(me, post.text)
shutup ! {
val text = s"${topic.name} ${post.text}"
Expand Down
4 changes: 2 additions & 2 deletions modules/game/src/main/BinaryFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ object BinaryFormat {

def write(mts: Vector[Centis]): ByteArray = {
def enc(mt: Centis) = encodeCutoffs.search(mt.centis).insertionPoint
(mts
mts
.grouped(2)
.map {
case Vector(a, b) => (enc(a) << 4) + enc(b)
case Vector(a) => enc(a) << 4
})
}
.map(_.toByte)
.toArray
}
Expand Down
2 changes: 1 addition & 1 deletion modules/game/src/main/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ case class Game(
// because if moretime was given,
// elapsed time is no longer representing the game duration
def durationSeconds: Option[Int] =
(movedAt.getSeconds - createdAt.getSeconds) match {
movedAt.getSeconds - createdAt.getSeconds match {
case seconds if seconds > 60 * 60 * 12 => none // no way it lasted more than 12 hours, come on.
case seconds => seconds.toInt.some
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gameSearch/src/main/DataForm.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package lila.gameSearch

import chess.{ Mode }
import chess.Mode
import org.joda.time.DateTime
import play.api.data._
import play.api.data.Forms._
Expand Down
2 changes: 1 addition & 1 deletion modules/i18n/src/main/I18nQuantity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private object I18nQuantity {
def romanian(c: Count) = {
val rem100 = c % 100;
if (c == 1) One
else if ((c == 0 || (rem100 >= 1 && rem100 <= 19))) Few
else if (c == 0 || (rem100 >= 1 && rem100 <= 19)) Few
else Other
}

Expand Down
2 changes: 1 addition & 1 deletion modules/importer/src/main/Importer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Importer(gameRepo: GameRepo)(implicit ec: scala.concurrent.Execution
(data preprocess user).toFuture flatMap {
case Preprocessed(g, _, initialFen, _) =>
val game = forceId.fold(g.sloppy)(g.withId)
(gameRepo.insertDenormalized(game, initialFen = initialFen)) >> {
gameRepo.insertDenormalized(game, initialFen = initialFen) >> {
game.pgnImport.flatMap(_.user).isDefined ?? gameRepo.setImportCreatedAt(game)
} >> {
gameRepo.finish(
Expand Down
1 change: 0 additions & 1 deletion modules/msg/src/main/MsgThread.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ object MsgThread {
def make(u1: User.ID, u2: User.ID, msg: Msg): MsgThread =
sortUsers(u1, u2) match {
case (user1, user2) =>
s"$user1/$user2"
MsgThread(
id = id(user1, user2),
user1 = user1,
Expand Down
2 changes: 1 addition & 1 deletion modules/plan/src/main/PlanNotifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package lila.plan
import akka.actor._
import scala.concurrent.duration._

import lila.hub.actorApi.timeline.{ Propagate }
import lila.hub.actorApi.timeline.Propagate
import lila.notify.Notification.Notifies
import lila.notify.{ Notification, NotifyApi }
import lila.user.User
Expand Down
2 changes: 1 addition & 1 deletion modules/pref/src/main/PrefApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class PrefApi(
def unfollowableIds(userIds: List[User.ID]): Fu[Set[User.ID]] =
coll.secondaryPreferred.distinctEasy[User.ID, Set](
"_id",
($inIds(userIds) ++ $doc("follow" -> false))
$inIds(userIds) ++ $doc("follow" -> false)
)

def followableIds(userIds: List[User.ID]): Fu[Set[User.ID]] =
Expand Down
2 changes: 1 addition & 1 deletion modules/puzzle/src/main/Line.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Line {
walk(rest :+ (siblings -> depth) :+ (children -> (depth + 1)))
}
}
(1 + ~(walk(Vector(lines -> 1)))) / 2
(1 + ~walk(Vector(lines -> 1))) / 2
}

def solution(lines: Lines): List[String] = {
Expand Down
2 changes: 1 addition & 1 deletion modules/relay/src/main/Relay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package lila.relay

import org.joda.time.DateTime

import lila.study.{ Study }
import lila.study.Study
import lila.user.User

case class Relay(
Expand Down
2 changes: 1 addition & 1 deletion modules/round/src/main/Forecast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ case class Forecast(
nextMove(g, lastMove) map { move =>
copy(
steps = steps.collect {
case (fst :: snd :: rest)
case fst :: snd :: rest
if rest.nonEmpty && g.turns == fst.ply && fst.is(lastMove) && snd.is(move) =>
rest
},
Expand Down
4 changes: 2 additions & 2 deletions modules/slack/src/main/SlackApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ final class SlackApi(
SlackMessage(
username = mod.username,
icon = "spiral_note_pad",
text = (s"_*${userLink(user.username)}*_ (${userNotesLink(user.username)}):\n" +
linkifyUsers(note.text take 2000)),
text = s"_*${userLink(user.username)}*_ (${userNotesLink(user.username)}):\n" +
linkifyUsers(note.text take 2000),
channel = rooms.tavern
)
} flatMap client.apply
Expand Down
2 changes: 1 addition & 1 deletion modules/socket/src/main/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ final class IsOnline(f: (String => Boolean)) extends (String => Boolean) {
def apply(id: String) = f(id)
}

final class OnlineIds(f: (() => Set[String])) extends (() => Set[String]) {
final class OnlineIds(f: () => Set[String]) extends (() => Set[String]) {
def apply() = f()
}
2 changes: 1 addition & 1 deletion modules/swiss/src/main/Swiss.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ case class Swiss(
def estimatedDurationString = {
val minutes = estimatedDuration.toMinutes
if (minutes < 60) s"${minutes}m"
else s"${minutes / 60}h" + (if (minutes % 60 != 0) s" ${(minutes % 60)}m" else "")
else s"${minutes / 60}h" + (if (minutes % 60 != 0) s" ${minutes % 60}m" else "")
}

def roundInfo = Swiss.RoundInfo(teamId, settings.chatFor)
Expand Down
4 changes: 2 additions & 2 deletions modules/tournament/src/main/AutoPairing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ final class AutoPairing(
duelStore.add(
tour = tour,
game = game,
p1 = (usernameOf(pairing.user1) -> ~game.whitePlayer.rating),
p2 = (usernameOf(pairing.user2) -> ~game.blackPlayer.rating),
p1 = usernameOf(pairing.user1) -> ~game.whitePlayer.rating,
p2 = usernameOf(pairing.user2) -> ~game.blackPlayer.rating,
ranking = ranking
)
} inject game
Expand Down
2 changes: 1 addition & 1 deletion modules/tournament/src/main/Pause.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final private class Pause {

private def baseDelayOf(tour: Tournament) =
Delay {
(tour.clock.estimateTotalSeconds / 15)
tour.clock.estimateTotalSeconds / 15
}

private def delayOf(record: Record, tour: Tournament) =
Expand Down
4 changes: 2 additions & 2 deletions modules/tournament/src/main/PlayerRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ final class PlayerRepo(coll: Coll)(implicit ec: scala.concurrent.ExecutionContex
teamId <- doc.getAsOpt[TeamID]("_id")
leadersBson <- doc.getAsOpt[List[Bdoc]]("p")
leaders = leadersBson.flatMap {
case p: Bdoc =>
p: Bdoc =>
for {
id <- p.getAsOpt[User.ID]("u")
id <- p.getAsOpt[User.ID]("u")
magic <- p.int("m")
} yield TeamLeader(id, magic)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/tournament/src/main/Spotlight.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Spotlight {

private def sort(tours: List[Tournament]) =
tours.sortBy { t =>
-(t.schedule.??(_.freq.importance))
-t.schedule.??(_.freq.importance)
}

private def select(tour: Tournament, user: User): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion modules/tournament/src/main/Tournament.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ case class Tournament(

def durationString =
if (minutes < 60) s"${minutes}m"
else s"${minutes / 60}h" + (if (minutes % 60 != 0) s" ${(minutes % 60)}m" else "")
else s"${minutes / 60}h" + (if (minutes % 60 != 0) s" ${minutes % 60}m" else "")

def berserkable = !noBerserk && clock.berserkable
def streakable = !noStreak
Expand Down

0 comments on commit 1d0e445

Please sign in to comment.