A format string asks for more or fewer arguments than are passed
What it finds
String.format("%s: %d", name) throws MissingFormatArgumentException at run time, and extra arguments are silently ignored. Reported for String.format(...) and "...".format(...) when the format is a literal without explicit argument indices and no argument is spread.
From the rule's source, format_arguments.rs.
fun messages(name: String, count: Int, args: Array<Any>) { val a = String.format("%s has %d items", name)tx0 reports: the format asks for 2 arguments but 1 are passed val b = "%s: %d%%".format(name, count, 3)tx0 reports: the format uses 2 arguments but 3 are passed val g = "%s".format(java.util.Locale.ROOT, name) val c = "%s and %s%n".format(name, name) val d = String.format(java.util.Locale.ROOT, "%.2f", 1.5) val e = "%1\$s %1\$s".format(name) val f = "%s %s".format(*args)} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/kotlin:format-argument-count" = "off"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:format-argument-count] reason="..."tx0 explain tx0/kotlin:format-argument-count shows the same in the terminal. Found a false positive? Report it.