Missing printf Format Argument

ID

java.printf_style_format_strings_lead

Severity

critical

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Reliability

Language

Java

Tags

reliability

Description

Reports a String.format, Formatter.format, PrintStream/PrintWriter printf or format call whose format string needs more argument slots than the call supplies.

Rationale

Conversion specifiers (%s, %d, …​) are validated only at runtime, not by the compiler. When a format string has more specifiers than the call has trailing arguments, the JDK throws MissingFormatArgumentException every time the code path runs:

String.format("Processed %d of %d records", 42); // throws MissingFormatArgumentException

Only format strings built from plain, sequential specifiers are checked. A format string using an explicit argument index (%1$s), a back-reference (%<), flags, width or precision is left alone.

Remediation

Supply one argument for every specifier in the format string:

String.format("Processed %d of %d records", 42, total);

References

© 2026 Xygeni. All rights reserved