CSE 70, Fall 2008
Software Engineering
Lab 13 Instructions
Check your style.
Checkstyle is an Eclipse plugin that analyzes source code and reports deviations from coding standards.
Follow these directions to install and use it:
-
Install the plugin.
-
In Eclipse's Help menu,
select Software Updates -> Find and Install...
-
In the Install/Update dialog,
select Search for new features to install and hit Next.
-
Hit New Remote Site and enter the name "Metrics" and the URL
http://eclipse-cs.sourceforge.net/update/.
Hit OK, then Finish.
-
Check the box next to the plugin name and hit Next.
-
Select I accept the terms in the license agreement and hit Next, then Finish.
-
Enable and use the plugin.
- Select the project and choose File/Properties to bring up the Project properties dialog.
- Select the Checkstyle panel, and check Checkstyle active for this project. Also, choose "Sun Checks (Eclipse) - (Global)" from the popup.
- Once you close the properties dialog, the project will be rebuilt. The Problems panel will show many warnings. Take a look at them. How many errors? How many warnings?
- Let's try to customize the warnings for this project; we don't want to fix more than 10,000 warnings:
- Open Window/Preferences
- In the Checkstyle panel, select Sun Checks (Eclipse) and click on Copy. Name it Our Checks.
- Double-click on Our Checks to set, in almost infinite detail, exactly what checks will be done. For the moment, remove the Magic Number check.
- Go back to the project preferences and change the pop to "Our Checks".
- How many warnings and errors now?
- Go back to the Eclipse preferences and try removing/modifying the following checks:
- Operator wrap (in Whitespace)
- No whitespaces after
- No whitespaces before
- Maximum line length (try 100 instead of 80)
- Figure out what of the warnings might be useful. Spend 5 more minutes trying to turn off warning checks that you think don't matter.
- How many warnings do you end up with? Any that seem like potential problems?
-
As you continue work on your project,
use this plugin to measure and improve your
conformance with coding standards.