UniqueProperties

Since Checkstyle 5.7

Description

Detects duplicated keys in properties files.

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

key.one=44
key.two=32 // OK
key.one=54 // violation
        

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

key.one=44
key.two=32 // OK
key.one=54 // violation
        

Example: in foo.properties file

key.one=44
key.two=32 // OK
key.one=54 // OK, file is not checked
        

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

Parent Module

Checker