Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#588 Header check has to distinguis source file-type

release_5.0
closed
Oliver Burn
5
2012-10-10
2009-07-25
Jörg Hohwiller
No

In your own documentation at
http://checkstyle.sourceforge.net/config_header.html
you say "Different programming languages have different comment syntax rules".
However I can not find a way to tell checks such as Header or RegexpHeader to work only on .java Files.
My header is multiline / ... / comment that can not be used in properties-files.
However checkstyle complains about the missing header in properties-files.
Either documentation is missing importation information or there is an important feature missing in checkstyle to
be able to allow different Filters for different file-formats.

Discussion

  • Lars Kühne
    Lars Kühne
    2009-07-28

    If the propertíes file should contain a header as well, only in a different comment format, you can use something similiar to the Apache example in the RegexpHeader docs, you only have to adjust the regular expressions a bit.

    I assume that is not what you intend, and you want to limit the file header check to java files only. I haven't tried this, but you should be able to do that by specifying the property "fileExtensions" to "java". This is supported by most (all?) checks that have Checker as their parent module, it is implemented in the AbstractFileSetCheck baseclass (see API docs).

    You are correct that this property is not documented in the end user documentation, leaving this issue open.

     
  • Oliver Burn
    Oliver Burn
    2009-07-30

    As usual Lars is 100% right. Just do something like:

    <module name="Header">
    <property name="headerFile" value="java.header"/>
    <property name="ignoreLines" value="2, 3, 4"/>
    <property name="fileExtensions" value="java"/>
    </module>

    Fixed documentation - SVN revision 2506