Checks for Headers

The property checkstyle.header.file controls whether Checkstyle checks that each files with a specified header. The header contents are specified in the file. If no file is specified, checkstyle does not check for a header. The property type is java.lang.String and defaults to null (which means do not check).

The property checkstyle.header.ignoreline can be used to tell Checkstyle to ignore matching lines in a header file. The property type is a list of comma separated integers and defaults to an empty list. This property is very useful for supporting headers that contain copyright dates. For example, consider the following header:

line 1: ///////////////////////////////////////////////////////////////////////
line 2: // checkstyle: Checks Java source code for adherence to a set of rules.
line 3: // Copyright (C) 2001  Oliver Burn
line 4: ///////////////////////////////////////////////////////////////////////

Since the year information will change over time, you can tell checkstyle to ignore line 3 by setting the property to 3.

The property checkstyle.header.regexp controls whether Checkstyle will interpret each header line as a regular expression. The property type is boolean and defaults to false. For example, consider the following header when regular expression checking is turned on:

line 1: /{71}
line 2: // checkstyle: Checks Java source code for adherence to a set of rules\.
line 3: // Copyright \(C\) \d\d\d\d  Oliver Burn
line 4: // Last modification by \$Author.*\$
line 5: /{71}

Lines 1 and 5 demonstrate a more compact notation for 71 '/' characters. Line 3 enforces that the copyright notice includes a four digit year. Line 4 is an example how to enforce revision control keywords in a file header.