maxvetrenko / checkstyle

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.
http://checkstyle.sourceforge.net/
GNU Lesser General Public License v2.1
0 stars 0 forks source link

New Check: EmptyLineSeparatorCheck #13

Closed maxvetrenko closed 10 years ago

maxvetrenko commented 10 years ago

http://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s3.3.3-import-ordering-and-spacing http://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s4.6.1-vertical-whitespace Need to implement next rule: Exactly one blank line separates each section that is present. Also need to cover Vertical Whitespace

romani commented 10 years ago

please make sure that list of Tokens between each user could enforce vertical whitespace will be managed by user through Check parameters.

romani commented 10 years ago

Please make sure that "Exception: A blank line between two consecutive fields..." will be covered by Check

maxvetrenko commented 10 years ago

I'll check it during implementation.

romani commented 10 years ago

I do not see implementation , i see only Input file

romani commented 10 years ago

1) Where is JavaDoc ?

2) I do not see a reason to add support for empty lines for imports as you need to copy whole check of ImportOrder .... too much to my mind for this Check. Lets focus on http://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s4.6.1-vertical-whitespace in this Check, and spaces between imports implement in ImportOrderCheck

lets have a call if you disagree.

romani commented 10 years ago

1)

  • * Checks for blank line separators after fields, constructors,
  • * methods, nested classes, static initializers, instance initializers.

Why after package and all imports options are missed ?

2)

  • *

    An example of how to configure the check is:

  • *

  • *
  • *
  • * <module name="EmptyLineSeparator"/>
  • *

Do you see big help to provide user example how to configure Check with default options ? and after that with custom options

maxvetrenko commented 10 years ago
  1. Added package and all import block support
  2. I updated my Javadoc and I think, that it is useful to provide example of missing line separators, then provide default config to check it and then provide example of line separators. Also present a sample custom configuration for checking line separators only after methods and fields.
romani commented 10 years ago

1)

all imports fields

please consult with specifcation before naming smth http://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.5

2)

  • * Example of instances without blank line separator:

Example of declarations ....

Call me and explain difference between: declaration, definition, class, instance. before call review

3)

Example of instances with blank line separator:

Example of declarations with blank line separator that is expected by the Check by default :

4)

lastToken = null == lastToken ? aToken.getLastChild() : lastToken;

try to avoid ternary usage - it is not very readable. in this case : if (null == lastToken) { lastToken = aToken.getLastChild(); }

maxvetrenko commented 10 years ago
  1. Done. link, It was mistake, I forgot comma.
  2. Foo foo = new Foo(); foo is an instance of Foo. Declaration says nothing about how class, variable etc looks like. Declaration just says that it exists. Definition says how something is implemented. Class is model from which objects are created.
  3. Done link
  4. Done link
romani commented 10 years ago

code looks ok to me. please update xdoc and do PR.