Skip to content

Commit d7e413c

Browse files
authored
Merge pull request #335 from scala-steward/update/scalafmt-core-3.11.0
Update scalafmt-core to 3.11.0
2 parents a4acba3 + 41dad5b commit d7e413c

6 files changed

Lines changed: 68 additions & 58 deletions

File tree

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ ecfbaf459af23ed5981aa3b030425f67dece7f9e
99

1010
# Scala Steward: Reformat with scalafmt 3.9.7
1111
cb2021ce0648edfbf4bb45f2962562820c7b677b
12+
13+
# Scala Steward: Reformat with scalafmt 3.11.0
14+
f17d63754ce806a77e5a57c99dcc7b7cc7f1a5ca

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version="3.10.7"
1+
version="3.11.0"
22
maxColumn = 120
33
runner.dialect = scala3

src/main/scala/lc/captchas/CrumpledTextCaptcha.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class CrumpledTextCaptcha extends ChallengeProvider {
3535
def returnChallenge(level: String, size: String): Challenge = {
3636
val r = new scala.util.Random
3737
val n = level match {
38-
case "easy" => 5
38+
case "easy" => 5
3939
case "medium" => 6
40-
case "hard" => 7
41-
case _ => 6
40+
case "hard" => 7
41+
case _ => 6
4242
}
4343
val characters = if (level == "hard") HelperFunctions.safeCharacters else HelperFunctions.safeAlphaNum
4444
val secret = LazyList.continually(r.nextInt(characters.size)).map(characters).take(n).mkString
@@ -71,13 +71,13 @@ class CrumpledTextCaptcha extends ChallengeProvider {
7171

7272
var img = canvas
7373
val numFolds = level match {
74-
case "easy" => 7
75-
case "medium" => 14
76-
case "hard" => 19
77-
case _ => 14
74+
case "easy" => 7
75+
case "medium" => 14
76+
case "hard" => 19
77+
case _ => 14
7878
}
7979
for (_ <- 0 until numFolds) {
80-
img = applyFold(img, r)
80+
img = applyFold(img, r)
8181
}
8282

8383
val baos = new ByteArrayOutputStream()
@@ -126,27 +126,27 @@ class CrumpledTextCaptcha extends ChallengeProvider {
126126
val rgb01 = img.getRGB(xf, yf + 1)
127127
val rgb11 = img.getRGB(xf + 1, yf + 1)
128128

129-
val r00 = (rgb00 >> 16) & 0xFF
130-
val g00 = (rgb00 >> 8) & 0xFF
131-
val b00 = rgb00 & 0xFF
132-
val r10 = (rgb10 >> 16) & 0xFF
133-
val g10 = (rgb10 >> 8) & 0xFF
134-
val b10 = rgb10 & 0xFF
135-
val r01 = (rgb01 >> 16) & 0xFF
136-
val g01 = (rgb01 >> 8) & 0xFF
137-
val b01 = rgb01 & 0xFF
138-
val r11 = (rgb11 >> 16) & 0xFF
139-
val g11 = (rgb11 >> 8) & 0xFF
140-
val b11 = rgb11 & 0xFF
129+
val r00 = (rgb00 >> 16) & 0xff
130+
val g00 = (rgb00 >> 8) & 0xff
131+
val b00 = rgb00 & 0xff
132+
val r10 = (rgb10 >> 16) & 0xff
133+
val g10 = (rgb10 >> 8) & 0xff
134+
val b10 = rgb10 & 0xff
135+
val r01 = (rgb01 >> 16) & 0xff
136+
val g01 = (rgb01 >> 8) & 0xff
137+
val b01 = rgb01 & 0xff
138+
val r11 = (rgb11 >> 16) & 0xff
139+
val g11 = (rgb11 >> 8) & 0xff
140+
val b11 = rgb11 & 0xff
141141

142142
val rInterp = (r00 * (1 - xt) * (1 - yt) + r10 * xt * (1 - yt) + r01 * (1 - xt) * yt + r11 * xt * yt).toInt
143143
val gInterp = (g00 * (1 - xt) * (1 - yt) + g10 * xt * (1 - yt) + g01 * (1 - xt) * yt + g11 * xt * yt).toInt
144144
val bInterp = (b00 * (1 - xt) * (1 - yt) + b10 * xt * (1 - yt) + b01 * (1 - xt) * yt + b11 * xt * yt).toInt
145145

146-
val rgb = (0xFF << 24) | (rInterp << 16) | (gInterp << 8) | bInterp
146+
val rgb = (0xff << 24) | (rInterp << 16) | (gInterp << 8) | bInterp
147147
newImg.setRGB(x, y, rgb)
148148
} else {
149-
newImg.setRGB(x, y, 0xFFFFFFFF)
149+
newImg.setRGB(x, y, 0xffffffff)
150150
}
151151
} else {
152152
newImg.setRGB(x, y, img.getRGB(x, y))

src/main/scala/lc/core/config.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Config(configFilePath: String) {
3838
private val appConfigEither = AppConfig.codec.decode(ByteBuffer.wrap(configString.getBytes("UTF-8")))
3939
private val appConfig = appConfigEither match {
4040
case Right(conf) => conf
41-
case Left(err) => throw new Exception(err.toString)
41+
case Left(err) => throw new Exception(err.toString)
4242
}
4343
private val configFields: ConfigField = appConfig.toConfigField
4444

@@ -121,5 +121,4 @@ class Config(configFilePath: String) {
121121

122122
}
123123

124-
object Config {
125-
}
124+
object Config {}

src/main/scala/lc/core/models.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,16 @@ case class AppConfig(
9999
captchas: List[CaptchaConfig] = List.empty
100100
) {
101101
def toConfigField: ConfigField = ConfigField(
102-
port, address, bufferCount, seed, captchaExpiryTimeLimit,
103-
threadDelay, playgroundEnabled, corsHeader, maxAttemptsRatio, authRequired
102+
port,
103+
address,
104+
bufferCount,
105+
seed,
106+
captchaExpiryTimeLimit,
107+
threadDelay,
108+
playgroundEnabled,
109+
corsHeader,
110+
maxAttemptsRatio,
111+
authRequired
104112
)
105113
}
106114
object AppConfig {

src/test/scala/lc/ServerAuthSpec.scala

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,40 @@ class ServerAuthSpec extends AnyFunSuite {
1919
val url = new URL("http://localhost:8889/v2/captcha")
2020

2121
// 1. Test without auth header
22-
val connection1 = url.openConnection().asInstanceOf[HttpURLConnection]
23-
connection1.setRequestMethod("POST")
24-
connection1.setRequestProperty("Content-Type", "application/json")
25-
connection1.setDoOutput(true)
26-
val payload = """{"level":"debug","media":"image/png","input_type":"text","size":"350x100"}"""
27-
val out1 = new OutputStreamWriter(connection1.getOutputStream)
28-
out1.write(payload)
29-
out1.close()
22+
val connection1 = url.openConnection().asInstanceOf[HttpURLConnection]
23+
connection1.setRequestMethod("POST")
24+
connection1.setRequestProperty("Content-Type", "application/json")
25+
connection1.setDoOutput(true)
26+
val payload = """{"level":"debug","media":"image/png","input_type":"text","size":"350x100"}"""
27+
val out1 = new OutputStreamWriter(connection1.getOutputStream)
28+
out1.write(payload)
29+
out1.close()
3030

31-
var responseCode = connection1.getResponseCode
32-
assert(responseCode == 401, s"Expected 401 but got $responseCode")
31+
var responseCode = connection1.getResponseCode
32+
assert(responseCode == 401, s"Expected 401 but got $responseCode")
3333

34-
// 2. Test with invalid auth header
35-
val connection2 = url.openConnection().asInstanceOf[HttpURLConnection]
36-
connection2.setRequestMethod("POST")
37-
connection2.setRequestProperty("Content-Type", "application/json")
38-
connection2.setRequestProperty("Auth", "wrongsecret")
39-
connection2.setDoOutput(true)
40-
val out2 = new OutputStreamWriter(connection2.getOutputStream)
41-
out2.write(payload)
42-
out2.close()
34+
// 2. Test with invalid auth header
35+
val connection2 = url.openConnection().asInstanceOf[HttpURLConnection]
36+
connection2.setRequestMethod("POST")
37+
connection2.setRequestProperty("Content-Type", "application/json")
38+
connection2.setRequestProperty("Auth", "wrongsecret")
39+
connection2.setDoOutput(true)
40+
val out2 = new OutputStreamWriter(connection2.getOutputStream)
41+
out2.write(payload)
42+
out2.close()
4343

44-
responseCode = connection2.getResponseCode
45-
assert(responseCode == 401, s"Expected 401 but got $responseCode")
44+
responseCode = connection2.getResponseCode
45+
assert(responseCode == 401, s"Expected 401 but got $responseCode")
4646

47-
// 3. Test with valid auth header
48-
val connection3 = url.openConnection().asInstanceOf[HttpURLConnection]
49-
connection3.setRequestMethod("POST")
50-
connection3.setRequestProperty("Content-Type", "application/json")
51-
connection3.setRequestProperty("Auth", "secret123")
52-
connection3.setDoOutput(true)
53-
val out3 = new OutputStreamWriter(connection3.getOutputStream)
54-
out3.write(payload)
55-
out3.close()
47+
// 3. Test with valid auth header
48+
val connection3 = url.openConnection().asInstanceOf[HttpURLConnection]
49+
connection3.setRequestMethod("POST")
50+
connection3.setRequestProperty("Content-Type", "application/json")
51+
connection3.setRequestProperty("Auth", "secret123")
52+
connection3.setDoOutput(true)
53+
val out3 = new OutputStreamWriter(connection3.getOutputStream)
54+
out3.write(payload)
55+
out3.close()
5656

5757
responseCode = connection3.getResponseCode
5858
assert(responseCode == 200, s"Expected 200 but got $responseCode")

0 commit comments

Comments
 (0)