From f6f00c1931079fc9fc4028737c34b459fd7d025a Mon Sep 17 00:00:00 2001 From: PandaMan Date: Sat, 7 Feb 2026 10:47:25 -0500 Subject: [PATCH] [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. --- .../main/scala/sbt/internal/LintUnused.scala | 1 + .../project/lint-autostartserver/build.sbt | 23 +++++++++++++++++++ .../project/lint-autostartserver/test | 1 + 3 files changed, 25 insertions(+) create mode 100644 sbt-app/src/sbt-test/project/lint-autostartserver/build.sbt create mode 100644 sbt-app/src/sbt-test/project/lint-autostartserver/test diff --git a/main/src/main/scala/sbt/internal/LintUnused.scala b/main/src/main/scala/sbt/internal/LintUnused.scala index 6f78f3fc4..936caf31d 100644 --- a/main/src/main/scala/sbt/internal/LintUnused.scala +++ b/main/src/main/scala/sbt/internal/LintUnused.scala @@ -29,6 +29,7 @@ object LintUnused { }, excludeLintKeys := Set( aggregate, + autoStartServer, concurrentRestrictions, commands, configuration, diff --git a/sbt-app/src/sbt-test/project/lint-autostartserver/build.sbt b/sbt-app/src/sbt-test/project/lint-autostartserver/build.sbt new file mode 100644 index 000000000..974058aa8 --- /dev/null +++ b/sbt-app/src/sbt-test/project/lint-autostartserver/build.sbt @@ -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(", ")}" + ) + } + ) diff --git a/sbt-app/src/sbt-test/project/lint-autostartserver/test b/sbt-app/src/sbt-test/project/lint-autostartserver/test new file mode 100644 index 000000000..15675b169 --- /dev/null +++ b/sbt-app/src/sbt-test/project/lint-autostartserver/test @@ -0,0 +1 @@ +> check