Analyze
C/C++ code: By default, the Klocwork Visual Studio extension runs whenever you save a file. If you prefer, you can use on-the-fly analysis instead so that Klocwork detects issues when you open files and as you type.
C# code: For pure C# or mixed C/C++ and C# solutions, right-click the solution and select Analyze Solution. Or, right-click a project and select Analyze Selection. A full solution or project analysis detects both C/C++ and C# issues.
When Klocwork detects issues in a file, you see issue markers on the left and right margins of the editor. The left markers (chevrons) scroll with the text. When Klocwork detects more than one issue on the same line, the left gutter markers display only the highest-priority issue.
The markers are color-coded by severity:
Left margin icon | Right margin icon | Severity |
---|---|---|
![]() | ![]() | Critical, Error |
![]() | ![]() | Warning, Review |
![]() | Ignored | |
![]() | Critical, Error (server issue) | |
![]() | Warning, Review (server issue) | |
![]() | Ignored (server issue) |
A few notes about the types of issues the Visual Studio extension displays
By default, the Visual Studio extension identifies and displays desktop, system, and server issues. You can change settings to configure which issues show.
Desktop issues
Desktop issues are issues detected by the Visual Studio extension. In connected desktop projects, the Visual Studio extension identifies two types of desktop issues: system issues and local only issues. For example, in the image above:
- The NPD.FUNC.MUST issue highlighted in green is a system issue. This is indicated by the word System after the line number in parentheses: (Line 130, System). A system issue is an issue that Klocwork identified two ways: Klocwork found the issue locally by using desktop analysis, and Klocwork found the issue in an integration build on the Validate server.
- The HA.OPTIMIZE issues highlighted in blue are also issues detected by desktop analysis. These two issues do not have the word "System" following the line number in parentheses. This means the issues that have only been found locally, and have not been found in an integration build on the Validate server.
Show local issues only
In the Klocwork Issues window, click the Show local issues only icon to filter the issues list so that it only shows issues that have been found locally on the desktop and not by an integration build on the Validate server.
Server issues
Server issues are issues that Klocwork has detected in an integration build on the Validate server, but that Klocwork has not detected by using local desktop analysis. This can sometimes occur because of the highly optimized nature of desktop analysis. In the image above, the CWARN.MEM.NONPOD issues highlighted in red are server issues, as indicated by the icon in the left margin of the issue list.
If you modify the source code to fix a server issue, it won't disappear from the issues list until the next integration build runs. Similarly, if you modify the source code to fix a system issue, it won't be detected by desktop analysis and will become a server issue that won't disappear from the issues list until the next integration build runs.
If you're working in standalone desktop mode (that is, not connected mode), all of the issues you see are classed as desktop issues. You will never see any server issues, because you aren't connected to an integration project on the Validate server.
Disable loading server issues
The Visual Studio Extension displays server issues by default. If you don't want to see server issues in your Klocwork Issues list, do the following:
- Open your version of Visual Studio and go to Klocwork > Options.
- Click the Analysis tab.
- In the Server issues section, clear the Load server issues check box.