Using Klocwork Inspect to review code
From Insight-9.0
Watch a demo of this feature. Here's a link to our video gallery.
Accessing Klocwork Inspect
- Double-click the Klocwork Inspect shortcut or go to:
http://<KlocworkServer-host>:<KlocworkServer-port>/codereview
- For example:
http://server11:8080/codereview
- Note: If a secure connection to the Klocwork Server has been set up, use https in your URL instead of http.
- If you don't know the Klocwork Server host and port, contact your Klocwork administrator.
- If the prerequisites have been met, you'll see the login page.
- A user name and password aren't required unless your Klocwork administrator has set up access control. If you get an error, try entering your LDAP or NIS user name and password.
- Note: You can check "stay logged in", so that you won't have to log in again in future.
Your Klocwork Inspect headquarters: your feed page
When you log in, you see the feed page. The feed page aggregates various events related to code reviews in your environment.
What you see...
The feed page is where you see:
- *revisions checked in to SCM
- any comments or actions that arise from a code review
- *pre-checkin reviews that you have permission to see and that match your filter settings
*You only see revisions for projects that:
- you have permission to see, and
- match your filter settings
- have been created and set up (see Klocwork Inspect prerequisites)
Each revision may contain one or more files that have been checked in.
What you can do...
From your feed page, you can:
- access the diff view to see checked-in revisions and their previous versions at any time
- get a link to the revision to send to other team members for a team review
- access the entire history for a file
- subscribe to the RSS feed to receive notifications of checked-in code, pre-checkin reviews, and comments and actions arising from reviews (see "tip" below)
- view, change or delete your filter settings
- link from comments or actions to the diff view where they were first entered
RSS feed tip: Remember to set your filters (see below) before subscribing, so you only see notifications involving users or aspects of the code base that interest you.
Personalizing Klocwork Inspect with filters
Personalize your feed page with filters so you see only the information that you want to see.
The filters dialog is available on the feed page. You can filter by:
- path
- user (person committing the revision)
If you filter by path, you must provide the absolute path that you want to apply to the selected project.
Note: If you notice that a project is missing from the Project list, it means that you don't have access to that project. See Enabling access to Klocwork projects.
Tips:
- If you are filtering by path, but want to see all files in a project, just enter a slash ("/") in the path field
- You must save your filter setting(s) and then apply them by selecting them
- Note: The filter name cannot exceed 16 characters.
- You can create several filters and apply them all or in combination
- Filter settings remain in effect on your feed page until you change them again. If you're not seeing something you'd expect to see, then check the filtering you have in place.
Inviting others to review code
Klocwork Inspect allows users to view committed code at any time, as well as add comments and assign actions. However, from time to time, you may wish to invite others to a team review.
From the feed page, locate your revision of interest and click link (at the far right). Or, right-click the link and open it in a new window or tab and copy the link from there.
This will provide you with a URL that contains the revision ID that you can send to your invitees.
Note: It's possible that one or more invitees may not have access to a project. If they see a message indicating "insufficient permissions" to view the code, they'll need to follow up with the Klocwork administrator. See also Enabling access to Klocwork projects.
Viewing revisions in the diff tool
From your feed view, click the diff link next to the revision of interest.
The diff tool provides:
- the option of a side-by-side revision comparison or a merged view
- the ability to make comments or assign actions
- issue detection in the file being reviewed if it was initially set up as a pre-checkin review
If you are participating in a team review, click the link from your invitation to access the diff tool for the revision/project of interest.
The diff tool displays a side-by-side comparison, with the most recent revision on the right and the previous revision on the left.
Additions are highlighted in green, edits are highlighted in red and lines that have been removed are highlighted in grey.
If you wish to combine the revisions, click the merged view checkbox above the diff view.
If a line of code containing comments or actions is deleted from a file, you will not be able to see those particular comments or actions in that file.
Adding comments to the code
Comments added to the code are highlighted in yellow in the diff view and on your feed page.
To add a comment, move your cursor to the line of code you want to comment on and select the comment icon.
Any responses to comment are handled as "threaded conversations".
You can link directly to comments or actions in the diff view from your feed page.
Assigning actions
Klocwork Inspect allows you to assign yourself or others action items to work on.
- Move your cursor to the line of code pertaining to the action item you want to assign.
- Click the action icon.
- Type the action item.
- In the "Responsible" field, start typing the name of the person you wish to assign it to.
- The default assignee is the person who committed the file. When you type in this field, auto-completion fills in any matching names.
- Action items are fed to the assignee's "todo" list.
Tracking the review in your to-do list
Action items are piped into your todo list.
When your action is complete, check done.
Completed actions are moved from to the "done actions" queue. You can filter your todo list to view todo actions, done actions or all actions.
Viewing traceback in Klocwork Inspect for detected issues
You'll see detected issues and their traceback information during pre-checkin reviews, if the pre-checkin review was set up to load locally-detected issues.
Detected issues show up as links in the diff view.
The link tells you the:
- status of the issue (only locally-detected issues are shown)
- issue code, which is the short form of the issue type detected. You can get more information about these detected issues in Detected C/C++ Issues and Detected Java Issues
- issue message
- responsible person (the person launched the pre-checkin review)
When you click the link, you access traceback information for the detected issue, inline as you're reading code.
Klocwork Inspect loads code snippets instead of entire files, quickly providing you with information about problematic statements that contributed to the detected issue. These quick summaries are called traceback lines and appear in bold, italics.
Simple navigation allows you to jump to/from the previous or next traceback line. A details link indicates an issue that spans multiple functions and methods.
