Analysis Scope of Polyspace as You Code
Polyspace® as You Code is a static code analysis software meant for regular use by C/C++ developers within their Integrated Development Environments (IDEs). Polyspace as You Code can find bugs and coding standard violations on the file that is currently active in the IDE.
This topic outlines the analysis scope of Polyspace as You Code and the benefits of using Polyspace Bug Finder or Polyspace Bug Finder Server for full integration analysis.
Results Involve Current File Only
Polyspace as You Code is designed to provide results that are of immediate interest to developers. So the tool only shows results in files that you are currently working on. After installing the Polyspace as You Code extension, each time you open or save a file in your IDE, the analysis runs silently in the background and highlights issues in the file.
All issues found originate within the source file itself and can also be fixed within this file. You can either implement the fix at the highlighted location or another related location still within the current file. For instance, the following integer division by zero result is shown with related events on previous lines. You can implement a guard against division by zero just before the division or implement some checks on inputs to the function where the division is performed.
Results that involve multiple files, for instance, declaration mismatch across files or data flow between functions in different files, are not shown in the default Polyspace as You Code analysis. To see complete integration results on your project, analyze your project with Polyspace Bug Finder on your desktop or with Polyspace Bug Finder Server on a continuous integration (CI) server.
Some checkers that are not likely to find issues in a single-file analysis are completely disabled in Polyspace as You Code. See Checkers Deactivated in Polyspace as You Code Analysis.
Headers Included in Current File Not Analyzed
When you analyze a source file that #include
-s a headers, that are in the
same folder as the source (or in subfolders), Polyspace also analyzes these headers and in the case of the Polyspace as You Code extension in Visual Studio code, reports findings if it finds
any. You can see which headers contain findings in the HEADERS view
of the extension. See Open Additional Polyspace Views. All other
header files are taken into account for compilation but not analyzed further.
The reason for this default behavior is the following:
Headers close to sources:
The underlying assumption is that headers in the source folders are more closely related to the current source file and are therefore relevant for the analysis. A developer might want to fix issues reported in these headers.
Headers in non-source folders:
Headers in other folders typically come from third party libraries and are not analyzed.
You can change this default behavior using these options:
Generate results for sources and (-generate-results-for)
(Polyspace Bug Finder): Use this option to expand the scope of which headers must be analyzed.Do not generate results for (-do-not-generate-results-for)
(Polyspace Bug Finder): Use this option to expand the scope of which headers must not be analyzed.
You can also see findings in header files by explicitly analyzing the headers.