All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.delphi.rules.community-delphi.FormatStringValid.html Maven / Gradle / Ivy

The newest version!

Why is this an issue?

Passing an invalid format string to System.SysUtils.Format can raise a runtime exception. In addition, even if an exception is not raised Format stops processing the string after the first invalid character, which will result in an unexpected value.

How to fix it

Modify the format string to be syntactically valid.

For example, if there are stray percent symbols, escape them with a second percent symbol:

Format('%s got 50%!', ['Bob']);
Format('%s got 50%%!', ['Bob']);

Or if there is a mangled format specifier, fix the syntax problems:

Format('%s got %*:*f!', ['Bob', 2, 50.0]);
Format('%s got %.*f!', ['Bob', 2, 50.0]);

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy