Message format validation in properties files
Reports the following MessageFormat
problems in property values:
Unknown format types
MessageFormat
supports only these format types:
number
date
time
choice
Other format types will be reported.
Unpaired quotes
A single quote is interpreted as an escape until the end of the property, and will not be present in the result string. In most cases this is not what is intended. If a single quote should be present in the result string, it has to be duplicated in the property.
Unmatched braces
Every placeholder must have a closing brace.
Too many quotes
In some cases (e.g. it's
), it is expected that only one quote ends up in the result string. Cases where two or more quotes are placed together in the result string are reported.
Incorrect lower bounds for nested ChoiceFormat
Lower bounds are expected to be numbers and to be sorted in ascending order.
Wrong number of quotes around parameters
In java.text.MessageFormat
patterns single quotes are used for escaping. To keep quotes visible, they must be duplicated. For example when passing 1
:
'{0}'
→{0}
''{0}''
→'1'
When using choice format, nested formats are evaluated as format strings themselves, and quotes will need to be duplicated twice. For example when passing 1
:
{0, choice, 0#no|#1''{0}'' files}
→{0} files
{0, choice, 0#no|#1''''{0}'''' files}
→'1' files
Note
Property values are verified only if they contain the literal text {0}
, {0,
, {1}
or {1,
. This is to make sure that these property values are actually used as MessageFormat
patterns.
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
DevKitPropertiesMessageValidation- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
New in 2023.2
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Plugin DevKit, 242.22892 |