Add solutions for dynamic task evaluation

There are many cases where one would want to force evaluation of the
task even when contained in a lambda (see
https://github.com/sbt/sbt/issues/3266). The @sbtUnchecked annotation is
one way to disable the linter that prevents this, but it is obscure. If
the annotation is to exist, I think it should be presented as a
solution.
This commit is contained in:
Ethan Atkins 2018-12-10 15:20:39 -08:00
parent 1c2bab093b
commit 2e027640d3
1 changed files with 3 additions and 1 deletions

View File

@ -189,6 +189,7 @@ object TaskLinterDSLFeedback {
|$SolutionHeader:
| 1. Make `$task` evaluation explicit outside of the function body if you don't care about its evaluation.
| 2. Use a dynamic task to evaluate `$task` and pass that value as a parameter to an anonymous function.
| 3. Annotate the `$task` evaluation with `@sbtUnchecked`, e.g. `($task.value: @sbtUnchecked)`.
""".stripMargin
def useOfValueInsideIfExpression(task: String): String =
@ -198,7 +199,8 @@ object TaskLinterDSLFeedback {
| Regular tasks always evaluate task inside the bodies of if expressions.
|$SolutionHeader:
| 1. If you only want to evaluate it when the if predicate is true or false, use a dynamic task.
| 2. Otherwise, make the static evaluation explicit by evaluating `$task` outside the if expression.
| 2. Make the static evaluation explicit by evaluating `$task` outside the if expression.
| 3. If you still want to force the static evaluation, you may annotate the task evaluation with `@sbtUnchecked`, e.g. `($task.value: @sbtUnchecked)`.
""".stripMargin
def missingValueForKey(key: String): String =