scapegoat code review

scapegoat
Thibault Duplessis 2019-12-08 23:54:33 -06:00
parent 904e6a8c59
commit 4cc3c8c3ec
8 changed files with 9 additions and 12 deletions

View File

@ -58,7 +58,7 @@ object BinaryFormat {
case (i1, i2) => (i1 + i2) / 2
} toVector
private val decodeMap: Map[Int, MT] = buckets.view.zipWithIndex.map(x => x._2 -> x._1).to(Map)
private val decodeMap: Map[Int, MT] = buckets.view.zipWithIndex.map(x => x._2 -> x._1).toMap
def write(mts: Vector[Centis]): ByteArray = {
def enc(mt: Centis) = encodeCutoffs.search(mt.centis).insertionPoint
@ -69,11 +69,11 @@ object BinaryFormat {
}
def read(ba: ByteArray, turns: Int): Vector[Centis] = {
def dec(x: Int) = decodeMap get x getOrElse decodeMap(size - 1)
def dec(x: Int) = decodeMap.getOrElse(x, decodeMap(size - 1))
ba.value map toInt flatMap { k =>
Array(dec(k >> 4), dec(k & 15))
}
}.view.take(turns).map(Centis.apply).to(Vector)
}.view.take(turns).map(Centis.apply).toVector
}
case class clock(start: Timestamp) {

View File

@ -2,7 +2,6 @@ package lila.game
import play.api.libs.json._
import chess.Pos
import chess.variant.Crazyhouse
import chess.{ Centis, PromotableRole, Pos, Color, Situation, Move => ChessMove, Drop => ChessDrop, Clock => ChessClock, Status }
import JsonView._

View File

@ -205,14 +205,13 @@ case class Game(
val events = moveOrDrop.fold(
Event.Move(_, game.situation, state, clockEvent, updated.board.crazyData),
Event.Drop(_, game.situation, state, clockEvent, updated.board.crazyData)
) ::
{
) :: {
// abstraction leak, I know.
(updated.board.variant.threeCheck && game.situation.check) ?? List(Event.CheckCount(
white = updated.history.checkCount.white,
black = updated.history.checkCount.black
))
}.toList
}
Progress(this, updated, events)
}

View File

@ -4,7 +4,6 @@ import chess.format.Forsyth
import chess.variant._
import chess.{ Game => ChessGame, Board, Color => ChessColor, Castles, Clock, Situation }
import ChessColor.{ White, Black }
import com.github.blemale.scaffeine.Cache
import com.github.blemale.scaffeine.{ Cache, Scaffeine }
import scala.concurrent.duration._

View File

@ -38,7 +38,7 @@ final class SelfReport(
// user.ifTrue(!known && name != "ceval") ?? { u =>
// Env.report.api.autoBotReport(u.id, referer, name)
// }
def doLog = if (name != "ceval") {
def doLog(): Unit = if (name != "ceval") {
lila.log("cheat").branch("jslog").info(
s"$ip https://lichess.org/$fullId ${user.fold("anon")(_.id)} $name"
)

View File

@ -52,7 +52,7 @@ private object DisposableEmailDomain {
private val whitelist = Set(
/* Default domains included */
"aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
"aol.com", "att.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
"google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
"live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk", "protonmail.com", "protonmail.ch",

View File

@ -26,7 +26,7 @@ object FingerHash {
private def normalize(fp: FingerPrint): String = {
val str = fp.value.replace("-", "")
if (str.size % 2 == 1) s"${str}0" else str
if (str.size % 2 != 0) s"${str}0" else str
}
val impersonate = FingerHash("imperson")

View File

@ -103,7 +103,7 @@ final class RemoteSocket(
})
val subPromise = Promise[Unit]
conn.async.subscribe(channel).thenRun {
new Runnable { def run = subPromise.success(()) }
new Runnable { def run() = subPromise.success(()) }
}
subPromise.future
}