Since Checkstyle 8.22
Rationale: Sorted properties make it easy for people to find required properties by name
in file. This makes it easier to merge. While there are no problems at runtime.
This check is valuable only on files with string resources where order of lines
does not matter at all, but this can be improved.
E.g.: checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/messages.properties
You may suppress warnings of this check for files that have a logical structure like
build files or log4j configuration files. See SuppressionFilter.
<suppress checks="OrderedProperties"
files="log4j.properties|ResourceBundle/Bug.*.properties|logging.properties"/>
Known limitation: The key should not contain a newline. The string compare will work, but not the line number reporting.
name | description | type | default value | since |
---|---|---|---|---|
fileExtensions | Specify the file extensions of the files to process. | String[] | .properties |
8.22 |
To configure the check:
<module name="Checker"> <module name="OrderedProperties"/> </module>
Example properties file:
A =65 a =97 key =107 than nothing key.sub =k is 107 and dot is 46 key.png =value - violation
We check order of key's only. Here we would like to use a Locale independent order mechanism and binary order. The order is case-insensitive and ascending.
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks