Getting started with Klocwork Desktop Java Plug-in for Eclipse

Getting started with Klocwork Desktop Java Plug-in for Eclipse

The Klocwork plug-in for Eclipse helps you detect and fix issues before check-in.

Information and instructions below also apply to IBM Rational Application Developer for WebSphere. See also Supported IDEs.

You can also customize project settings, issue filters and analysis settings to your own preferences. For more information about these features, see the topics below.

Set up a local project

For each coherent, buildable component that you work on, create a local project -- a repository for your analysis results and settings. You need to set up a project only once for each component you work on.

Capture and specify your build settings

You need to capture and specify your build settings only if:

  • your source files are not part of the Java Development Toolkit (JDT) project, and
  • you build with Ant or Maven

To capture build settings, see Creating a Java build specification.

To specify build settings:

  1. In the Project Properties, select Klocwork Build Settings.
  2. Select Use build specification file, browse to the build specification you created, and click OK.

The properties are saved for the selected project and used when you run your next analysis. You only have to specify build settings once for your project, as long as your updated build specification file remains in the same location.

Connect to a project on the Klocwork Server

You get the most from static code analysis when you connect a small local project to a larger project on the Klocwork Server. The small local project is analyzed quickly while incorporating Klocwork knowledge bases generated on the server where additional source files were analyzed (for example, shared libraries). Connecting to a server project also allows you to share issue status information with the integration build analysis and among team members. You can run a standalone desktop analysis, but the analysis only derives knowledge from the local project's source files.

You perform this step only once for each project.

  1. In the project properties view navigator, expand Klocwork and select Enable project specific settings.
  2. Click the Synchronization tab.
  3. Ensure that the Klocwork Server host and port information is correct.
  4. In the Project name list, select the server project you want to connect to.
  5. Enable the Use secure connection checkbox if a secure connection to the Klocwork Server has been set up.
  6. Click OK.
    When you set up your connection, synchronization occurs between the integration project and your desktop project, pulling configuration information from the integration project.
    You only have to do this step once for each project.

Analyze your code

Select the project and click in the toolbar.

When the analysis is complete, the Klocwork Issues view shows the analysis results.

In connected desktop projects, local issues are those you've introduced since the last integration build analysis; system issues are those that also exist in the integration build.

Investigate detected issues

  1. Double-click an issue in the Issues view to display the Details view.
  2. Use Traceback information to investigate the issue. To see traceback, click or . Traceback lines link to events that contributed to the issue. Clicking a line in the traceback brings up the location in the file where the issue appears, with a bug marker on the left.
  3. Get help on an issue type by right-clicking the issue in the Issues view and selecting More information.

Fix defects and ignore the rest

For a real defect:

  1. Fix the issue in your code and save your changes.
  2. Run the analysis by clicking .
    If the issue disappears from the list, it's fixed.

For an issue that doesn't need to be fixed:

  1. Right-click the issue in the list and select Change Status > Ignore.
  2. Enter a comment and click OK.

If you're connected to a project on the Klocwork Server, your changes are now visible to other developers, and in Klocwork Static Code Analysis. Your desktop project is also updated with any changes made by other developers. This happens even before another integration build analysis has been run.

Keep your build specification up to date

If you captured and specified your build settings manually, whenever you add files or change build settings, recreate your build specification with kwant or kwmaven and save it to the same location. If your build specification is out of date, the analysis will not be accurate.