Skip to content

Commit

Permalink
more unused warnings and code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 1, 2023
1 parent 562de56 commit c40628c
Show file tree
Hide file tree
Showing 58 changed files with 133 additions and 202 deletions.
12 changes: 6 additions & 6 deletions app/controllers/Plan.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ final class Plan(env: Env) extends LilaController(env):
}
} yield res

private def indexPayPalPatron(me: UserModel, patron: lila.plan.Patron, subscription: PayPalSubscription)(
implicit ctx: Context
) = for {
pricing <- env.plan.priceApi.pricingOrDefault(myCurrency)
gifts <- env.plan.api.giftsFrom(me)
} yield Ok(html.plan.indexPayPal(me, patron, subscription, pricing, gifts))
private def indexPayPalPatron(me: UserModel, patron: lila.plan.Patron, sub: PayPalSubscription)(using
Context
) =
env.plan.api.giftsFrom(me) map { gifts =>
Ok(html.plan.indexPayPal(me, patron, sub, gifts))
}

private def myCurrency(implicit ctx: Context): Currency =
get("currency") flatMap lila.plan.CurrencyApi.currencyOption getOrElse
Expand Down
1 change: 0 additions & 1 deletion app/controllers/Push.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package controllers

import lila.app.{ given, * }
import lila.push.WebSubscription
import lila.push.WebSubscription.*

final class Push(env: Env) extends LilaController(env):

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Puzzle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ final class Puzzle(env: Env, apiC: => Api) extends LilaController(env):
DashboardPage(u) { implicit ctx => user =>
Reasonable(page) {
env.puzzle.history(user, page) map { history =>
Ok(views.html.puzzle.history(user, page, history))
Ok(views.html.puzzle.history(user, history))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/Tutor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ final class Tutor(env: Env) extends LilaController(env):
}

def openings(username: UserStr, perf: Perf.Key) = TutorPerfPage(username, perf) {
implicit ctx => me => report => perf =>
Ok(views.html.tutor.openings(report, perf, me)).toFuccess
implicit ctx => me => _ => perf =>
Ok(views.html.tutor.openings(perf, me)).toFuccess
}

def opening(username: UserStr, perf: Perf.Key, colName: String, opName: String) =
TutorPerfPage(username, perf) { implicit ctx => me => report => perf =>
TutorPerfPage(username, perf) { implicit ctx => me => _ => perf =>
chess.Color
.fromName(colName)
.fold(Redirect(routes.Tutor.openings(me.username, perf.perf.key)).toFuccess) { color =>
Expand All @@ -41,7 +41,7 @@ final class Tutor(env: Env) extends LilaController(env):
.flatMap(perf.openings(color).find)
.fold(Redirect(routes.Tutor.openings(me.username, perf.perf.key)).toFuccess) { family =>
env.puzzle.opening.find(family.family.key) map { puzzle =>
Ok(views.html.tutor.opening(report, perf, family, color, me, puzzle))
Ok(views.html.tutor.opening(perf, family, color, me, puzzle))
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,14 @@ final class User(
}

val userLoginsFu = env.security.userLogins(user, nbOthers)
val others = for {
val others = for
userLogins <- userLoginsFu
appeals <- env.appeal.api.byUserIds(user.id :: userLogins.otherUserIds)
data <- loginsTableData(user, userLogins, nbOthers)
} yield html.user.mod.otherUsers(holder, user, data, appeals)
yield html.user.mod.otherUsers(holder, user, data, appeals)

val identification = userLoginsFu map { logins =>
Granter.is(_.ViewPrintNoIP)(holder) ??
html.user.mod.identification(holder, user, logins)
Granter.is(_.ViewPrintNoIP)(holder) ?? html.user.mod.identification(logins)
}

val kaladin = isGranted(_.MarkEngine) ?? env.irwin.kaladinApi.get(user).map {
Expand Down
2 changes: 1 addition & 1 deletion app/templating/ChessgroundHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package templating
import chess.{ Board, Color, Pos }
import lila.api.Context

import lila.app.ui.ScalatagsTemplate.{ *, given }
import lila.app.ui.ScalatagsTemplate.*
import lila.game.Pov

trait ChessgroundHelper:
Expand Down
46 changes: 23 additions & 23 deletions app/views/activity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import lila.swiss.Swiss

object activity:

def apply(u: User, as: Iterable[lila.activity.ActivityView])(implicit ctx: Context) =
def apply(u: User, as: Iterable[lila.activity.ActivityView])(using Context) =
div(cls := "activity")(
as.toSeq filterNot (_.isEmpty) map { a =>
st.section(
Expand Down Expand Up @@ -48,7 +48,7 @@ object activity:

private def subCount(count: Int) = if (count >= maxSubEntries) s"$count+" else s"$count"

private def renderPatron(p: Patron)(implicit ctx: Context) =
private def renderPatron(p: Patron)(using Context) =
div(cls := "entry plan")(
iconTag(""),
div(
Expand All @@ -58,7 +58,7 @@ object activity:
)
)

private def renderPractice(p: Map[lila.practice.PracticeStudy, Int])(implicit ctx: Context) =
private def renderPractice(p: Map[lila.practice.PracticeStudy, Int])(using Context) =
val ps = p.toSeq.sortBy(-_._2)
entryTag(
iconTag(""),
Expand All @@ -71,7 +71,7 @@ object activity:
)
)

private def onePractice(tup: (lila.practice.PracticeStudy, Int))(implicit ctx: Context) =
private def onePractice(tup: (lila.practice.PracticeStudy, Int))(using Context) =
tup match
case (study, nb) =>
val href = routes.Practice.show("-", study.slug, study.id)
Expand All @@ -80,7 +80,7 @@ object activity:
br
)

private def renderPuzzles(u: User)(p: Puzzles)(implicit ctx: Context) =
private def renderPuzzles(u: User)(p: Puzzles)(using ctx: Context) =
entryTag(
iconTag(""),
scoreFrag(p.value),
Expand All @@ -90,7 +90,7 @@ object activity:
)
)

private def renderStorm(s: Storm)(implicit ctx: Context) =
private def renderStorm(s: Storm)(using Context) =
entryTag(
iconTag(""),
scoreTag(winTag(trans.storm.highscoreX(strong(s.score)))),
Expand All @@ -100,7 +100,7 @@ object activity:
)
)

private def renderRacer(s: Racer)(implicit ctx: Context) =
private def renderRacer(s: Racer)(using Context) =
entryTag(
iconTag(""),
scoreTag(winTag(trans.storm.highscoreX(strong(s.score)))),
Expand All @@ -110,7 +110,7 @@ object activity:
)
)

private def renderStreak(s: Streak)(implicit ctx: Context) =
private def renderStreak(s: Streak)(using Context) =
entryTag(
iconTag(""),
scoreTag(winTag(trans.storm.highscoreX(strong(s.score)))),
Expand All @@ -120,7 +120,7 @@ object activity:
)
)

private def renderGames(games: Games)(implicit ctx: Context) =
private def renderGames(games: Games)(using Context) =
games.value.toSeq.sortBy(-_._2.size).map { case (pt, score) =>
entryTag(
iconTag(pt.iconChar),
Expand All @@ -132,7 +132,7 @@ object activity:
)
}

private def renderForumPosts(posts: Map[lila.forum.ForumTopic, List[lila.forum.ForumPost]])(implicit
private def renderForumPosts(posts: Map[lila.forum.ForumTopic, List[lila.forum.ForumPost]])(using
ctx: Context
) =
ctx.noKid option entryTag(
Expand Down Expand Up @@ -171,7 +171,7 @@ object activity:
)
)

private def renderCorresMoves(nb: Int, povs: List[lila.game.LightPov])(implicit ctx: Context) =
private def renderCorresMoves(nb: Int, povs: List[lila.game.LightPov])(using Context) =
entryTag(
iconTag(""),
div(
Expand All @@ -191,7 +191,7 @@ object activity:
)
)

private def renderCorresEnds(score: Score, povs: List[lila.game.LightPov])(implicit ctx: Context) =
private def renderCorresEnds(score: Score, povs: List[lila.game.LightPov])(using Context) =
entryTag(
iconTag(""),
div(
Expand All @@ -217,7 +217,7 @@ object activity:
)
)

private def renderFollows(all: Follows)(implicit ctx: Context) =
private def renderFollows(all: Follows)(using Context) =
entryTag(
iconTag(""),
div(
Expand All @@ -236,7 +236,7 @@ object activity:
)
)

private def renderSimuls(u: User)(simuls: List[lila.simul.Simul])(implicit ctx: Context) =
private def renderSimuls(u: User)(simuls: List[lila.simul.Simul])(using Context) =
entryTag(
iconTag(""),
div(
Expand All @@ -263,7 +263,7 @@ object activity:
)
)

private def renderStudies(studies: List[lila.study.Study.IdName])(implicit ctx: Context) =
private def renderStudies(studies: List[lila.study.Study.IdName])(using Context) =
entryTag(
iconTag(""),
div(
Expand All @@ -276,7 +276,7 @@ object activity:
)
)

private def renderTeams(teams: Teams)(implicit ctx: Context) =
private def renderTeams(teams: Teams)(using ctx: Context) =
ctx.noKid option entryTag(
iconTag(""),
div(
Expand All @@ -285,7 +285,7 @@ object activity:
)
)

private def renderTours(tours: lila.activity.ActivityView.Tours)(implicit ctx: Context) =
private def renderTours(tours: lila.activity.ActivityView.Tours)(using Context) =
entryTag(
iconTag(""),
div(
Expand Down Expand Up @@ -313,7 +313,7 @@ object activity:
)
)

private def renderSwisses(swisses: List[(Swiss.IdName, Rank)])(implicit ctx: Context) =
private def renderSwisses(swisses: List[(Swiss.IdName, Rank)])(using Context) =
entryTag(
iconTag(""),
div(
Expand All @@ -338,13 +338,13 @@ object activity:
)
)

private def renderStream(u: User)(implicit ctx: Context) =
private def renderStream(u: User)(using ctx: Context) =
ctx.noKid option entryTag(
iconTag(""),
a(href := routes.Streamer.redirect(u.username))(trans.activity.hostedALiveStream())
)

private def renderSignup(implicit ctx: Context) =
private def renderSignup(using Context) =
entryTag(
iconTag(""),
div(trans.activity.signedUp())
Expand All @@ -355,7 +355,7 @@ object activity:
private val scoreTag = tag("score")
private val winTag = tag("win")

private def scoreFrag(s: Score)(implicit ctx: Context) =
private def scoreFrag(s: Score)(using Context) =
raw {
s"""<score>${scoreStr("win", s.win, trans.nbWins)}${scoreStr("draw", s.draw, trans.nbDraws)}${scoreStr(
"loss",
Expand All @@ -364,10 +364,10 @@ object activity:
)}</score>"""
}

private def ratingProgFrag(r: RatingProg)(implicit ctx: Context) =
private def ratingProgFrag(r: RatingProg)(using ctx: Context) =
ctx.pref.showRatings option ratingTag(r.after.value, ratingProgress(r.diff))

private def scoreStr(tag: String, p: Int, name: lila.i18n.I18nKey)(implicit ctx: Context) =
private def scoreStr(tag: String, p: Int, name: lila.i18n.I18nKey)(using Context) =
if (p == 0) ""
else s"""<$tag>${wrapNumber(name.pluralSameTxt(p))}</$tag>"""

Expand Down
31 changes: 9 additions & 22 deletions app/views/appeal/tree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object tree:
val excludedFromLeaderboards = "Your account has been excluded from leaderboards.";
val closedByModerators = "Your account was closed by moderators.";

private def cleanMenu(implicit ctx: Context): Branch =
private def cleanMenu(using Context): Branch =
Branch(
"root",
cleanAllGood,
Expand Down Expand Up @@ -68,7 +68,7 @@ object tree:
)
)

private def engineMenu(implicit ctx: Context): Branch =
private def engineMenu(using Context): Branch =
val accept =
"I accept that I used outside assistance in my games."
val deny =
Expand Down Expand Up @@ -110,7 +110,7 @@ object tree:
).some
)

private def boostMenu(implicit ctx: Context): Branch =
private def boostMenu(using Context): Branch =
val accept = "I accept that I manipulated my rating."
val acceptFull =
"I accept that I deliberately manipulated my rating by losing games on purpose, or by playing another account that was deliberately losing games. I am sorry and I would like another chance."
Expand Down Expand Up @@ -144,7 +144,7 @@ object tree:
).some
)

private def muteMenu(implicit ctx: Context): Branch =
private def muteMenu(using Context): Branch =
val accept = "I accept that I have not followed the communication guidelines"
val acceptFull =
"I accept that I have not followed the communication guidelines. I will behave better in future, please give me another chance."
Expand Down Expand Up @@ -183,7 +183,7 @@ object tree:
).some
)

private def rankBanMenu(implicit ctx: Context): Branch =
private def rankBanMenu(using Context): Branch =
val accept = "I accept that I have manipulated my account to get on the leaderboard."
val deny =
"I deny having manipulated my account to get on the leaderboard."
Expand Down Expand Up @@ -213,7 +213,7 @@ object tree:
).some
)

private def playbanMenu(implicit ctx: Context): Branch =
private def playbanMenu: Branch =
Branch(
"root",
"You have a play timeout.",
Expand Down Expand Up @@ -259,7 +259,7 @@ object tree:
)
)

private def altScreen(implicit ctx: Context) = div(cls := "leaf")(
private def altScreen(using Context) = div(cls := "leaf")(
h2(closedByModerators),
div(cls := "content")(
p("Did you create multiple accounts? If so, remember that you promised not to, on the sign up page."),
Expand All @@ -274,7 +274,7 @@ object tree:
newAppeal()
)

def apply(me: User, playban: Boolean)(implicit ctx: Context) =
def apply(me: User, playban: Boolean)(using ctx: Context) =
bits.layout("Appeal a moderation decision") {
val query = isGranted(_.Appeals) ?? ctx.req.queryString.toMap
val isMarked = playban || me.marks.engine || me.marks.boost || me.marks.troll || me.marks.rankban
Expand Down Expand Up @@ -315,23 +315,10 @@ object tree:
p("Please be honest, concise, and on point.")
)

private def newAppeal(preset: String = "")(implicit ctx: Context) =
private def newAppeal(preset: String = "")(using Context) =
discussion.renderForm(
lila.appeal.Appeal.form.fill(preset),
action = appealRoutes.post.url,
isNew = true,
presets = none
)

private def renderHelp =
div(cls := "appeal__help")(
p(
"If your account has been restricted for violation of ",
a(href := routes.Page.tos)("the Lichess rules"),
" you may file an appeal here."
),
p(
"You can read more about the appeal process ",
a(href := routes.Page.loneBookmark("appeal"))("here.")
)
)
2 changes: 1 addition & 1 deletion app/views/base/embed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package views.html.base
import lila.app.templating.Environment.{ given, * }
import lila.app.ui.EmbedConfig
import lila.app.ui.EmbedConfig.given
import lila.app.ui.ScalatagsTemplate.{ *, given }
import lila.app.ui.ScalatagsTemplate.*
import lila.pref.SoundSet

object embed:
Expand Down
Loading

0 comments on commit c40628c

Please sign in to comment.