Import and merge Helix QAC projects into your Klocwork analysis results
As of Klocwork 2021.2, you can import QAC results into the same tables produced by the native Klocwork analysis, allowing you to browse Klocwork defects and QAC diagnostics in the same project in the Klocwork Portal. To enable this, use kwbuildproject with the additional option --qac-project
:
kwbuildproject <other analysis options> --qac-project <path to your QAC project>
Similar to kwqacimport, kwbuildproject requires that an installation of Helix QAC exists on the build machine. By default, it searches for those tools in your PATH. This can be overridden by providing an optional switch --qac-install-dir
:
kwbuildproject <other analysis options> --qac-project <path to QAC project> --qac-install-dir <PATH to Heix QAC 21.2 installation>
Below are some useful examples for getting started with the Klocwork and Helix QAC integration. Note that all of these examples use Visual Studio 2017.
Example 1
First, let's do an analysis of zlib project using both Klocwork and Helix QAC on Windows, and loading the combined result into same project in Klocwork Portal, as follows:
- Download the 'zlib' project from github.
- Extract the files locally to a directory, for example 'D:\Sources\zlib'.
- Open the Visual Studio command prompt and run the command
cd D:\Source\zlib
. - Generate Klocwork buildspec running native build using kwinject:
kwinject nmake -f win32/Makefile.msc
- Open the Helix QAC GUI. Create a Helix QAC project (for example, in
D:\QAC_Projects\zlib
), synchronize it with your source code, and analyze the project. Note that you do not need QAC GUI open for the rest of this example. - Create a new directory such as
D:\Klocwork_Tables
. - Next, run Klocwork analysis in hybrid mode using kwbuildproject:
kwbuildproject -o D:\Klocwork_Tables\zlib --qac-project D:\QAC_Projects\zlib D:\Sources\zlib\kwinject.out
This command runs Klocwork analysis and stores its results in the
D:\Klocwork_Tables\zlib
directory. During the analysis, the Helix QAC results are imported and loaded into the same tables directory. - Create the 'zlib' project in the Klocwork Portal using kwadmin:
kwadmin create-project zlib
- Lastly, load the generated tables:
kwadmin load zlib D:\Klocwork_Tables\zlib
Example 2
Next, let's do an analysis of the hybrid C/C# project 'dotzlib', using Klocwork for C# analysis and Helix QAC for C code analysis. In this example, we use the same 'zlib' project as in Example 1 above.
- Open the file
D:\Sources\zlib\contrib\dotzlib\DotZLib.sln
in Visual Studio and follow prompts to generate missing project parts. - In Developer Command Prompt for Visual Studio 2017, run:
cd D:\Sources\zlib\contrib\dotzlib
- Next, generate the C# build specification using kwinject:
kwinject msbuild /p:UseSharedCompilation=false /p:ProduceReferenceAssembly=false
- Run Klocwork analysis in hybrid mode using kwbuildproject:
kwbuildproject -o D:\Klocwork_Tables\zlibdotnet --qac-project D:\QAC_Projects\zlib D:\Sources\zlib\contrib\dotzlib\kwinject.out
- Create the 'zlibdotnet' project in the Klocwork Portal using kwadmin:
kwadmin create-project zlibdotnet
- Lastly, load the generated tables:
kwadmin load zlibdotnet D:\Klocwork_Tables\zlibdotnet
'dotzlib' is a small project, and Klocwork C# checkers in default configuration may not find any issues. You can enable more checkers and re-run analysis to expand your analysis results.
Example 3
Finally, let's try showing the analysis results of the 'zlib' project with Helix QAC analysis, while using issue information produced by Klocwork.
This is a modified version of Example 1. In this example, we will only run a very shallow analysis using the Klocwork engine, and will generate the actual defects by using only the Helix QAC engine. The data generated by the shallow Klocwork analysis allows code navigation in the Klocwork Portal, and also produces metrics and trends.
- Using the build specification produced in Example 1, run shallow Klocwork hybrid analysis using kwbuildproject:
Kwbuildproject --classic --no-lef -o D:\Klocwork_Tables\zlib_shallow --qac-project D:\QAC_Projects\zlib D:\Sources\zlib\kwinject.out
In the above command,
--classic --no-lef
is the combination of switches resulting in no Klocwork defect analysis run, as well as the directive to use only the classic engine for production of code browsing information and metrics. - Create the 'zlib_shallow' project in the Klocwork Portal using kwadmin:
kwadmin create-project zlib_shallow
- Lastly, load the generated tables:
kwadmin load zlib_shallow D:\Klocwork_Tables\zlib_shallow