[2.x] ci: Add scalafix DisableSyntax.noReturns (#8922)

This commit is contained in:
kenji yoshida 2026-03-19 23:48:10 +09:00 committed by GitHub
parent 963acca8ad
commit 14606c593d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 34 additions and 11 deletions

5
.scalafix.conf Normal file
View File

@ -0,0 +1,5 @@
rules = [
DisableSyntax
]
DisableSyntax.noReturns = true

View File

@ -45,6 +45,7 @@ ThisBuild / scmInfo := Some(
)
ThisBuild / resolvers += Resolver.mavenLocal
ThisBuild / mimaFailOnNoPrevious := false
ThisBuild / scalafixOnCompile := true
Global / semanticdbEnabled := !(Global / insideCI).value
// Change main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala too, if you change this.
@ -1022,6 +1023,10 @@ lazy val sbtwProj = (project in file("sbtw"))
description := "Windows drop-in launcher for sbt (replaces sbt.bat)",
scalaVersion := "3.8.2",
crossPaths := false,
Compile / scalafix / unmanagedSources := {
// https://github.com/scalameta/scalameta/issues/4531
(Compile / unmanagedSources).value.filterNot(_.getName == "Main.scala")
},
Compile / mainClass := Some("sbtw.Main"),
libraryDependencies += "com.github.scopt" %% "scopt" % "4.1.0",
libraryDependencies += scalaVerify % Test,

View File

@ -18,6 +18,7 @@ object EditDistance {
* Translated from the java version at http://www.merriampark.com/ld.htm which is declared to be
* public domain.
*/
@SuppressWarnings(Array("scalafix:DisableSyntax"))
def levenshtein(
s: String,
t: String,

View File

@ -67,6 +67,7 @@ object Escapes extends Properties("Escapes") {
(original == removed)
}
@SuppressWarnings(Array("scalafix:DisableSyntax"))
def diffIndex(expect: String, original: String): String = {
var i = 0;
while (i < expect.length && i < original.length) {

View File

@ -31,6 +31,7 @@ final case class BenchmarkResult(
object UpdateReportPersistenceBenchmark:
@SuppressWarnings(Array("scalafix:DisableSyntax"))
def run(
iterations: Int = 500,
configs: Seq[String] = Seq("compile", "test"),

View File

@ -30,6 +30,7 @@ object CacheUrlConversion {
withForwardSlash
}
@SuppressWarnings(Array("scalafix:DisableSyntax"))
def cacheFileToOriginalUrl(fileUrl: String, cacheDir: File): String = {
if (!fileUrl.startsWith(FileUrlPrefix)) return fileUrl
val filePath = normalizedFilePath(fileUrl)

View File

@ -41,9 +41,11 @@ private[sbt] object IvyUtil {
private val _r = """.*HTTP response code: (5\d{2}|408|429).*""".r
@inline private def check(s: String): Boolean = {
if (s == null) return false
_r.pattern.matcher(s).matches()
if (s == null) {
false
} else {
_r.pattern.matcher(s).matches()
}
}
def apply(t: Throwable): Boolean = t match {

View File

@ -111,14 +111,17 @@ private[sbt] case class SbtChainResolver(
/* Copy pasted from `IvyStringUtils` to handle `Throwable` */
private def getStackTrace(e: Throwable): String = {
if (e == null) return ""
val baos = new ByteArrayOutputStream()
val printWriter = new PrintWriter(baos)
e.printStackTrace(printWriter)
printWriter.flush()
val stackTrace = new String(baos.toByteArray)
printWriter.close()
stackTrace
if (e == null) {
""
} else {
val baos = new ByteArrayOutputStream()
val printWriter = new PrintWriter(baos)
e.printStackTrace(printWriter)
printWriter.flush()
val stackTrace = new String(baos.toByteArray)
printWriter.close()
stackTrace
}
}
/** If None, module was not found. Otherwise, hit. */

View File

@ -516,6 +516,8 @@ private[sbt] final class CommandExchange {
private def notifyOtherServers(): Unit = {
val thread = new Thread("sbt-notify-other-servers") {
setDaemon(true)
@SuppressWarnings(Array("scalafix:DisableSyntax"))
override def run(): Unit = {
val procDir = SysProp.globalLocalCache / "proc"
if (!procDir.exists) return

View File

@ -240,6 +240,7 @@ private[sbt] object PomGenerator:
(scope, optional)
/** Convert Ivy-style dynamic versions to Maven range format. */
@SuppressWarnings(Array("scalafix:DisableSyntax"))
private def convertVersion(version: String): String =
if version == null then null
else if version.endsWith("+") then

View File

@ -70,6 +70,7 @@ object Runner:
if opts.jvmClient then s = s :+ "--client"
s
@SuppressWarnings(Array("scalafix:DisableSyntax"))
def runNativeClient(sbtBinDir: File, scriptPath: String, opts: LauncherOptions): Int =
val sbtn = new File(sbtBinDir, "sbtn-x86_64-pc-win32.exe")
if !sbtn.isFile then