How to use CheckStyle plugin in Eclipse

Problems found by CheckStyle in Editor
Problems found by CheckStyle in Editor

CheckStyle is a popular Java tool to ensure that source code adheres to a coding standard and is useful to enforcing style in a team or company. It is available for Eclipse as the Elipse CheckStyle plugin. CheckStyle is packaged along with this plugin and does not need to be separately installed.

  • Install: To install CheckStyle in Eclipse, go to Help -> Install New Software and add the URL http://eclipse-cs.sf.net/update to add the plugin.

  • CheckStyle comes pre-installed with the style of Google and other configuration files. You can view these listed in Window -> Preferences -> CheckStyle.

  • Add style: You can also add your own style configuration files by choosing New -> External Configuration File in the CheckStyle preferences dialog.

  • To set the styles to be applied on a project, right-click on it and choose Properties -> Checkstyle and choose the style you want from the dropdown.

  • Activate style: Activating CheckStyle for a project makes it check the project source files whenever they are saved. To do this, right-click on the project and choose CheckStyle -> Activate Checkstyle.

  • To manually check the style, right-click on the project and choose Properties -> Check Code with Checkstyle.

Tried with: CheckStyle 6.2, Eclipse 4.4.1 (Luna) and Ubuntu 14.04

Advertisements

One thought on “How to use CheckStyle plugin in Eclipse

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s