Run and Review Results in Polyspace as You Code for Visual Studio
After you configure the Polyspace as You Code plugin, you are ready to run an analysis
and fix or justify any findings. Before continuing this guide, confirm you have added
the files example.hpp
and example_source.cpp
to
the Quality Monitoring list.
Run Polyspace as You Code Analysis in Visual Studio
You can run an analysis in these ways:
If you select Start analysis on save, save your edited file to run an analysis.
Right-click in the file editor with your file open and select Polyspace > Run Polyspace Analysis.
Manually add your file to the Quality Monitoring list and click the icon in the Quality Monitoring view to analyze your file.
View, Fix, or Justify Findings
After Polyspace runs the analysis, the filename in the Quality Monitoring view is green if there are no findings and red if there are findings. A number to the right of the filename indicates the number of findings.
View a list of your findings in the Error List view, which opens by default when you open the Polyspace as You Code windows in Visual Studio®. If the Error List is not open, reset the perspective by clicking Extensions > Polyspace > Open Polyspace Windows.
Use the filter in the Error List to search for specific findings. Each finding contains a filename and line number to indicate where the finding exists in your code.
After you run an analysis on the example code:
Open the results in the Error List.
In the search bar, enter the text
A16-2-3
. There is one result on line five.Click the finding in the Error List to open the file that contains the finding.
Each finding is noted in the file with a red highlight. Click the highlighted sections of code to see a list of each finding associated with the problem in the Result Details.
In the example code, add this
#include
statement on line two:#include <cstdint>
Save this change and run another analysis. The
A16-2-3
error on line five is no longer present.
If you set up automatic analysis, you can find and fix findings during the code authoring process. Each time you save changes, a Polyspace analysis begins in the background and displays any new findings or removes fixed findings from the list.
Justify Individual Findings
You can justify a finding from the Error List or from the location of the finding in the code.
Right-click a finding in the Error List and select Polyspace > Justify the current result. This adds a comment to your code, which you can amend. Adding a justification removes the finding from the Error List. To show the finding again, remove the justification comment and perform an analysis.
Provide Justification Catalog
You can add a catalog of predefined justifications to Polyspace as You Code. The justification catalog allows you to select a prewritten justification instead of manually typing each justification comment. If you do not already have a justification catalog, use the example JSON file.
example_catalog.json
{ "justifications": [ { "family": "Defect", "acronym": "INT_ZERO_DIV", "comment": "This is my justification for division" }, { "family": "Defect", "acronym": "INT_ZERO_DIV", "comment": "Alternative justification for division" } ] }
Select Tools > Options and then Polyspace as You Code from the sidebar. Next to the Justification catalog text box, click Browse and navigate to your justification catalog.
View Header Findings
When you analyze source files, you see any header file findings in the Error List. If a header contains any findings, the findings are noted with a red H next to the source file in the Quality Monitoring list.
Click a header finding in the Error List to navigate to the header file that contains the finding. The source file analysis that caused the header finding is listed in the Description column of the Error List.