Skip to content

Commit 595602d

Browse files
committed
Get rid of unnecessary foldLefts and shutdownClient
1 parent aad721f commit 595602d

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

bot/src/dotty/tools/bot/PullRequestService.scala

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ trait PullRequestService {
8484
def reviewUrl(issueNbr: Int): String =
8585
s"$githubUrl/repos/lampepfl/dotty/pulls/$issueNbr/reviews"
8686

87-
def shutdownClient(client: Client): Task[Unit] =
88-
client.shutdownNow().pure[Task]
89-
9087
sealed trait CommitStatus {
9188
def commit: Commit
9289
def isValid: Boolean
@@ -207,7 +204,7 @@ trait PullRequestService {
207204
=> false
208205
}
209206

210-
wrongTense || firstLine.last == '.' || firstLine.length > 100
207+
wrongTense || firstLine.last == '.' || firstLine.length > 80
211208
}
212209

213210
def sendInitialComment(issueNbr: Int, invalidUsers: List[String], commits: List[Commit], client: Client): Task[ReviewResponse] = {
@@ -235,7 +232,7 @@ trait PullRequestService {
235232
|
236233
|> 1. Separate subject from body with a blank line
237234
|> 1. When fixing an issue, start your commit message with `Fix #<ISSUE-NBR>: `
238-
|> 1. Limit the subject line to 80 characters
235+
|> 1. Limit the subject line to 72 characters
239236
|> 1. Capitalize the subject line
240237
|> 1. Do not end the subject line with a period
241238
|> 1. Use the imperative mood in the subject line ("Added" instead of "Add")
@@ -288,7 +285,7 @@ trait PullRequestService {
288285

289286
// Send positive comment:
290287
_ <- sendInitialComment(issue.number, invalidUsers, commits, httpClient)
291-
_ <- shutdownClient(httpClient)
288+
_ <- httpClient.shutdown
292289
resp <- Ok("Fresh PR checked")
293290
} yield resp
294291

@@ -331,10 +328,10 @@ trait PullRequestService {
331328
cancellable = statuses.filter(status => status.state == "pending" && status.context == droneContext)
332329
runningJobs = cancellable.map(_.target_url.split('/').last.toInt)
333330
cancelled <- Task.gatherUnordered(runningJobs.map(Drone.stopBuild(_, droneToken)))
334-
} yield cancelled.foldLeft(true)(_ == _)
331+
} yield cancelled.forall(identity)
335332
}
336333
}
337-
.map(xs => xs.foldLeft(true)(_ == _))
334+
.map(_.forall(identity))
338335

339336
def checkSynchronize(issue: Issue): Task[Response] = {
340337
implicit val httpClient = PooledHttp1Client()
@@ -353,7 +350,7 @@ trait PullRequestService {
353350
else
354351
setStatus(statuses.last, httpClient)
355352
}
356-
_ <- shutdownClient(httpClient)
353+
_ <- httpClient.shutdown
357354
resp <- Ok("Updated PR checked")
358355
} yield resp
359356
}
@@ -421,7 +418,16 @@ trait PullRequestService {
421418
def extractMention(body: String): Option[String] =
422419
body.lines.find(_.startsWith("@dotty-bot:"))
423420

424-
/** TODO: The implementation here could be quite elegant if we used a trie instead */
421+
/** Try to make sense of what the user is requesting from the bot
422+
*
423+
* The bot's abilities currently only include:
424+
*
425+
* - Checking or re-checking the CLA
426+
* - Restarting the CI tests
427+
*
428+
* @note The implementation here could be quite elegant if we used a trie
429+
* instead
430+
*/
425431
def interpretMention(line: String, issueComment: IssueComment): Task[Response] = {
426432
val loweredLine = line.toLowerCase
427433
if (loweredLine.contains("check cla") || loweredLine.contains("check the cla"))

0 commit comments

Comments
 (0)