Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

Configuring live links in Klocwork reviews

You can create a replacement schema to automatically create hyperlinks in commit messages, actions, and comments given a unique identifier such as a defect number or ID. You can access the replacement schemas or create a new replacement schema on the Settings tab in Code Review.

A replacement schema consists of two parts: a regex and a URL pattern. A regex is a regular expression that matches a particular text pattern in a review comment, a commit message, or an action. The regular expression must contain one or more capturing groups that you can use as a variable in the URL pattern. The URL pattern is a template for the link's target URL. When a regular expression matches some text, it will be replaced with a link who's target URL is generated from the URL pattern with any arguments filled in.

Default replacement schemas

Code Review provides the following pre-defined replacement schemas:

Replacement schema Description
kw\:(\d+) Creates a link to an issue in Code Review.
line\:(\d+) Creates a link to a line in the current file-revision.
ref\:(\d+) Creates a link to another revision in Code Review.
([hH][tT][tT][pP][sS]?://[^\p{Space}]+) Creates a link given a URL.

Default format elements

In addition to the default replacement schemas, Code Review also provides the following format elements that you can use in your own custom replacement schemas:

Format element Description
{file_revision} The Klocwork file-revision ID. The {file_revision} is a required parameter that must be present, otherwise the text will not be converted to a link. For this reason, the {file_revision} cannot be used in commit-messages.
{project} The name of the project, to which the revision belongs.

Create a replacement schema

To create a new replacement schema, click Create a new schema.

In the Regex field, enter the regex expression that matches the pattern that you want to replace. Be sure to include one or more capturing groups in your expression. For example:

ref\:(\d+)

In the URL pattern field, enter the replacement URL pattern, including format element, into which the capturing group will be injected. For example:

/codereview/CodeReview.html#revision_goto:revisionId={0}

Note: The URL replacement pattern must contain a format element for each capturing group in the regex field. You can specify the same format element multiple times. For a list of supported expressions, refer to the Java class documentation.

Click Create to save the schema. If the regex pattern is matched in the text of a comment, action, or commit message, it will be replaced by the specified URL pattern.

Example 1

The following example replaces a user's Twitter handle with a link to the user's Twitter page:

Regex:

@(\w+)

URL pattern:

https://twitter.com/{0}

Example 2

The following example replaces a simple keyword phrase and ID number with a link to the corresponding record in a bug tracking system:

Regex:

[bB][uU][gG][\p{Space}|:]*(\d+)

URL pattern:

http://example.com/bugs?id={0}&project={project}

The url pattern above uses the default {project} format element.