Skip to content

sbt 2.x lintUnused warnings for plugin-defined keys #379

Description

@eshu

When using sbt-ci-release with sbt 2.x, the following lintUnused warnings appear:

[warn] there are 3 keys that are not used by any other settings/tasks:
[warn]  
[warn] * ThisBuild / gitUncommittedChanges
[warn]   +- ThisBuild / gitUncommittedChanges := gitReader.value.withGit(_.hasUncommittedChanges):135
[warn] * ThisBuild / scmInfo
[warn]   +- scmInfo := parseScmInfo(gitReader.value.withGit(_.remoteOrigin)):136
[warn]   +- scmInfo ~= {
[warn]       case Some(info) => Some(info)
[warn]       case None       =>
[warn]         import scala.sys.process._
[warn]         val identifier = """([^\/]+?)"""
[warn]         val GitHubHttps =
[warn]           s"https://github.com/$identifier/$identifier(?:\\.git)?".r
[warn]         val GitHubGit = s"git://github.com:$identifier/$identifier(?:\\.git)?".r
[warn]         val GitHubSsh = s"git@github.com:$identifier/$identifier(?:\\.git)?".r
[warn]         try {
[warn]           val remote = List("git", "ls-remote", "--get-url", "origin").!!.trim()
[warn]           remote match {
[warn]             case GitHubHttps(user, repo) => Some(gitHubScmInfo(user, repo))
[warn]             case GitHubGit(user, repo)   => Some(gitHubScmInfo(user, repo))
[warn]             case GitHubSsh(user, repo)   => Some(gitHubScmInfo(user, repo))
[warn]             case _                       => None
[warn]           }
[warn]         } catch {
[warn]           case NonFatal(_) => None
[warn]         }
[warn]     }:120
[warn] * root / gitDescribedVersion
[warn]   +- gitDescribedVersion := {
[warn]       val projectPatterns = gitDescribePatterns.value
[warn]       val buildPatterns = (ThisBuild / gitDescribePatterns).value
[warn]       val projectTagToVersionNumber = gitTagToVersionNumber.value
[warn]       val buildTagToVersionNumber = (ThisBuild / gitTagToVersionNumber).value
[warn]       if (projectPatterns == buildPatterns && projectTagToVersionNumber == buildTagToVersionNumber)
[warn]         (ThisBuild / gitDescribedVersion).value
[warn]       else gitReader.value.withGit(_.describedVersion(projectPatterns)).map(v => projectTagToVersionNumber(v).getOrElse(v))
[warn]     }:167
[warn]  
[warn] note: a setting might still be used by a command; to exclude a key from this `lintUnused` check
[warn] either append it to `Global / excludeLintKeys` or call .withRank(KeyRanks.Invisible) on the key

These keys are set by the plugin but consumed only by commands (e.g. ci-release), not by other settings — hence the false-positive warning.

Expected: no warnings from sbt-ci-release keys out of the box.

Suggested fix: in the plugin itself, mark these keys with .withRank(KeyRanks.Invisible) or add them to Global / excludeLintKeys from within the plugin's buildSettings/globalSettings.

Environment:

  • sbt: 2.0.0
  • sbt-ci-release: 1.11.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions