Skip to content

Commit

Permalink
remove superfluous blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Aug 16, 2020
1 parent 5bbb970 commit 30e23a7
Show file tree
Hide file tree
Showing 50 changed files with 71 additions and 99 deletions.
2 changes: 1 addition & 1 deletion app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class LilaComponents(ctx: ApplicationLoader.Context) extends BuiltInCompon
val mem = Runtime.getRuntime().maxMemory() / 1024 / 1024
val appVersionCommit = ~configuration.getOptional[String]("app.version.commit")
val appVersionDate = ~configuration.getOptional[String]("app.version.date")
s"lila ${ctx.environment.mode} $appVersionCommit $appVersionDate / java ${java}, memory: ${mem}MB"
s"lila ${ctx.environment.mode} $appVersionCommit $appVersionDate / java $java, memory: ${mem}MB"
}

import _root_.controllers._
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/Account.scala
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,9 @@ final class Account(
def reopenLogin(token: String) =
Open { implicit ctx =>
env.security.reopen confirm token flatMap {
case None => {
case None =>
lila.mon.user.auth.reopenConfirm("token_fail").increment()
notFound
}
case Some(user) =>
env.report.api.reopenReports(lila.report.Suspect(user)) >>
auth.authenticateUser(user) >>-
Expand Down
27 changes: 9 additions & 18 deletions app/controllers/Auth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,14 @@ final class Auth(
env.security.recaptcha.verify(~data.recaptchaResponse, req) flatMap {
_ ?? env.user.repo.enabledWithEmail(data.realEmail.normalize)
} flatMap {
case Some((user, storedEmail)) => {
case Some((user, storedEmail)) =>
lila.mon.user.auth.passwordResetRequest("success").increment()
env.security.passwordReset.send(user, storedEmail) inject Redirect(
routes.Auth.passwordResetSent(storedEmail.conceal)
)
}
case _ => {
case _ =>
lila.mon.user.auth.passwordResetRequest("noEmail").increment()
BadRequest(renderPasswordReset(none, fail = true)).fuccess
}
}
)
}
Expand All @@ -361,25 +359,22 @@ final class Auth(
def passwordResetConfirm(token: String) =
Open { implicit ctx =>
env.security.passwordReset confirm token flatMap {
case None => {
case None =>
lila.mon.user.auth.passwordResetConfirm("tokenFail").increment()
notFound
}
case Some(user) => {
case Some(user) =>
authLog(user.username, "-", "Reset password")
lila.mon.user.auth.passwordResetConfirm("tokenOk").increment()
fuccess(html.auth.bits.passwordResetConfirm(user, token, forms.passwdReset, none))
}
}
}

def passwordResetConfirmApply(token: String) =
OpenBody { implicit ctx =>
env.security.passwordReset confirm token flatMap {
case None => {
case None =>
lila.mon.user.auth.passwordResetConfirm("tokenPostFail").increment()
notFound
}
case Some(user) =>
implicit val req = ctx.body
FormFuResult(forms.passwdReset) { err =>
Expand Down Expand Up @@ -421,18 +416,16 @@ final class Auth(
env.security.recaptcha.verify(~data.recaptchaResponse, req) flatMap {
_ ?? env.user.repo.enabledWithEmail(data.realEmail.normalize)
} flatMap {
case Some((user, storedEmail)) => {
case Some((user, storedEmail)) =>
MagicLinkRateLimit(user, storedEmail, ctx.req) {
lila.mon.user.auth.magicLinkRequest("success").increment()
env.security.magicLink.send(user, storedEmail) inject Redirect(
routes.Auth.magicLinkSent(storedEmail.value)
)
}(rateLimitedFu)
}
case _ => {
case _ =>
lila.mon.user.auth.magicLinkRequest("no_email").increment()
BadRequest(renderMagicLink(none, fail = true)).fuccess
}
}
)
}
Expand All @@ -447,15 +440,13 @@ final class Auth(
def magicLinkLogin(token: String) =
Open { implicit ctx =>
env.security.magicLink confirm token flatMap {
case None => {
case None =>
lila.mon.user.auth.magicLinkConfirm("token_fail").increment()
notFound
}
case Some(user) => {
case Some(user) =>
authLog(user.username, "-", "Magic link")
authenticateUser(user) >>-
lila.mon.user.auth.magicLinkConfirm("success").increment()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Allow: /
"icons" -> List(32, 64, 128, 192, 256, 512, 1024).map { size =>
Json.obj(
"src" -> s"//${env.net.assetDomain.value}/assets/logo/lichess-favicon-$size.png",
"sizes" -> s"${size}x${size}",
"sizes" -> s"${size}x$size",
"type" -> "image/png"
)
},
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Mod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ final class Mod(
err => BadRequest(err.toString).fuccess,
rawEmail => {
val email = env.security.emailAddressValidator
.validate(EmailAddress(rawEmail)) err s"Invalid email ${rawEmail}"
.validate(EmailAddress(rawEmail)) err s"Invalid email $rawEmail"
modApi.setEmail(me.id, user.id, email.acceptable) inject redirect(user.username, mod = true)
}
)
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/Round.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ final class Round(
case _ =>
Redirect(routes.Round.watcher(gameId, "white")).fuccess
}
case None => {
case None =>
watch(pov)
}
}
case None => challengeC showId gameId
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Streamer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ final class Streamer(
}
else {
val next = if (sws.streamer is me) "" else s"?u=${sws.user.id}"
Redirect(s"${routes.Streamer.edit().url}${next}").fuccess
Redirect(s"${routes.Streamer.edit().url}$next").fuccess
}
}
)
Expand Down
3 changes: 1 addition & 2 deletions app/templating/GameHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,9 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
}
case S.Draw => trans.draw.txt()
case S.Outoftime => trans.timeOut.txt()
case S.NoStart => {
case S.NoStart =>
val color = game.loser.fold(Color.white)(_.color).name.capitalize
s"$color didn't move"
}
case S.Cheat => "Cheat detected"
case S.VariantEnd =>
game.variant match {
Expand Down
2 changes: 1 addition & 1 deletion app/templating/SetupHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ trait SetupHelper { self: I18nHelper =>

val corresDaysChoices: List[SelectChoice] =
("1", "One day", none) :: List(2, 3, 5, 7, 10, 14).map { d =>
(d.toString, s"${d} days", none)
(d.toString, s"$d days", none)
}

def translatedTimeModeChoices(implicit lang: Lang) =
Expand Down
2 changes: 1 addition & 1 deletion app/views/base/layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object layout {
.map { px =>
s"""<link rel="icon" type="image/png" href="${staticUrl(
s"logo/lichess-favicon-$px.png"
)}" sizes="${px}x${px}">"""
)}" sizes="${px}x$px">"""
}
.mkString(
"",
Expand Down
2 changes: 1 addition & 1 deletion app/views/mod/inquiry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ object inquiry {
div(cls := "links")(
in.report.boostWith
.map { userId =>
a(href := s"${routes.User.games(in.user.id, "search")}?players.b=${userId}")("View", br, "Games")
a(href := s"${routes.User.games(in.user.id, "search")}?players.b=$userId")("View", br, "Games")
}
.getOrElse {
in.report.bestAtomByHuman.map { atom =>
Expand Down
2 changes: 1 addition & 1 deletion app/views/setup/bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private object bits {
div(
input(
`type` := "radio",
id := s"$prefix${field.id}_${key}",
id := s"$prefix${field.id}_$key",
st.name := field.name,
value := key,
field.value.has(key) option checked
Expand Down
2 changes: 1 addition & 1 deletion app/views/study/show.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ object show {
)
)

def socketUrl(id: String) = s"/study/$id/socket/v${apiVersion}"
def socketUrl(id: String) = s"/study/$id/socket/v$apiVersion"
}
3 changes: 1 addition & 2 deletions app/views/tournament/shields.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object shields {
h1("Tournament shields"),
div(cls := "tournament-shields")(
history.sorted.map {
case (categ, awards) => {
case (categ, awards) =>
section(
h2(
a(href := routes.Tournament.categShields(categ.key))(
Expand All @@ -38,7 +38,6 @@ object shields {
)
})
)
}
}
)
)
Expand Down
3 changes: 1 addition & 2 deletions app/views/userTournament/chart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ object chart {
),
tbody(
data.perfResults.map {
case (pt, res) => {
case (pt, res) =>
tr(
th(iconTag(pt.iconChar, pt.trans)),
td(res.nb.localize),
td(res.points.median.map(_.toInt)),
td(res.points.sum.localize),
td(res.rankPercentMedian, "%")
)
}
},
tr(
th("Total"),
Expand Down
2 changes: 1 addition & 1 deletion app/views/video/bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object bits {
videos.currentPageResults.map { card(_, control) },
videos.nextPage.map { next =>
div(cls := "pager none")(
a(rel := "next", href := s"${routes.Video.author(name)}?${control.queryString}&page=${next}")(
a(rel := "next", href := s"${routes.Video.author(name)}?${control.queryString}&page=$next")(
"Next"
)
)
Expand Down
2 changes: 1 addition & 1 deletion modules/bot/src/main/GameStateStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class GameStateStream(

private val classifiers = List(
MoveGameEvent makeChan id,
s"boardDrawOffer:${id}",
s"boardDrawOffer:$id",
"finishGame",
"abortGame",
uniqChan(init.game pov as),
Expand Down
2 changes: 1 addition & 1 deletion modules/chat/src/main/ChatTimeout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object ChatTimeout {
def apply(key: String) = all.find(_.key == key)
}
implicit val ReasonBSONHandler: BSONHandler[Reason] = tryHandler[Reason](
{ case BSONString(value) => Reason(value) toTry s"Invalid reason ${value}" },
{ case BSONString(value) => Reason(value) toTry s"Invalid reason $value" },
x => BSONString(x.key)
)

Expand Down
2 changes: 1 addition & 1 deletion modules/clas/src/main/Student.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ case class Student(

object Student {

def id(userId: User.ID, clasId: Clas.Id) = Id(s"${userId}:${clasId}")
def id(userId: User.ID, clasId: Clas.Id) = Id(s"$userId:$clasId")

def make(user: User, clas: Clas, teacherId: User.ID, realName: String, managed: Boolean) =
Student(
Expand Down
3 changes: 1 addition & 2 deletions modules/common/src/main/String.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,12 @@ object String {
case JsNumber(n) => n.toString
case JsBoolean(b) => if (b) "true" else "false"
case JsArray(items) => items.map(safeJsonValue).mkString("[", ",", "]")
case JsObject(fields) => {
case JsObject(fields) =>
fields
.map {
case (k, v) => s"${safeJsonString(k)}:${safeJsonValue(v)}"
}
.mkString("{", ",", "}")
}
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions modules/common/src/main/WMMatching.scala
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,12 @@ object WMMatching {
for (v <- vertices) {
label(inblossom(v)) match {
case 0 => ()
case 1 => {
case 1 =>
//S-vertex: 2*u = 2*u - 2*delta
dualvar(v) -= dt.delta
}
case 2 => {
case 2 =>
//T-vertex: 2*u = 2*u + 2*delta
dualvar(v) += dt.delta
}
}
}

Expand All @@ -768,24 +766,21 @@ object WMMatching {
// Take action at the point where minimum delta occurred.
dt.tp match {
case 0 => false
case 1 => {
case 1 =>
// Use the least-slack edge to continue the search.
allowedge(dt.extra) = true
val kk = 2 * dt.extra
val ei = endpoint(kk)
queue ::= (if (label(inblossom(ei)) == 0) endpoint(kk + 1) else ei)
true
}
case 2 => {
case 2 =>
// Use the least-slack edge to continue the search.
allowedge(dt.extra) = true
queue ::= endpoint(2 * dt.extra)
true
}
case 3 => {
case 3 =>
expandBlossom(dt.extra, endstage = false)
true
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/common/src/main/base/RawHtml.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ final object RawHtml {
while (
(sArr(last): @switch) match {
case '.' | ',' | '?' | '!' | ':' | ';' | '–' | '—' | '@' | '\'' => true
case '(' => { parenCnt -= 1; true }
case ')' => { parenCnt += 1; parenCnt <= 0 }
case '(' => parenCnt -= 1; true
case ')' => parenCnt += 1; parenCnt <= 0
case _ => false
}
) { last -= 1 }
Expand Down
2 changes: 1 addition & 1 deletion modules/common/src/main/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ case class NormalizedEmailAddress(value: String) extends AnyVal with StringValue
case class EmailAddress(value: String) extends AnyVal with StringValue {
def conceal =
value split '@' match {
case Array(user, domain) => s"${user take 3}*****@${domain}"
case Array(user, domain) => s"${user take 3}*****@$domain"
case _ => value
}
def normalize =
Expand Down
6 changes: 3 additions & 3 deletions modules/evalCache/src/main/BSONHandlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ private object BSONHandlers {
scoreRead(score) err s"Invalid score $score",
movesRead(moves) err s"Invalid moves $moves"
)
case x => sys error s"Invalid PV $pvStr: ${x.toList} (in ${value})"
case x => sys error s"Invalid PV $pvStr: ${x.toList} (in $value)"
}
}
}.flatMap {
_.toNel toTry s"Empty PVs ${value}"
_.toNel toTry s"Empty PVs $value"
}
case b => lila.db.BSON.handlerBadType[NonEmptyList[Pv]](b)
}
Expand All @@ -70,7 +70,7 @@ private object BSONHandlers {
SmallFen raw fen
)
)
case _ => lila.db.BSON.handlerBadValue(s"Invalid evalcache id ${value}")
case _ => lila.db.BSON.handlerBadValue(s"Invalid evalcache id $value")
}
},
x =>
Expand Down
3 changes: 1 addition & 2 deletions modules/fishnet/src/main/Analyser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final class Analyser(
def study(req: lila.hub.actorApi.fishnet.StudyChapterRequest): Fu[Boolean] =
analysisRepo exists req.chapterId flatMap {
case true => fuFalse
case _ => {
case _ =>
import req._
val sender =
Work.Sender(req.userId.some, none, mod = false, system = lila.user.User isOfficial req.userId)
Expand Down Expand Up @@ -92,7 +92,6 @@ final class Analyser(
}
} inject accepted
}
}
}

private def makeWork(game: Game, sender: Work.Sender): Fu[Work.Analysis] =
Expand Down
Loading

0 comments on commit 30e23a7

Please sign in to comment.