A dependency version ends in + or is latest, so each build may resolve a different one

tx0/kotlin:dynamic-dependency-versionrecommendedwarningreliability/api-misusedepth fastbug, cwe-1357

What it finds

A dependency declared as "com.example:lib:2.+" or "latest.release" resolves to whatever version the repository offers on the day of the build. Two builds of the same commit can then differ, a release can break without a change in the project, and a compromised or careless upload is picked up by itself. A fixed version, updated on purpose, keeps builds reproducible.

Reported for coordinates and versions that end in + or are latest.*, in the dependencies, constraints and plugins blocks of a build script or a plugin that configures one.

From the rule's source, dynamic_dependency_version.rs.

Example from the rule's tests
plugins {    id("com.example.plugin") version "1.+"tx0 reports: the version 1.+ changes with what the repository offers} dependencies {    implementation("com.squareup.okhttp3:okhttp:4.+")tx0 reports: the version 4.+    implementation("org.example:lib:latest.release")tx0 reports: the version latest.release    implementation(group = "org.example", name = "other", version = "2.+")tx0 reports: the version 2.+    implementation("org.example:pinned:1.2.3")    testImplementation("org.example:lib") {        version { strictly("3.+") }tx0 reports: the version 3.+    }} val pattern = "a:b:1.+"
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:dynamic-dependency-version" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:dynamic-dependency-version] reason="..."

tx0 explain tx0/kotlin:dynamic-dependency-version shows the same in the terminal. Found a false positive? Report it.