Skip to content

Commit

Permalink
upgrade scalafmt and reformat all scala files
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 23, 2022
1 parent 676caab commit da0c824
Show file tree
Hide file tree
Showing 262 changed files with 1,344 additions and 1,346 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.5.2"
align.preset = more
maxColumn = 110
spaces.inImportCurlyBraces = true
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Account.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import lila.api.Context
import lila.app._
import lila.common.HTTPRequest
import lila.security.SecurityForm.Reopen
import lila.user.{ User => UserModel, TotpSecret, Holder }
import lila.user.{ Holder, TotpSecret, User => UserModel }

final class Account(
env: Env,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/Auth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import lila.memo.RateLimit
import lila.security.SecurityForm.{ MagicLink, PasswordReset }
import lila.security.{ FingerPrint, Signup }
import lila.user.User.ClearPassword
import lila.user.{ User => UserModel, PasswordHasher }
import lila.user.{ PasswordHasher, User => UserModel }

final class Auth(
env: Env,
Expand Down Expand Up @@ -94,7 +94,7 @@ final class Auth(
Firewall {
def redirectTo(url: String) = if (HTTPRequest isXhr ctx.req) Ok(s"ok:$url") else Redirect(url)
implicit val req = ctx.body
val referrer = get("referrer").filterNot(env.api.referrerRedirect.sillyLoginReferrers.contains)
val referrer = get("referrer").filterNot(env.api.referrerRedirect.sillyLoginReferrers.contains)
api.usernameOrEmailForm
.bindFromRequest()
.fold(
Expand All @@ -114,7 +114,7 @@ final class Auth(
html = fuccess {
err.errors match {
case List(FormError("", List(err), _)) if is2fa(err) => Ok(err)
case _ => Unauthorized(html.auth.login(err, referrer))
case _ => Unauthorized(html.auth.login(err, referrer))
}
},
api = _ =>
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Challenge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ final class Challenge(

private def isMine(challenge: ChallengeModel)(implicit ctx: Context) =
challenge.challenger match {
case lila.challenge.Challenge.Challenger.Anonymous(secret) => HTTPRequest sid ctx.req contains secret
case lila.challenge.Challenge.Challenger.Anonymous(secret) => HTTPRequest sid ctx.req contains secret
case lila.challenge.Challenge.Challenger.Registered(userId, _) => ctx.userId contains userId
case lila.challenge.Challenge.Challenger.Open => false
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Coach.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import play.api.mvc._

import lila.api.Context
import lila.app._
import lila.coach.{ Coach => CoachModel, CoachProfileForm, CoachPager }
import lila.coach.{ Coach => CoachModel, CoachPager, CoachProfileForm }
import views._
import lila.user.Countries

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ForumCateg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ForumCateg(env: Env) extends LilaController(env) with ForumControlle
canRead <- access.isGrantedRead(categ.slug)
canWrite <- access.isGrantedWrite(categ.slug)
stickyPosts <- (page == 1) ?? env.forum.topicApi.getSticky(categ, ctx.me)
_ <- env.user.lightUserApi preloadMany topics.currentPageResults.flatMap(_.lastPostUserId)
_ <- env.user.lightUserApi preloadMany topics.currentPageResults.flatMap(_.lastPostUserId)
res <-
if (canRead) Ok(html.forum.categ.show(categ, topics, canWrite, stickyPosts)).fuccess
else notFound
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/LilaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import lila.i18n.I18nLangPicker
import lila.notify.Notification.Notifies
import lila.oauth.{ OAuthScope, OAuthServer }
import lila.security.{ AppealUser, FingerPrintedUser, Granter, Permission }
import lila.user.{ UserContext, User => UserModel, Holder }
import lila.user.{ Holder, User => UserModel, UserContext }

abstract private[controllers] class LilaController(val env: Env)
extends BaseController
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/Mod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import lila.app._
import lila.chat.Chat
import lila.common.{ EmailAddress, HTTPRequest, IpAddress }
import lila.mod.UserSearch
import lila.report.{ Suspect, Mod => AsMod }
import lila.report.{ Mod => AsMod, Suspect }
import lila.security.{ FingerHash, Granter, Permission }
import lila.user.{ User => UserModel, Title, Holder }
import lila.user.{ Holder, Title, User => UserModel }

final class Mod(
env: Env,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Msg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ final class Msg(
env.msg.api.post(me.id, userId, text) map {
case lila.msg.MsgApi.PostResult.Success => jsonOkResult
case lila.msg.MsgApi.PostResult.Limited => rateLimitedJson
case _ => BadRequest(jsonError("The message was rejected"))
case _ => BadRequest(jsonError("The message was rejected"))
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Puzzle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import lila.common.ApiVersion
import lila.common.config.MaxPerSecond
import lila.puzzle.PuzzleForm.RoundData
import lila.puzzle.PuzzleTheme
import lila.puzzle.{ Result, PuzzleDashboard, PuzzleDifficulty, PuzzleReplay, PuzzleStreak, Puzzle => Puz }
import lila.puzzle.{ Puzzle => Puz, PuzzleDashboard, PuzzleDifficulty, PuzzleReplay, PuzzleStreak, Result }

final class Puzzle(
env: Env,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/RelayRound.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lila.api.Context
import lila.app._

// import lila.common.config.MaxPerSecond
import lila.relay.{ RelayRound => RoundModel, RelayTour => TourModel, RelayRoundForm }
import lila.relay.{ RelayRound => RoundModel, RelayRoundForm, RelayTour => TourModel }
import lila.user.{ User => UserModel }
import views._
import lila.common.HTTPRequest
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/Report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import views._
import lila.api.{ BodyContext, Context }
import lila.app._
import lila.common.HTTPRequest
import lila.report.{ Room, Report => ReportModel, Mod => AsMod, Reporter, Suspect }
import lila.user.{ User => UserModel, Holder }
import lila.report.{ Mod => AsMod, Report => ReportModel, Reporter, Room, Suspect }
import lila.user.{ Holder, User => UserModel }

import play.api.data._

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Round.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import lila.api.Context
import lila.app._
import lila.chat.Chat
import lila.common.HTTPRequest
import lila.game.{ Pov, Game => GameModel, PgnDump }
import lila.game.{ Game => GameModel, PgnDump, Pov }
import lila.swiss.Swiss.{ Id => SwissId }
import lila.tournament.{ Tournament => Tour }
import lila.user.{ User => UserModel }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Swiss.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import views._
import lila.api.Context
import lila.app._
import lila.common.HTTPRequest
import lila.swiss.Swiss.{ Id => SwissId, ChatFor }
import lila.swiss.Swiss.{ ChatFor, Id => SwissId }
import lila.swiss.{ Swiss => SwissModel, SwissForm }
import lila.user.{ User => UserModel }

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/Team.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import lila.common.config.MaxPerSecond
import lila.common.HTTPRequest
import lila.memo.RateLimit
import lila.team.{ Requesting, Team => TeamModel }
import lila.user.{ User => UserModel, Holder }
import lila.user.{ Holder, User => UserModel }

final class Team(
env: Env,
Expand Down Expand Up @@ -588,7 +588,7 @@ final class Team(
msg =>
Right {
PmAllLimitPerTeam[RateLimit.Result](team.id, if (me.isVerifiedOrAdmin) 1 else pmAllCost) {
val url = s"${env.net.baseUrl}${routes.Team.show(team.id)}"
val url = s"${env.net.baseUrl}${routes.Team.show(team.id)}"
val full = s"""$msg
---
You received this because you are subscribed to messages of the team $url."""
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/TheftPrevention.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package controllers

import lila.api.Context
import lila.app._
import lila.game.{ Game => GameModel, Pov, AnonCookie }
import lila.game.{ AnonCookie, Game => GameModel, Pov }
import play.api.mvc._

private[controllers] trait TheftPrevention { self: LilaController =>
Expand All @@ -18,7 +18,7 @@ private[controllers] trait TheftPrevention { self: LilaController =>
case (Some(playerUserId), Some(userId)) => playerUserId != userId
case (None, _) =>
!lila.api.Mobile.Api.requested(ctx.req) &&
!ctx.req.cookies.get(AnonCookie.name).exists(_.value == pov.playerId)
!ctx.req.cookies.get(AnonCookie.name).exists(_.value == pov.playerId)
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/Tournament.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import lila.app._
import lila.common.{ HTTPRequest, Preload }
import lila.hub.LightTeam._
import lila.memo.CacheApi._
import lila.tournament.{ TournamentForm, VisibleTournaments, Tournament => Tour }
import lila.tournament.{ Tournament => Tour, TournamentForm, VisibleTournaments }
import lila.user.{ User => UserModel }

final class Tournament(
Expand Down Expand Up @@ -457,8 +457,8 @@ final class Tournament(
val form = lila.tournament.TeamBattle.DataForm.edit(
teams.map { t =>
s"""${t.id} "${t.name}" by ${env.user.lightUserApi
.sync(t.createdBy)
.fold(t.createdBy)(_.name)}"""
.sync(t.createdBy)
.fold(t.createdBy)(_.name)}"""
},
battle.nbLeaders
)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Ublog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import lila.report.Suspect
final class Ublog(env: Env) extends LilaController(env) {

import views.html.ublog.post.{ editUrlOfPost, urlOfPost }
import views.html.ublog.blog.{ urlOfBlog }
import views.html.ublog.blog.urlOfBlog
import lila.common.paginator.Paginator.zero

def index(username: String, page: Int) = Open { implicit ctx =>
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import lila.app._
import lila.app.mashup.{ GameFilter, GameFilterMenu }
import lila.common.paginator.Paginator
import lila.common.{ HTTPRequest, IpAddress }
import lila.game.{ Pov, Game => GameModel }
import lila.game.{ Game => GameModel, Pov }
import lila.rating.PerfType
import lila.security.UserLogins
import lila.socket.UserLagCache
import lila.user.{ User => UserModel, Holder }
import lila.user.{ Holder, User => UserModel }
import lila.security.Granter

final class User(
Expand Down Expand Up @@ -153,8 +153,8 @@ final class User(
)
else
env.user.repo named username flatMap {
case None if isGranted(_.UserModView) => ctx.me.map(Holder) ?? { modC.searchTerm(_, username.trim) }
case None => notFound
case None if isGranted(_.UserModView) => ctx.me.map(Holder) ?? { modC.searchTerm(_, username.trim) }
case None => notFound
case Some(u) if u.enabled || isGranted(_.UserModView) => f(u)
case Some(u) =>
negotiate(
Expand Down
54 changes: 27 additions & 27 deletions app/mashup/Preload.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,33 @@ final class Preload(
// format: off
case ((((((((((((((data, povs), tours), events), simuls), feat), entries), lead), tWinners), puzzle), streams), playban), blindGames), ublogPosts), lichessMsg) =>
// format: on
(ctx.me ?? currentGameMyTurn(povs, lightUserApi.sync))
.mon(_.lobby segment "currentGame") zip
lightUserApi
.preloadMany(tWinners.map(_.userId) ::: entries.flatMap(_.userIds).toList)
.mon(_.lobby segment "lightUsers") map { case (currentGame, _) =>
Homepage(
data,
entries,
tours,
swiss,
events,
simuls,
feat,
lead,
tWinners,
puzzle,
streams.excludeUsers(events.flatMap(_.hostedBy)),
playban,
currentGame,
simulIsFeaturable,
blindGames,
lobbySocket.counters,
lastPostCache.apply,
ublogPosts,
hasUnreadLichessMessage = lichessMsg
)
}
(ctx.me ?? currentGameMyTurn(povs, lightUserApi.sync))
.mon(_.lobby segment "currentGame") zip
lightUserApi
.preloadMany(tWinners.map(_.userId) ::: entries.flatMap(_.userIds).toList)
.mon(_.lobby segment "lightUsers") map { case (currentGame, _) =>
Homepage(
data,
entries,
tours,
swiss,
events,
simuls,
feat,
lead,
tWinners,
puzzle,
streams.excludeUsers(events.flatMap(_.hostedBy)),
playban,
currentGame,
simulIsFeaturable,
blindGames,
lobbySocket.counters,
lastPostCache.apply,
ublogPosts,
hasUnreadLichessMessage = lichessMsg
)
}
}

def currentGameMyTurn(user: User): Fu[Option[CurrentGame]] =
Expand Down
48 changes: 24 additions & 24 deletions app/mashup/UserInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,30 @@ object UserInfo {
// format: off
case ((((((((((((ratingChart, nbFollowers), nbForumPosts), ublog), nbStudies), trophies), shields), revols), teamIds), isCoach), isStreamer), insightVisible), hasSimul) =>
// format: on
new UserInfo(
user = user,
ranks = userCached.rankingsOf(user.id),
nbs = nbs,
hasSimul = hasSimul,
ratingChart = ratingChart,
nbFollowers = nbFollowers,
nbForumPosts = nbForumPosts,
ublog = ublog,
nbStudies = nbStudies,
trophies = trophies ::: trophyApi.roleBasedTrophies(
user,
Granter(_.PublicMod)(user),
Granter(_.Developer)(user),
Granter(_.Verified)(user),
Granter(_.ContentTeam)(user)
),
shields = shields,
revolutions = revols,
teamIds = teamIds,
isStreamer = isStreamer,
isCoach = isCoach,
insightVisible = insightVisible
)
new UserInfo(
user = user,
ranks = userCached.rankingsOf(user.id),
nbs = nbs,
hasSimul = hasSimul,
ratingChart = ratingChart,
nbFollowers = nbFollowers,
nbForumPosts = nbForumPosts,
ublog = ublog,
nbStudies = nbStudies,
trophies = trophies ::: trophyApi.roleBasedTrophies(
user,
Granter(_.PublicMod)(user),
Granter(_.Developer)(user),
Granter(_.Verified)(user),
Granter(_.ContentTeam)(user)
),
shields = shields,
revolutions = revols,
teamIds = teamIds,
isStreamer = isStreamer,
isCoach = isCoach,
insightVisible = insightVisible
)
}
}
}
4 changes: 2 additions & 2 deletions app/templating/Environment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ object Environment
// #TODO holy shit fix me
// requires injecting all the templates!!
private var envVar: Option[Env] = None
def setEnv(e: Env) = { envVar = Some(e) }
def env: Env = envVar.get
def setEnv(e: Env) = { envVar = Some(e) }
def env: Env = envVar.get

type FormWithCaptcha = (play.api.data.Form[_], lila.common.Captcha)

Expand Down
Loading

0 comments on commit da0c824

Please sign in to comment.