Add parentheses (#9000)

This commit is contained in:
kenji yoshida 2026-04-01 02:48:59 +09:00 committed by GitHub
parent f2ce52e985
commit 6d44aca9b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 23 additions and 23 deletions

View File

@ -236,7 +236,7 @@ private[sbt] case class SbtParser(path: VirtualFileRef, lines: Seq[String])
|$code
|}""".stripMargin
val fileName = path.id
val reporterId = s"$fileName-${Random.nextInt}"
val reporterId = s"$fileName-${Random.nextInt()}"
val sourceFile = SourceFile(
VirtualFile(reporterId, wrapCode.getBytes(StandardCharsets.UTF_8)),
scala.io.Codec.UTF8

View File

@ -29,7 +29,7 @@ object SbtParserErrorSpec extends AbstractSpec {
print(s"Processing ${file.getFileName}: ")
val vf = converter.toVirtualFile(file)
val buildSbt = Source.fromFile(file.toUri).getLines.toSeq
val buildSbt = Source.fromFile(file.toUri).getLines().toSeq
val message = interceptMessageException(SbtParser(vf, buildSbt))
println(message)
assert(message.contains(file.getFileName.toString))

View File

@ -179,9 +179,9 @@ trait ShellScriptUtil extends BasicTestSuite {
BasicIO.processFully(processLine)
)
)
if p.exitValue != 0 then
if p.exitValue() != 0 then
lines.foreach(l => Console.err.println(l))
sys.error(s"process exit with ${p.exitValue}")
sys.error(s"process exit with ${p.exitValue()}")
f(lines.toList)
()
finally

View File

@ -215,7 +215,7 @@ private class React(
case NonFatal(_) => ()
override def notifyExit(p: Process): Unit =
if !process.isAlive && !promise.isCompleted then
if !process.isAlive() && !promise.isCompleted then
val exitCode = process.exitValue()
if exitCode != 0 then
promise.failure(new RuntimeException(s"Forked test process exited with code $exitCode"))

View File

@ -109,7 +109,7 @@ class WorkerProxy(
input.close()
serverSocket.foreach(_.close())
def blockForExitCode(): Int =
if !process.isAlive then process.exitValue()
if !process.isAlive() then process.exitValue()
else Fork.blockForExitCode(process)
/** print a line into stdin of the worker process. */

View File

@ -68,7 +68,7 @@ private[sbt] abstract class AbstractTaskExecuteProgress(
timings.forEach { (task, timing) =>
if (timing.isActive) result += task -> (now - timing.startNanos).nanos
}
result.result
result.result()
}
override def afterRegistered(

View File

@ -101,7 +101,7 @@ private[sbt] final class CommandExchange {
Option(deadline match {
case Some(d: Deadline) =>
commandQueue.poll(d.timeLeft.toMillis + 1, TimeUnit.MILLISECONDS) match {
case null if idleDeadline.fold(false)(_.isOverdue) =>
case null if idleDeadline.fold(false)(_.isOverdue()) =>
state.foreach { s =>
s.get(BasicKeys.serverIdleTimeout) match {
case Some(Some(d)) => s.log.info(s"sbt idle timeout of $d expired")

View File

@ -503,7 +503,7 @@ private[sbt] object Continuous {
* increase in latency.
*/
@tailrec def aggregate(res: Seq[Event]): Seq[Event] =
if (limit.isOverdue) res
if (limit.isOverdue()) res
else {
monitor.poll(antiEntropyPollPeriod) match {
case s if s.nonEmpty => aggregate(res ++ s)

View File

@ -194,7 +194,7 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe
override final def close(): Unit = shutdown()
override def shutdown(): Unit = {
val deadline = 10.seconds.fromNow
while (jobSet.nonEmpty && !deadline.isOverdue) {
while (jobSet.nonEmpty && !deadline.isOverdue()) {
jobSet.headOption.foreach { handle =>
if (handle.job.isRunning()) {
handle.job.shutdown()

View File

@ -86,7 +86,7 @@ private[sbt] class TaskProgress(
private def doReport(): Unit = {
val runnable: Runnable = () => {
if (nextReport.get.isOverdue) {
if (nextReport.get.isOverdue()) {
report()
}
}

View File

@ -219,7 +219,7 @@ private[sbt] object Definition {
}
private[sbt] def getAnalyses: Future[Seq[Analysis]] = {
val result = Promise[Seq[Analysis]]
val result = Promise[Seq[Analysis]]()
new Thread("sbt-get-analysis-thread") {
setDaemon(true)

View File

@ -766,7 +766,7 @@ final class NetworkChannel(
private def empty = TerminalPropertiesResponse(0, 0, false, false, false, false)
def getProperties(block: Boolean): Unit = {
if (alive.get) {
if (!pending.get && Option(lastUpdate.get).fold(true)(d => (d + 1.second).isOverdue)) {
if (!pending.get && Option(lastUpdate.get).fold(true)(d => (d + 1.second).isOverdue())) {
pending.set(true)
val queue = VirtualTerminal.sendTerminalPropertiesQuery(term.name, jsonRpcRequest)
val update: Runnable = () => {

View File

@ -245,7 +245,7 @@ private[sbt] object Settings {
val created = createdBuilder.result()
val modified = modifiedBuilder.result()
if (created.isEmpty && deleted.isEmpty && modified.isEmpty) {
FileChanges.unmodified(unmodifiedBuilder.result)
FileChanges.unmodified(unmodifiedBuilder.result())
} else {
FileChanges(created, deleted, modified, unmodified)
}

View File

@ -192,15 +192,15 @@ object ServerSession {
val deadline = duration.fromNow
var nextLog = PortfileLogInterval.fromNow
while (portfileIsEmpty() && !deadline.isOverdue && isAlive) {
if (nextLog.isOverdue) {
while (portfileIsEmpty() && !deadline.isOverdue() && isAlive) {
if (nextLog.isOverdue()) {
log("Still waiting for sbt ...")
nextLog = PortfileLogInterval.fromNow
}
Thread.sleep(10)
}
if (deadline.isOverdue)
if (deadline.isOverdue())
throw new TimeoutException(
s"${portfile.getAbsolutePath} was not created within $duration"
)

View File

@ -256,7 +256,7 @@ private[sbt] class ServerSessionImpl(
f(msg) match {
case Some(result) => result
case None =>
if (deadline.isOverdue)
if (deadline.isOverdue())
throw new TimeoutException(s"Timeout waiting for response after $duration")
else impl()
}
@ -324,7 +324,7 @@ private[sbt] class ServerSessionImpl(
override def shutdown(isAlive: => Boolean, destroy: () => Unit): Try[Unit] = {
def waitForExit(isAlive: => Boolean, timeout: FiniteDuration): Unit = {
val deadline = timeout.fromNow
while (!deadline.isOverdue && isAlive) Thread.sleep(10)
while (!deadline.isOverdue() && isAlive) Thread.sleep(10)
}
val result = for {

View File

@ -67,7 +67,7 @@ final class SbtHandler(remoteSbtCreator: RemoteSbtCreator) extends StatementHand
} catch {
case _: IOException => process.destroy()
} finally {
if (process.isAlive) process.destroy()
if (process.isAlive()) process.destroy()
RunningProcesses.remove(process)
}
}

View File

@ -28,7 +28,7 @@ final class SbtServer(
private val process: scala.sys.process.Process
) {
def close(): Unit =
session.shutdown(process.isAlive, () => process.destroy()).get
session.shutdown(process.isAlive(), () => process.destroy()).get
}
trait AbstractServerTest extends AnyFunSuite with BeforeAndAfterAll {
@ -80,7 +80,7 @@ trait AbstractServerTest extends AnyFunSuite with BeforeAndAfterAll {
)
val portfile = buildDir / "project" / "target" / "active.json"
ServerSession.waitForPortfile(portfile, process.isAlive)
ServerSession.waitForPortfile(portfile, process.isAlive())
val session = ServerSession.connect(portfile)
session.initialize(10.seconds, subscribeToAllForTest)

View File

@ -45,7 +45,7 @@ object Test extends std.TaskExtra:
lazy val d3 = t3(a, b, c).flatMapR(f3)
def d4(i: Int): Task[Int] = nop flatMap { _ =>
val x = math.random; if (x < 0.01) task(i); else d4(i + 1)
val x = math.random(); if (x < 0.01) task(i); else d4(i + 1)
}
def go(): Unit = {