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

Update for existing Check: EmptyBlock #27

Closed maxvetrenko closed 10 years ago

maxvetrenko commented 10 years ago

http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock http://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s4.1.3-braces-empty-blocks If (a==1) {} //is not OK If (doSideEffect()==1) {} //is not OK, while ((r = in.read()) != 0) {} // is OK for (; index < s.length() && s[index] != 'x'; index++) {} // is OK

and If (a==1) {} else {print(a)} // is not OK

Till comments support are not in Checkstyle you can not extend this check to allow empty blocks that have a comments.
// it is OK, but you can not support this now If (a==1) {/it is ok /} else {print(a)}

romani commented 10 years ago

1) add youself as author

2)

setAllowEmptyLoops

I do not see a reason in this booelan field, as we could as user to define tokens where empty block is allowed {TokenTypes.LITERAL_FOR , TokenTypes.LITERAL_WHILE} Let user define Style he wants, do not restrict him.

romani commented 10 years ago

1)

<property name="allowEmptyLoops" value="true" />

?

maxvetrenko commented 10 years ago

There is no such code in last commit.

romani commented 10 years ago

squash all commit in one to let me validate them, I use only last commits reference on this page.

maxvetrenko commented 10 years ago

I have only one commit: EmptyBlockUpdate branch. I always amend it after making changes.

romani commented 10 years ago

I do not see changes in Check itself, is it expected ?

maxvetrenko commented 10 years ago

Yes, there is no changes in Check, I added UT to test Google's rule coverage.

romani commented 10 years ago

ok to PR.