Java code Formater and Checkstyle configuration for development
Clone this wiki locally
Author is Ruslan Dyachenko.
After finishing work under your new check you need format your code with Checkstyle format to avoid error messages while building Checkstyle project with your check.
1. ATTENTION: THIS FORMATTER DOES NOT COVER ALL CASES. Use this formatter which is approximate to origin Checkstyle format. Run Eclipse: Windows — Properties — Java — Code Style — Formatter and import it. Apply formatter on your code.
- Follow Checkstyle check configuration*
1. Prerequisite, checkout checkstyle code, instruction is here first point, from this folder you will need suppress.xml, java.header, … .
2.1. Right click on project where you have written your check — Preferences — Checkstyle — ‘Local Check Configurations’ tab — New.
2.2. In opened dialog choose Type – External Configuration File. Write a Name of a new configuration. Browse Location: go to the Checkstyle project folder and choose “checkstyle_checks.xml” from latest release that eclipse-cs plugin is build here, example for 6.11 release file.
ATTENTION: in build system we use latest release of checkstyle, so your configuration in eclipse-cs is not guaranty of covering all violations, so usage of “mvn verify” command is still mandatory before PullRequest.
Download file and put in profile filesystem path. Press Additional properties… button:
2.3. Press Find unresolved properties button:
2.4. In opened dialog press Yes:
2.5. Now you need to add values for properties.
Press Edit…. In Value text field paste a path to java.header file which is in Checkstyle project folder:
Press Edit…. In Value text field paste a path to import-control.xml file which is in Checkstyle project folder:
Press Edit…. In Value text field paste a path to suppressions.xml file which is in Checkstyle project folder:
Press Edit…. In Value text field write ignore:
2.6. Press Ok and return to the Checkstyle preference page. Choose Main tab, from combo list choose your new configuration. Press Ok:
2.7. Right click on your project — Checkstyle — Activate Checkstyle. Fix all checkstyle warnings.