mirror of https://github.com/sbt/sbt.git
`.value` inside the if of a regular task is unsafe. The wrapping task will always execute the value, no matter what the if predicate yields. This commit adds the infrastructure to lint code for every sbt DSL macro. It also adds example of neg tests that check that the DSL checks are in place. The sbt checks yield error for this specific case because we may want to explore changing this behaviour in the future. The solutions to this are straightforward and explained in the error message, that looks like this: ``` EXPECTED: The evaluation of `fooNeg` happens always inside a regular task. PROBLEM: `fooNeg` is inside the if expression of a regular task. Regular tasks always evaluate task inside the bodies of if expressions. SOLUTION: 1. If you only want to evaluate it when the if predicate is true, use a dynamic task. 2. Otherwise, make the static evaluation explicit by evaluating `fooNeg` outside the if expression. ``` Aside from those solutions, this commit also adds a way to disable any DSL check by using the new `sbt.unchecked` annotation. This annotation, similar to `scala.annotation.unchecked` disables compiler output. In our case, it will disable any task dsl check, making it silent. Examples of positive checks have also been added. There have been only two places in `Defaults.scala` where this check has made compilation fail. The first one is inside `allDependencies`. To ensure that we still have static dependencies for `allDependencies`, I have hoisted up the value invocation outside the if expression. We may want to explore adding a dynamic task in the future, though. We are doing unnecessary work there. The second one is inside `update` and is not important because it's not exposed to the user. We use a `taskDyn`. |
||
|---|---|---|
| core-macros/src/main/scala/sbt/internal/util/appmacro | ||
| launch | ||
| licenses | ||
| main | ||
| main-actions/src | ||
| main-command/src/main | ||
| main-settings/src | ||
| notes | ||
| project | ||
| protocol/src/main | ||
| run | ||
| sbt/src | ||
| scripted | ||
| src/main/conscript | ||
| tasks | ||
| tasks-standard | ||
| testing | ||
| .gitattributes | ||
| .gitignore | ||
| .java-version | ||
| .scalafmt.conf | ||
| .travis.yml | ||
| CONTRIBUTING.md | ||
| ISSUE_TEMPLATE.md | ||
| LICENSE | ||
| NOTICE | ||
| PULL_REQUEST_TEMPLATE.md | ||
| README.md | ||
| build.sbt | ||
| reset.sh | ||
| sbt-allsources.sh | ||
| server.md | ||
README.md
sbt
sbt is a build tool for Scala, Java, and more.
For general documentation, see http://www.scala-sbt.org/.
sbt 1.0.x
This is the 1.0.x series of sbt. The source code of sbt is split across several Github repositories, including this one.
- sbt/io hosts
sbt.iomodule. - sbt/util hosts a collection of internally used modules.
- sbt/librarymanagement hosts
sbt.librarymanagementmodule that wraps Ivy. - sbt/zinc hosts Zinc, an incremental compiler for Scala.
- sbt/sbt, this repository hosts modules that implements the build tool.
Other links
- Setup: Describes getting started with the latest binary release.
- FAQ: Explains how to get help and more.
- sbt/sbt-zero-seven: hosts sbt 0.7.7 and earlier versions
Issues and Pull Requests
Please read CONTRIBUTING carefully before opening a GitHub Issue.
The short version: try searching or asking on StackOverflow and sbt-dev.
license
See LICENSE.