aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Checkstyle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Checkstyle" Watch "Checkstyle" New topic
Author

Checkstyle

Jim Janssens
Ranch Hand

Joined: Sep 24, 2004
Posts: 210
I'm using eclipse 3 to build my assignment. I installed the "eclipse checkstyle plugin" (http://eclipse-cs.sourceforge.net/) to make sure my code style is ok. The default checkstyle xml shipped with this tool is called "Sun checks". I have 2 questions about this:

- How can I be sure that this checkstyle is sun's *official* checkstyle for the java language ? I did found lots of info about the sun checkstyle, but none of them are presented in some useable format to plug into a checkstyle plugin (I'm not going to manually verify it) .

- In every class I have multiple warnings. This checkstyle is VERY strict. For example: it nags about blank lines or spaces in my javadoc, line length is 80 chars, I have to put 'final' for every method parameter . Ok the last one I can still coop with, you do not reuse method params. But my normal checkstyle guidelines only give a checkstyle error when I'm actually doing that (and thus not require to put all of them final) . Now, is it allowed to ignore such warnings ? ...
Josh Allen
Ranch Hand

Joined: Jan 15, 2005
Posts: 37
Originally posted by Koen Serneels:

- How can I be sure that this checkstyle is sun's *official* checkstyle for the java language ? I did found lots of info about the sun checkstyle, but none of them are presented in some useable format to plug into a checkstyle plugin (I'm not going to manually verify it)

I think you've answered your own question here. Sun doesn't have any offical checkstyle config file, the only document they have is: Code Conventions for the JavaTM Programming Language which you've already read. So if you want to be sure you are going to have to manually verify your code.

Lint, checkstyle, and the coding conventions are just guidelines--use your judgement.
Jim Janssens
Ranch Hand

Joined: Sep 24, 2004
Posts: 210
Yeah ok, I realize that.
But is there any strict requirement about the code convention for this assignment that you are aware of ?

I have awfully lot of warnings when using the eclipse default checkstyle xml :-)
Matt Sheehan.
Ranch Hand

Joined: Oct 08, 2004
Posts: 63
Hi Koen,
I used checkstyle, too. Unfortunately I made the mistake of waiting until I was almost done with the project. The first time I ran it I had 1500 errors! I wrote some code to traverse the directories and fix simple problems like trailing spaces and tabs. But some of the checks I thought were unnecessary so I commented them out. You'll see at the top of sun_checks.xml it says:

Checkstyle configuration that checks the sun coding conventions from:

- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html

- the Sun Code Conventions at http://java.sun.com/docs/codeconv/

- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html

- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html

- some best practices

The modules I commented out were:

<module name="PackageHtml"/>
<module name="Header">
<module name="RegexpHeader"/>
<module name="AvoidStarImport"/>
<module name="HiddenField"/>
<module name="MagicNumber"/>
<module name="DesignForExtension"/>
<module name="HideUtilityClassConstructor"/>
<module name="FinalParameters"/>

I figured these fell under the 'best practices' and probably weren't required. But I didn't look into too much because by this time I was tired of working on the assignment.

Matt
 
 
subject: Checkstyle