Merge pull request #108 from scala-steward/update/scalafmt-core-3.0.8

Update scalafmt-core to 3.0.8
This commit is contained in:
hrj 2021-12-16 07:17:22 +05:30 committed by GitHub
commit 6cb10f409b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 36 deletions

View File

@ -1,3 +1,3 @@
version="3.0.5" version="3.0.8"
maxColumn = 120 maxColumn = 120
runner.dialect = scala213source3 runner.dialect = scala213source3

View File

@ -16,7 +16,13 @@ object LCFramework {
val captcha = new Captcha(config = config, captchaProviders = captchaProviders) val captcha = new Captcha(config = config, captchaProviders = captchaProviders)
val backgroundTask = new BackgroundTask(config = config, captcha = captcha) val backgroundTask = new BackgroundTask(config = config, captcha = captcha)
backgroundTask.beginThread(delay = config.threadDelay) backgroundTask.beginThread(delay = config.threadDelay)
val server = new Server(address = config.address, port = config.port, captcha = captcha, playgroundEnabled = config.playgroundEnabled, corsHeader = config.corsHeader) val server = new Server(
address = config.address,
port = config.port,
captcha = captcha,
playgroundEnabled = config.playgroundEnabled,
corsHeader = config.corsHeader
)
server.start() server.start()
} }
} }
@ -31,8 +37,7 @@ object MakeSamples {
val config = new Config(configFilePath) val config = new Config(configFilePath)
val captchaProviders = new CaptchaProviders(config = config) val captchaProviders = new CaptchaProviders(config = config)
val samples = captchaProviders.generateChallengeSamples() val samples = captchaProviders.generateChallengeSamples()
samples.foreach { samples.foreach { case (key, sample) =>
case (key, sample) =>
val extensionMap = Map("image/png" -> "png", "image/gif" -> "gif") val extensionMap = Map("image/png" -> "png", "image/gif" -> "gif")
println(key + ": " + sample) println(key + ": " + sample)

View File

@ -13,7 +13,9 @@ import lc.captchas.interfaces.Challenge
import lc.captchas.interfaces.ChallengeProvider import lc.captchas.interfaces.ChallengeProvider
import lc.misc.PngImageWriter import lc.misc.PngImageWriter
/** This captcha is only for debugging purposes. It creates very simple captchas that are deliberately easy to solve with OCR engines */ /** This captcha is only for debugging purposes. It creates very simple captchas that are deliberately easy to solve
* with OCR engines
*/
class DebugCaptcha extends ChallengeProvider { class DebugCaptcha extends ChallengeProvider {
def getId(): String = { def getId(): String = {
@ -26,9 +28,12 @@ class DebugCaptcha extends ChallengeProvider {
def supportedParameters(): Map[String, List[String]] = { def supportedParameters(): Map[String, List[String]] = {
Map.of( Map.of(
"supportedLevels", List.of("debug"), "supportedLevels",
"supportedMedia", List.of("image/png"), List.of("debug"),
"supportedInputType", List.of("text") "supportedMedia",
List.of("image/png"),
"supportedInputType",
List.of("text")
) )
} }

View File

@ -20,9 +20,12 @@ class FilterChallenge extends ChallengeProvider {
def supportedParameters(): JavaMap[String, JavaList[String]] = { def supportedParameters(): JavaMap[String, JavaList[String]] = {
JavaMap.of( JavaMap.of(
"supportedLevels",JavaList.of("medium", "hard"), "supportedLevels",
"supportedMedia", JavaList.of("image/png"), JavaList.of("medium", "hard"),
"supportedInputType", JavaList.of("text") "supportedMedia",
JavaList.of("image/png"),
"supportedInputType",
JavaList.of("text")
) )
} }

View File

@ -31,9 +31,12 @@ class LabelCaptcha extends ChallengeProvider {
def supportedParameters(): JavaMap[String, JavaList[String]] = { def supportedParameters(): JavaMap[String, JavaList[String]] = {
JavaMap.of( JavaMap.of(
"supportedLevels", JavaList.of("hard"), "supportedLevels",
"supportedMedia", JavaList.of("image/png"), JavaList.of("hard"),
"supportedInputType", JavaList.of("text") "supportedMedia",
JavaList.of("image/png"),
"supportedInputType",
JavaList.of("text")
) )
} }

View File

@ -38,9 +38,12 @@ class RainDropsCP extends ChallengeProvider {
def supportedParameters(): JavaMap[String, JavaList[String]] = { def supportedParameters(): JavaMap[String, JavaList[String]] = {
JavaMap.of( JavaMap.of(
"supportedLevels", JavaList.of("medium", "easy"), "supportedLevels",
"supportedMedia", JavaList.of("image/gif"), JavaList.of("medium", "easy"),
"supportedInputType", JavaList.of("text") "supportedMedia",
JavaList.of("image/gif"),
"supportedInputType",
JavaList.of("text")
) )
} }

View File

@ -18,8 +18,7 @@ class CaptchaProviders(config: Config) {
) )
def generateChallengeSamples(): Map[String, Challenge] = { def generateChallengeSamples(): Map[String, Challenge] = {
providers.map { providers.map { case (key, provider) =>
case (key, provider) =>
(key, provider.returnChallenge()) (key, provider.returnChallenge())
} }
} }

View File

@ -49,8 +49,8 @@ class Config(configFilePath: String) {
val corsHeader: String = (configJson \ AttributesEnum.CORS_HEADER.toString).extract[String] val corsHeader: String = (configJson \ AttributesEnum.CORS_HEADER.toString).extract[String]
private val captchaConfigJson = (configJson \ "captchas") private val captchaConfigJson = (configJson \ "captchas")
val captchaConfigTransform: JValue = captchaConfigJson transformField { val captchaConfigTransform: JValue = captchaConfigJson transformField { case JField("config", JObject(config)) =>
case JField("config", JObject(config)) => ("config", JString(config.toString)) ("config", JString(config.toString))
} }
val captchaConfig: List[CaptchaConfig] = captchaConfigTransform.extract[List[CaptchaConfig]] val captchaConfig: List[CaptchaConfig] = captchaConfigTransform.extract[List[CaptchaConfig]]
val allowedLevels: Set[String] = captchaConfig.flatMap(_.allowedLevels).toSet val allowedLevels: Set[String] = captchaConfig.flatMap(_.allowedLevels).toSet

View File

@ -66,7 +66,10 @@ class Server(address: String, port: Int, captcha: Captcha, playgroundEnabled: Bo
val server: picoserve.Server = serverBuilder.build() val server: picoserve.Server = serverBuilder.build()
private def getResponse(response: Either[Error, ByteConvert], responseHeaders: util.Map[String, util.List[String]]): ByteResponse = { private def getResponse(
response: Either[Error, ByteConvert],
responseHeaders: util.Map[String, util.List[String]]
): ByteResponse = {
response match { response match {
case Right(value) => { case Right(value) => {
new ByteResponse(200, value.toBytes(), responseHeaders) new ByteResponse(200, value.toBytes(), responseHeaders)