Getting started with Klocwork Desktop for Java
From current
Contents |
Klocwork Desktop is a GUI alternative to the command-line desktop analysis tool, kwcheck. Like kwcheck, Klocwork Desktop is for developers using IDEs and text editors that aren't supported by Klocwork Insight in the form of an IDE plug-in.
This article will walk you through:
- setting up a local Klocwork project
- analyzing your code
- investigating detected issues
Note: If you access your source code and compilers remotely, then you need to use Klocwork Desktop in remote mode.
Prerequisites and setup considerations
Installation
Before you can analyze your source code, you need to install the Klocwork User package.
An integration project to connect to
Connected desktop is a key step in harnessing the power of Insight. Before you can connect, an integration project must be set up and analyzed on the Klocwork Server. For more information about integration projects, see Integration build analysis.
If you don't connect to an integration project, this is referred to as standalone desktop.
Set up a Klocwork project
For each coherent, buildable component that you work on, you create a Klocwork local project. A local project is a repository for your analysis results and settings. You need to create a project only once for each component you're working on.
- Open Klocwork Desktop with the kwgcheck command, or use the desktop shortcut.
- Mac: Double-click kwgcheck in /Applications/Klocwork User 9.5. Symbolic links are also set up in /usr/local/kw/.
- Note: If you see a login dialog, enter the credentials provided by your Klocwork administrator, or your LDAP or NIS user name and password.
- From the toolbar, click
.
- In the Project name field, enter a name for your project.
- Specify a location for your project.
- By default, the project is created in <home_directory>/klocwork_projects/<project_name>/.kwlp. Because you need to create a local project for each component you work on, we recommend creating the local project in your source tree, at the level where you routinely build this component. Make sure the location you choose has sufficient storage space, because the project can become large over time.
- In the Type section, Connected project is selected by default.
- If your project won't be connected to a project on the Klocwork Server, select Standalone, enter the License Server host and port information, and skip to Step 9.
- If you entered the Klocwork Server host and port information during installation, the Host and Port fields will be populated.
- Enter the information if required and click Next.
- In the Server project name list, select the server project to connect to. If you can’t see the project, click Refresh to update the list.
- Enable the Use secure connection checkbox if a secure connection to the Klocwork Server has been set up.
- Click Next.
- The Build Settings dialog appears. You will see the message: The project has no build settings.
- Copy the command line beginning with "kwant" from this message, and run the command.
- The command will capture build settings for your module, create a build specification, and store it in the proper location, so that Klocwork Desktop will find it.
- Note: If you have already created a build specification with kwant and stored it elsewhere, you need to import the build specification into this project on the command line with kwcheck import.
- For more information on creating a build specification, see Creating a Java build specification.
Analyze your code
In Klocwork Desktop, you should now see a list of files in the Project Navigator.
- Click
in the toolbar.
- The Configure Working Set dialog appears.
- Select all files in your project by checking the root directory. (Later, you may want to create a smaller working set).
- Give your working set a name (such as "All").
- Click Run.
You see the analysis output in the Log Console, and if issues are detected, you see the Issues view with a list of issues.
Investigate detected issues
- Double-click an issue in the Issues view to display the Details view.
- Use Traceback information to investigate the issue. 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.
- To get more information about the type of issue detected, right-click the issue in the Issues view and select More information.
- If you decide the issue needs to be fixed:
- Fix the issue in your code and save your changes.
- Run the analysis again by clicking
in the toolbar.
- If the issue disappears from the list, it's fixed.
- If you decide the issue does not need to be fixed:
- Right-click it in the list and select Change Status.
- Select Ignore from the list.
- Enter a comment in the Comments field.
- Click OK.
Keep your build specification up to date
Whenever you add files or change build settings, you need to recreate your build specification with kwant. If your build specification is out of date, your analysis will not be accurate.
What's next?
- Enabling and disabling specific Klocwork checkers in Klocwork Desktop - Specify which checkers will be run
- Tuning Java analysis - Tune the analysis to your specific software project to improve accuracy


