Cheat sheet for Klocwork Desktop Java Plug-in for Eclipse

From Insight-9.2

Contents

Overview

These instructions assume that you already have set up a Klocwork project. See Getting started with Klocwork Desktop Java Plug-in for Eclipse for more information.

  1. Select the project in the Project Explorer and click Java eclipse run icon.jpg or right-click the project name and choose Klocwork > Run Klocwork for Java from the pop-up menu.
  2. Review and investigate using traceback, issue help information and sorting and grouping features.
  3. Locate and fix local issues.
  4. Re-run the analysis to confirm your fix.
  5. Cite the remaining issues.
  6. When you're finished editing your code, check it back in.

Note: If there are issues you expect to see in your issue list that aren't there or there are more issues listed than you want to see, you may need to adjust your filter settings. Click Filter icon.jpg to access and change your filter settings.

Tips and tricks

Locate and fix "Local" issues in a project

Filtering by taxonomy and origin isolates issues in your list according to:

  • coding standard (such as MISRA C or MISRA C++) or an internal coding policy (such as one focusing on null-pointer dereferences), so you can see how you're performing against the policy or standard. If there are no custom taxonomies in place, the default taxonomies are C and C++, C# and Java.
  • only those issues you're responsible for injecting into your project. These are local issues. In contrast, system issues are those that were detected in the file in the last integration project analysis and are present in your desktop project. By default, Klocwork Desktop shows local and system issues.

If your company hasn't set up custom taxonomies, you can still filter to show local issues.

Tip: You can also group issues by taxonomy or sort by taxonomy and origin.

Note: If you're using continuous analysis while you work in your editor, any new issues detected after you've saved your file are likely local issues.

  1. From the Klocwork Issues view, click Filter icon.jpg to access your filter settings.
  2. Under Taxonomy, make sure that only the taxonomy of interest is checked.
  3. To make sure you only see new issues you're responsible for injecting into the project, add a check to Show local issues only, which is under Origin, the last setting in the dialog.
    Origin filter.png
    When this is checked, you only see "Local" listed under the Origin column in the Klocwork Issues view. This setting is relevant only for connected desktop projects.
    Your filtering changes take effect immediately.

Tip: If you want to see system issues in the list (and your viewer), you'll need to disable Show local issues only in your filter settings.

Locate and fix "System" issues in a project

If your manager has referred you to a system issue to fix or investigate, you can locate it in your desktop project, fix it and then confirm the fix by re-analyzing your project. System issues are those issues that are detected in both your desktop project and the integration build analysis.

Note: You only see system issues in your results if you have a connected desktop.

Typically, audit staff examine detected issues from the integration build analysis in Klocwork Review. Klocwork Review is the Web interface for Klocwork reports, issue analysis and Source Cross-Reference for the integration project.

Klocwork Review provides a System ID for each detected issue; By default, your desktop does not identify issues by System ID in the issue list.

Show the System ID in your issue list

You can show the System ID in your issue list by configuring your columns.

  1. Click the View menu icon eclipse.png View Menu icon to the far right and select Configure columns.
  2. Add a check to System ID.
    Any issue that was also detected in the integration build analysis (the results of which can be seen in Klocwork Review), will show a System ID.
  3. To view the issue in Klocwork Review, click the ID hyperlink.
    It's a good idea to get an updated view of traceback for the issue on your desktop. The file may have changed since the last integration build analysis.
  4. To view more current traceback for the issue on your desktop, double-click the issue in the Klocwork Issues view and investigate the identified traceback events.
  5. Fix the issue in your editor and save your file.
    If the issue disappears from the list after the analysis, that means it's fixed.

Troubleshooting: If your issue list is long and you don't see the issue in the list, you can use filtering and grouping tools to pinpoint the system issue. Instructions for filtering and grouping are provided below.

Filter by file

Tip: Make sure that your filters aren't set to "Show Local issues only".

  1. Go to your Filters dialog by clicking the Filters icon in the Klocwork Issues view:
    Filter icon.jpg
  2. Under Show issues for, click Selected element and its children:
    You can also filter by status, severity or owner to help pinpoint the issue.
  3. Select OK.
    When you select folders or source files in the left pane, the issue list displays only issues detected in the item(s) you select.
  4. If you can see the system issue, continue with Step 3 from Show the System ID in your issue list. If you don't see the issue, try grouping by issue type (see below).

Group by issue type

  1. Click the View menu icon eclipse.png View Menu icon to the far right and select Group by > Issue Type.
  2. View the contents of the Issue type group.
  3. If you can see the system issue, continue with Step 3 from Show the System ID in your issue list.

Tip: You can also group by taxonomy, severity, status, directory and owner. Select None to ungroup the issues. If you've grouped by taxonomy and the same issue was detected in each taxonomy, you'll see that one issue listed twice (in each applicable taxonomy). This is the only time you'd see the same issue listed twice.

Show or hide columns in the Klocwork Issues view

You can customize the Klocwork Issues view to show or hide columns or to change the order in which they appear. For example, you may wish to hide the severity column, or you may want to show the Ref or System ID columns, which are hidden by default.

The Ref column provides extra information about detected issues, such as MISRA rule numbers (if this reference information was configured).

The System ID column provides the ID number for issues that were also detected in the integration build analysis. The ID is a hyperlink that allows you to view the issue as it appears in Klocwork Review traceback.

  1. Click the View menu icon eclipse.png View Menu icon to the far right and select Configure columns.
  2. Add a check to display a column, or clear the checkbox next to the column you want hidden.
  3. Select a column and click Move Up or Move Down to change the order of the columns.
    Note: You can't hide or change the position of the Description column. It will always appear first.

Disconnecting from the Klocwork Server

You can disconnect your project if you wish to change to standalone mode from connected desktop.

  1. Right-click the project in the Project Explorer, and select Properties.
  2. Expand Klocwork.
  3. Add a check to Enable project specific settings.
  4. Click the Synchronization tab.
  5. Clear the information from the Klocwork Server host and port fields.

Updating License Server information

License Server host name and port number are typically added during installation. However, if this information changes, you can update the server information in the Settings dialog.

  1. Go to Window > Preferences > Settings.
  2. Enter the License Server host and port, as required.

Analyze the project, subdirectory or selected files

Select the project, subdirectory or group of files in the Project Explorer and click the Klocwork icon on the toolbar Klocwork check icon.jpg.

To trigger an analysis, you can also make your selection, right-click and select Klocwork > Run Klocwork.

Clean Klocwork issues from your project

Typically, the Klocwork "Clean" feature is not part of your Klocwork workflow, but there are those rare occasions when this feature is useful.

For example, if:

  • you want to override an incremental analysis and trigger a full project analysis
  • you are working on a large project in standalone desktop mode (not connected to a project on a Klocwork server), and you want to remove all of your issues in Fixed or Not in Scope State

Right-click a project in the Project Explorer and select Klocwork > Clean...

  • By default, the "Clear cached Klocwork analysis data" option is selected. This option triggers a full analysis on your project, but retains your issue-status changes and comments.
  • "Clear fixed and not-in-scope issues" permanently clears issues from your project that are in Fixed and Not in Scope state.
Note: The default filter settings automatically filter out issues in Fixed and Not in Scope state. Filter settings are a good way of hiding specific issues in the list without permanently removing them.
  • "Clear all issues" removes all issues, plus any issue-status changes and comments you have made. The next time you run an analysis or synchronize with the server project (if you have a connected project), the Klocwork Issues view will display detected issues.

See also