Format string uses a conversion character that does not exist
ID |
scala.correctness.malformed_format_string |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Api Misuse |
Language |
Scala |
Description
This format string contains a conversion that the formatter does not define, so the call throws UnknownFormatConversionException at run time rather than failing to compile. Use one of the documented conversions (%s, %d, %f, %x, …), and escape a literal percent sign as %%.
Rationale
This format string contains a conversion that the formatter does not define, so the call throws UnknownFormatConversionException at run time rather than failing to compile. Use one of the documented conversions (%s, %d, %f, %x, …), and escape a literal percent sign as %%.
The following code illustrates the pattern detected by this rule:
class MalformedFormatString {
def greet(name: String): String = {
// FLAGGED: Format string uses a conversion character that does not exist
"hello %z".format(name)
}
}