Only print unused setting warning if there are any

This commit is contained in:
Ethan Atkins 2019-11-17 17:58:20 -08:00
parent 181bfe8a46
commit 805fa002a7
1 changed files with 22 additions and 19 deletions

View File

@ -70,26 +70,29 @@ object LintUnused {
import scala.collection.mutable.ListBuffer import scala.collection.mutable.ListBuffer
val buffer = ListBuffer.empty[String] val buffer = ListBuffer.empty[String]
val size = result.size if (result.isEmpty) Vector.empty
if (size == 1) buffer.append("there's a key that's not used by any other settings/tasks:") else {
else buffer.append(s"there are $size keys that are not used by any other settings/tasks:") val size = result.size
buffer.append(" ") if (size == 1) buffer.append("there's a key that's not used by any other settings/tasks:")
result foreach { else buffer.append(s"there are $size keys that are not used by any other settings/tasks:")
case (_, str, positions) => buffer.append(" ")
buffer.append(s"* $str") result foreach {
positions foreach { case (_, str, positions) =>
case pos: FilePosition => buffer.append(s" +- ${pos.path}:${pos.startLine}") buffer.append(s"* $str")
case _ => () positions foreach {
} case pos: FilePosition => buffer.append(s" +- ${pos.path}:${pos.startLine}")
case _ => ()
}
}
buffer.append(" ")
buffer.append(
"note: a setting might still be used by a command; to exclude a key from this `lintUnused` check"
)
buffer.append(
"either append it to `Global / excludeLintKeys` or call .withRank(KeyRanks.Invisible) on the key"
)
buffer.toVector
} }
buffer.append(" ")
buffer.append(
"note: a setting might still be used by a command; to exclude a key from this `lintUnused` check"
)
buffer.append(
"either append it to `Global / excludeLintKeys` or call .withRank(KeyRanks.Invisible) on the key"
)
buffer.toVector
} }
def lintUnused( def lintUnused(