getSummary
View number of Polyspace results organized by results type (Bug Finder) or color and file (Code Prover)
To summarise coding rule violations, use 'codingStandards'
as the
resultsType
. (since R2024b) For information, see Version History.
Description
returns the distribution of results of type resSummary
= getSummary(resObj
, resultsType
)resultsType
in a Polyspace® results set, resObj
. The results set
resObj
can be a Bug Finder results set denoted by a polyspace.BugFinderResults
object or a Code Prover results set denoted by a
polyspace.CodeProverResults
object.
For instance:
If you choose to see Bug Finder defects, you can see how many defects of each type are present in the result set, for instance, how many non-initialized variables or declaration mismatches.
If you choose to see Code Prover run-time checks, you see how many red, orange, gray and green checks are present in each file.
If you choose to see coding standard violation, you see violation of supported coding standards.
Examples
Read Existing Bug Finder Results to MATLAB Tables
This example shows how to read Bug Finder analysis results from MATLAB®.
Copy a demo result set to a temporary folder.
resPath=fullfile(polyspaceroot,'polyspace','examples','cxx','Bug_Finder_Example', ... 'Module_1','BF_Result'); userResPath = tempname; copyfile(resPath,userResPath);
Create the results object.
resObj = polyspace.BugFinderResults(userResPath);
Read results to MATLAB tables using the object.
resSummary = getSummary(resObj, 'defects');
resTable = getResults(resObj);
Run Bug Finder Analysis and Read Results to MATLAB Tables
Check for violations of supported coding standards in the demo file
numerical.c
. Configure these options:
Specify GCC 4.9 as your compiler.
Save the results in a
results
subfolder of the current working folder.
proj = polyspace.Project % Configure analysis proj.Configuration.Sources = {fullfile(polyspaceroot, 'polyspace', ... 'examples', 'cxx', 'Bug_Finder_Example', 'sources', 'numerical.c')}; proj.Configuration.TargetCompiler.Compiler = 'gnu4.9'; proj.Configuration.ResultsDir = fullfile(pwd,'results'); % Run analysis bfStatus = run(proj, 'bugFinder'); % Read results resObj = proj.Results; bfSummary = getSummary(resObj, 'defects');
Check for Violations of Coding Standards and Read Results to MATLAB Tables
Run a Polyspace
Bug Finder™ analysis on the demo file numerical.c
.
Copy the file numerical.c
into a temporary location.
proj = polyspace.Project; % Configure analysis proj.Configuration.Sources = {fullfile(polyspaceroot, 'polyspace', ... 'examples', 'cxx', 'Bug_Finder_Example', 'sources', 'numerical.c')};
Specify GCC 4.9 as the compiler and save results in the subfolder
results
.
proj.Configuration.TargetCompiler.Compiler = 'gnu4.9'; proj.Configuration.ResultsDir = fullfile(pwd,'results');
Optionally, Disable Bug Finder defects.
proj.Configuration.BugFinderAnalysis.EnableCheckers = 0;
Enable MISRA C™:2023 and CERT® C coding standards.
% Configure coding standards proj.Configuration.CodingRulesCodeMetrics.EnableMisraC2023 = true; proj.Configuration.CodingRulesCodeMetrics.MisraC2023 = 'all'; proj.Configuration.CodingRulesCodeMetrics.EnableCertC = true; proj.Configuration.CodingRulesCodeMetrics.CertC = 'all';
Run the analysis read results.
% Run analysis bfStatus = run(proj, 'bugFinder'); % Read results resObj = proj.Results;
Summarize coding standard violations.
bfSummary = getSummary(resObj, 'codingStandard');
The object bfSummary
is two-element cell array. One of the
elements is a table containing the MISRA C:2023 violations, and the other is a table containing CERT C violations.
Read Existing Code Prover Results to MATLAB Tables
This example shows how to read Code Prover analysis results from MATLAB.
Copy a demo result set to a temporary folder.
resPath = fullfile(polyspaceroot,'polyspace','examples','cxx','Code_Prover_Example', ... 'Module_1','CP_Result'); userResPath = tempname; copyfile(resPath,userResPath);
Create the results object.
resObj = polyspace.CodeProverResults(userResPath);
Read results to MATLAB tables using the object.
resSummary = getSummary(resObj, 'runtime');
resTable = getResults(resObj);
Run Code Prover Analysis and Read Results to MATLAB Tables
Run a Polyspace
Code Prover™ analysis on the demo file single_file_analysis.c
.
Configure these options:
Specify GCC 4.9 as your compiler.
Save the results in a
results
subfolder of the current working folder.Specify that a
main
function must be generated, if it does not exist in the source code.
proj = polyspace.Project % Configure analysis proj.Configuration.Sources = {fullfile(polyspaceroot, 'polyspace', 'examples',... 'cxx', 'Code_Prover_Example', 'sources', 'single_file_analysis.c')}; proj.Configuration.TargetCompiler.Compiler = 'gnu4.9'; proj.Configuration.ResultsDir = fullfile(pwd,'results'); proj.Configuration.CodeProverVerification.MainGenerator = true; % Run analysis cpStatus = run(proj, 'codeProver'); % Read results resObj = proj.Results; cpSummary = getResults(resObj, 'readable');
Input Arguments
resObj
— Bug Finder or Code Prover results
polyspace.BugFinderResults
or
polyspace.CodeProverResults
object
Bug Finder or Code Prover results set, specified as a polyspace.BugFinderResults
or polyspace.CodeProverResults
object respectively.
resultsType
— Type of Bug Finder or Code Prover analysis result
'defects'
| 'runtime'
| 'misraC'
| 'misraCAGC'
| 'misraCPP'
| 'misraC2012'
| 'jsf'
| 'certC'
| 'certCpp'
| 'iso17961'
| 'autosarCPP14'
| 'metrics'
| 'customRules'
| 'codingStandards'
Type of result, specified as a character vector. The default for a Bug Finder
results set is 'defects'
and the default for a Code Prover results
set is 'runtime'
.
Entry | Meaning |
---|---|
'defects' | Bug Finder defects |
'runtime' | Code Prover checks for run-time errors |
'metrics' | Code complexity metrics |
'codingStandards' | All coding standards. For a list of supported coding standards, see Coding Standards. |
'misraC' | MISRA C:2004 rules |
'misraCAGC' | MISRA C:2004 rules for generated code |
'misraCPP' | MISRA™ C++ rules |
'misraC2012' | MISRA C:2012 rules |
'jsf' | JSF® C++ rules |
'certC' | CERT C rules |
'certCpp' | CERT C++ rules |
'iso17961' | ISO®/IEC TS 17961 rules |
'autosarCPP14' | AUTOSAR C++ 14 rules |
'metrics' | Code complexity metrics |
'customRules' | Custom rules enforcing naming conventions for identifiers |
'guidelines' | Polyspace Guidelines checkers |
Output Arguments
resSummary
— Distribution of Bug Finder results by result type or Code Prover run-time checks by check color and file
table | cell array of tables
Distribution of results, specified as a table. For instance:
If you choose to see a summary of Bug Finder defects, an extract of the table looks like this:
Category Defect Impact Total Concurrency Data race High 2 Concurrency Deadlock High 1 Data flow Non-initialized variable High 2 The table above shows that the result set contains two data races, one deadlock and two non-initialized variables.
If you choose to see a summary of Code Prover run-time checks, an extract of the table looks like this:
File Proven Green Red Gray Orange file1.c
92.0% 87 3 2 8 file2.c
97.7% 41 0 1 1 The table above shows that
file1.c
has:3 red, 2 gray and 8 orange checks.
92% of operations proven.
In other words, of every 100 operations that the verification checked, 92 operations were proven green, red or gray. See Code Prover Result and Source Code Colors.
If you choose to see a summary of coding standard violations,
resSummary
is an array of table, where each table represents the results of one coding standard. Each table in the array shows the number and description of a violated rule.
For more information on MATLAB tables, see Tables.
Version History
Introduced in R2017aR2024b: Input values corresponding to individual coding rules not recommended
These values of the input argument resultsType
are no longer
recommended:
Entry | Meaning |
---|---|
'misraC' | MISRA C:2004 rules |
'misraCAGC' | MISRA C:2004 rules for generated code |
'misraCPP' | MISRA C++ rules |
'misraC2012' | MISRA C:2012 rules |
'jsf' | JSF C++ rules |
'certC' | CERT C rules |
'certCpp' | CERT C++ rules |
'iso17961' | ISO/IEC TS 17961 rules |
'autosarCPP14' | AUTOSAR C++ 14 rules |
'metrics' | Code complexity metrics |
'customRules' | Custom rules enforcing naming conventions for identifiers |
'guidelines' | Polyspace Guidelines checkers |
To summarise the coding rule violations, use the value
codingStandards
instead.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)