Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#96 multi line header files

release_3.4
closed
Check (274)
5
2012-10-10
2002-08-20
Simon Langford
No

would it be possible to add a feature to the header file
checking so that it enforces a certain number of lines
between package and import for example, or to make
sure certain comments are in a certain order.

For example, our coding guidlines state that a source
file must be ordered hence:

  1. Header comment
  2. Package name
  3. Import statements
  4. Javadoc class documentation
  5. Revision log
  6. Class declaration
  7. Constants
  8. Variables - public first, then private
  9. Methods - public first
  10. Inner classes

now obviously, i'd like to fully check this precedence,
but that would be hard, but some mechanism by which i
could ensure 1-4 would be very handy.

eg something like:

<pre>
// \$Header.*\$
^package

[^import\n]*

/
[^ *\n]*
/

/
^\$Log:
[.*\n]*
/
</pre>

Discussion

  • Simon Langford
    Simon Langford
    2002-08-20

    Logged In: YES
    user_id=549015

    I've thought a little more, could have a property:

    checkstyle.header.multilines

    which could be a comma seperated list of lines or regular
    expressions describing lines of which there can be multiples
    thereof in a row, so if you have:

    headerfile:

    1 ^package
    2
    3 ^import
    4
    5 /*
    6 ^ *
    7
    /

    and:

    checkstyle.header.multilines=3,6

    then both:

    1 package blah;
    2
    3 import a;
    4
    5 /
    6

    7 */

    and:

    1 package blah;
    2
    3 import a;
    4 import b;
    5 import c;
    6
    7 /
    8

    9 * blah blah
    10 * @see foo
    11 */

    will be valid

     
  • Oliver Burn
    Oliver Burn
    2002-08-20

    Logged In: YES
    user_id=218824

    interesting idea

     
  • Logged In: YES
    user_id=746148

    Added multiLines property to RegexpHeader check.
    Committed to CVS for 3.4