String concatenation as argument to 'MessageFormat.format()' call
Reports non-constant string concatenations used as an argument to a call to MessageFormat.format().
While occasionally intended, this is usually a misuse of the formatting method and may even cause unexpected exceptions if the variables used in the concatenated string contain special characters like {.
Also, sometimes this could be the result of mistakenly concatenating a string format argument by typing a + when a , was meant.
Example:
Here, the userName will be interpreted as a part of the format string, which may result in IllegalArgumentException (for example, if userName is "{"). This call should be probably replaced with MessageFormat.format("Hello, {0}! Your balance is {1}.", userName, balance).
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.
StringConcatenationInMessageFormatCall- 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.
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |