tutorial: checkstyle for eclipse - wordpress.com€¦ · web viewtutorial: checkstyle for eclipse...

13
Tutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse 1. Open the Eclipse and Navigate to Help | Software Updates | Find and Install 2. Select the 2 nd radio button - ‘Search for new features to install’

Upload: others

Post on 17-Aug-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

Tutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x

Steps to Setup and use Checkstyle for Eclipse

1. Open the Eclipse and Navigate to Help | Software Updates | Find and Install

2. Select the 2nd radio button - ‘Search for new features to install’

Page 2: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

3. Click on ‘New Remote Site’ -- add Checkstyle in ‘Name’ field and point it to http://eclipse-cs.sourceforge.net/update

Page 3: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

4. Follow the wizard and hit ‘next’ after checking the box.

Page 4: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the
Page 5: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the
Page 6: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

Click on the ‘Finish’ button, it will start downloading the ‘chackstyle’ jar file.

After download, Eclipse performs verification on the downloaded Jar file. It takes few minutes to complete. Displays the verification details and asks for Install/Cancel.

Click on the ‘Install’ button, to install the ‘chackstyle’ plugin.

Page 7: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

5. Create a new Project OR use any existing project6. Build the project 7. In the Package explorer right-click on ‘<project-name>’ and select

Properties | Checkstyle | Check code with Checkstyle

Note: This will run the Checkstyle for this project with the default ruleset [Sun Checks (Eclipse) - (Global)]

8. Navigate to Window | Show view | Other… In the dialog window, Select Checkstyle | Checkstyle violations

9. In the Checkstyle violations view, click on the chart icon in the upper right corner. This will open the pie chart view of the violations.

Page 8: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

Using the Custom Checkstyle configuration file:

Pre-requisite: Copy the ‘MyCheckstyle.xml’ to your local machine in the path: %eclipse_home%\plugins\com.atlassw.tools.eclipse.checkstyle_4.3.2\

1. Navigate to Window | Preferences

Click on ‘New’

2. Provide any appropriate name in the ‘Name’ field and Select ‘External Configuration File’ as Type from the drop down list.

Page 9: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

Click on ‘Browse’ and Select the appropriate configuration XML file. Click on ‘Open’ to return back to previous window

3. One new entry is created for the ‘External Configuration File’. Click ‘Ok’ on the ‘Preferences’ window. It will save the settings and close the window.

Page 10: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

4. In the Package explorer right-click on ‘<project-name>’ and select ‘Properties’. It will open the ‘Properties’ dialog window.

5. On the Properties window (above), select the appropriate name (name provided in step 3) from the drop-down list and click on ‘Ok’.

6. Click on ‘Yes’ to Rebuild the project with the selected Checkstlye configuration and violations will be shown in the View.

Page 11: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the
Page 12: Tutorial: Checkstyle for Eclipse - WordPress.com€¦ · Web viewTutorial: Checkstyle for Eclipse Pre-requisite: Eclipse 3.x Steps to Setup and use Checkstyle for Eclipse Open the

Modifying the default ‘Rule Set’ configuration

Note: This is applicable to the particular instance of Eclipse

1. Navigate to Window | Preferences | Checkstyle and Click on New… 2. Select Internal Configuration, enter a name and description. Click

Import… and navigate to ECLIPSE_HOME/plugins/com.atlassw.tools.eclipse.checkstyle_x.x.x and select any of the existing rules XML file (for e.g. MyCheckstyle.xml). This will import all Sun Eclipse rules for the new custom ruleset. Also note that Checkstyle will create a new custom ruleset xml file under WORKSPACE/.metadata/.plugins/com.atlassw.tools.eclipse.checkstyle/internal_config__xxxxxxxxxxx.xml. Click OK.

3. Double click the new ruleset. It opens a dialog window. Do the required modification and Apply.

4. Click OK. It will rebuild the project and violations will be shown in the View.