This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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 ? ...
- 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.
Joined: Sep 24, 2004
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 :-)
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: