[2.x] fix: Exclude autoStartServer from lintUnused warnings (#6624) (#8708)

**Problem**
Setting `Global / autoStartServer := false` in global.sbt triggers a
spurious lintUnused warning, even though the setting is correctly used
by sbt's server startup logic.

**Solution**
Add `autoStartServer` to the `excludeLintKeys` set in LintUnused.scala,
similar to other server-related settings like `serverConnectionType` and
`serverIdleTimeout`. This prevents the warning while maintaining the
functionality of the setting.
This commit is contained in:
PandaMan 2026-02-07 10:47:25 -05:00 committed by GitHub
parent 4681dc714c
commit f6f00c1931
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,7 @@ object LintUnused {
},
excludeLintKeys := Set(
aggregate,
autoStartServer,
concurrentRestrictions,
commands,
configuration,

View File

@ -0,0 +1,23 @@
// Test for issue #6624: autoStartServer should not trigger lintUnused warning
Global / autoStartServer := false
@transient
lazy val check = taskKey[Unit]("")
lazy val root = (project in file("."))
.settings(
check := Def.uncached {
val state = Keys.state.value
val includeKeys = (Global / lintIncludeFilter).value
val excludeKeys = (Global / lintExcludeFilter).value
val result = sbt.internal.LintUnused.lintUnused(state, includeKeys, excludeKeys)
// autoStartServer should not appear in the lint results
val autoStartServerWarnings = result.filter { case (_, key, _) =>
key.contains("autoStartServer")
}
assert(
autoStartServerWarnings.isEmpty,
s"autoStartServer should not trigger lintUnused warnings, but found: ${autoStartServerWarnings.map(_._2).mkString(", ")}"
)
}
)

View File

@ -0,0 +1 @@
> check