UniqueProperties
Since Checkstyle 5.7
Description
Rationale: Multiple property keys usually appear after merge or rebase of several branches. While there are no problems in runtime, there can be a confusion due to having different values for the duplicated properties.
Properties
name | description | type | default value | since |
---|---|---|---|---|
fileExtensions | Specify the file extensions of the files to process. | String[] | .properties |
5.7 |
Examples
To configure the check:
<module name="Checker">
<module name="UniqueProperties"/>
</module>
Example: in foo.properties file
# // violation below 'Duplicated property 'key.one' (2 occurrence(s)).'
key.one=44
key.two=32
key.one=54
To configure the check to scan custom file extensions:
<module name="Checker">
<module name="UniqueProperties">
<property name="fileExtensions" value="customProperties"/>
</module>
</module>
Example: in foo.customProperties file
# // violation below 'Duplicated property 'key.one' (2 occurrence(s)).'
key.one=44
key.two=32
key.one=54
Example: in foo.properties file
# OK below, no duplication violation, as the file is not checked
key.one=44
key.two=32
key.one=54
Example of Usage
Violation Messages
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
Package
com.puppycrawl.tools.checkstyle.checks