Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / scala

No snapshot dependencies

scala/no-snapshot-dependencies@v1

No library dependency read out of the build is a -SNAPSHOT. build.sbt is Scala read by pattern, so the dependencies it declares indirectly are not seen and the list is a floor rather than the whole of it.

Idscala/no-snapshot-dependencies
Versionv1
Categoryscala
Default severityerror
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsscala

Collectors

This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.

CollectorGathersInputs it is given
scalaThe sbt build in the project directory: the Scala and sbt versions it pins, every subproject the reader saw, the library dependencies each build file names with their configurations, and the plugins the build itself runs. build.sbt is Scala rather than a declaration, so what it declares indirectly is not seen and scanned says so.projectDir

The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.

Configuration

json
{
  "guardrails": {
      "failOn": "error",
      "comment": true,
      "checks": [
          {
              "use": "scala/no-snapshot-dependencies@v1",
              "severity": "error",
              "with": {
                  "projectDir": "."
              },
              "exemptions": []
          }
      ]
  }
}

Inputs

InputDescriptionDefaultEnvironment variable
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR

How to fix

Depend on a released revision, and cut a release of the library upstream where there is not one yet:

scala
libraryDependencies += "com.acme" %% "queue" % "1.4.0"

A snapshot is republished under the same coordinates, so whatever 1.4.0-SNAPSHOT resolved to on the day the build shipped is gone and this commit cannot be built into the artifact that was released from it. A snapshot from publishLocal is worse again: it never existed anywhere a rebuild could reach, so the build passes for the author and for nobody else.

More in scala

  • scala/dependencies-pinned. Every library dependency read out of the build names a literal revision. build.sbt is Scala read by pattern, so a dependency built by a function, added inside a condition or held in a variable is not seen and the list is a floor rather than the whole of it.
  • scala/sbt-version-pinned. project/build.properties pins the sbt version the build runs under, rather than leaving it to the launcher the machine happens to carry.
  • scala/version-declared. The build declares the Scala version it compiles against, and that version is no older than the configured floor.

All 4 scala guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412