Main Content

Run Polyspace as You Code in Eclipse and Review Results

You can configure Polyspace® as You Code to run on each save in your Eclipse™-based IDE, or you can start the analysis manually. The analysis runs on the file that is currently active in the IDE. After analysis, you see bugs and coding standard violations as source code markers or in a separate list.

Check Installation and Start Plugin

To confirm that the Polyspace as You Code plugin is installed in your Eclipse-based IDE, check the list of installed plugins.

  1. Select Help > About Eclipse IDE.

  2. Click Installation Details and type polyspace in the search bar on the Plug-ins tab.

To start the Polyspace as You Code plugin, open a C or C++ file in the editor. The plugin does not start automatically when you open the Eclipse IDE if no C or C+ file is open in the editor. You can confirm that the extension starts as expected in the Console view. To open this view, select Window > Show View > Console. If the plugin starts without errors, you see a message similar to this:

[2023-01-26 00:43:42.68] [Information] No setting set for the port. Trying to find a free port.
[2023-01-26 00:43:49.539] [Information] Connector was successfully started on port 56041

You can also open the Console view by pressing Alt+Shift+Q and then Q again, and start typing console in the search bar.

The Polyspace as You Code plugin establishes an internal connection with the analysis engine on the selected port. If you do not specify a port, Polyspace queries your system for an open port and uses the port that your system returns.

Open Polyspace as You Code Perspective

The Polyspace as You Code plugin has a dedicated perspective in the Eclipse IDE that groups all the relevant Polyspace views.

To open the Polyspace as You Code perspective, click Open Perspective button in Eclipse on the far right of the toolbar. If the perspective is already open but a different perspective is active, click Polyspace icon to return to the Polyspace perspective.

The different views in the Polyspace as You Code perspective show information about the state of your configuration and about the files that you select for analysis. For more information, click Eclipse help button in each view (when available) to open the documentation.

Quality Monitoring View

The Quality Monitoring view shows all the files that you have selected for analysis, along with the status of the analysis and the number of findings for each file.

To analyze a file, select that file and click Run Polsypace analysis. You can also start a sequential file-by-file analysis by clicking Analyze all files.

Open the settings on the Analysis node by clicking Configure settings button to configure adding files to this view on save. See Configure Polyspace as You Code Plugin in Eclipse. To add a file manually, right-click the file in the editor or in the Project Explorer.

Headers View

When you analyze a file, Polyspace also analyzes the header files that are included by and that are in the same folder as the analyzed file. If Polyspace reports findings in a header file, you see an H next to the analyzed file in the Quality Monitoring view. Click the analyzed file in that view to list the headers file in the Headers view.

Polyspace as You Code Headers view in Eclipse

You see header files in the list only if they contain findings. Click the file in the Headers view to open its findings in the Polyspace Problems view.

Polyspace Problems View

The Polyspace Problems view shows the all the analysis findings listed as one finding per line. Each line shows additional information,such as:

  • The rule name, family, and description.

  • Name of the file containing the finding. If this file is a header, the Header columns show the name of the source file containing this header file.

  • Review information

The findings are grouped by results family. To change the grouping or view a flat list, click the three vertical dots and select Grouping options.

Polyspace as You Code Problems view in Eclipse

Click a column header to sort findings by the content of that column. For instance, you can sort findings by files.

Result Details View

When you select a finding in the Polyspace Problems view or in the editor, the Result Details view shows additional information about the finding, including (when available) the traceback and the review information imported from the baseline.

If you select multiple lines of code, this view shows the result details for all the findings in the selection. Click Eclipse help button to view contextual help about the selected finding.

To lock this view while you browse findings in the source code or the Polyspace Problems view, click Lock Results details view. The view does not update when you select a different finding. Click the icon again to unlock the view.

Configuration View

The Configuration view shows the current analysis settings and the status of the generated build options, if applicable.

Baseline View

View whether you are using the baseline or not and the status of the baseline download if applicable. If you configure the baseline settings, you see information about the Polyspace Access server and the project you use as a baseline. See Set Baseline Polyspace as You Code Results in Eclipse.

In the Baseline view, you can:

  • Click Download baseline button to download or update a baseline.

  • Click Configure settings button to open the baseline settings.

If the results from the baseline run are generated with a Polyspace product version that is older than your Polyspace as You Code version, the view shows a warning.

Run Analysis

Polyspace analyzes only files that are part of the Eclipse workspace. To add a file to a workspace, you add it to a project in that workspace. Files that are not in the workspace are not analyzed even if you add them to the Quality Monitoring list. If a file that you analyze includes a file that is not in the workspace, the Polyspace as You Code analysis runs but does not report any findings in the included file.

On Save

By default, the Polyspace as You Code plugin adds the current file to the Quality Monitoring view on save but does not start the analysis.

To enable the analysis of the current file on save, click Configure settings button in the Quality Monitoring view and select Start analysis on save in the Preferences window. You can also open the preferences by pressing Alt+W+P.

After analysis, findings appear as source code markers. You also see the finding locations as red marks on the scroll bar. Click a finding location to navigate to the corresponding source code. If the analysis fails, check the messages in the Console view to diagnose the cause of the failure.

If results do not appear, see Troubleshoot Failed Analysis or Unexpected Results in Polyspace as You Code.

On Demand

To disable starting an analysis on save, go to the Polyspace as You Code preferences and clear the Start analysis on save checkbox. To start an analysis manually, do one of the following:

  • Click Run Polsypace analysis in the Quality Monitoring view.

  • Right-click the file in the editor and click Run Polyspace Analysis.

Review Results

After analysis, you see the results in two forms:

  • As source code markers. You can point to a source code marker to view more details about the finding and view options to justify that finding.

  • In a list on the Polyspace Problems view. If you select a finding in the Polyspace Problems view or in the editor, you see additional details about the finding in the Result Details view. Click Eclipse help button to open the contextual help for the currently selected finding.

Justify Results Using Code Annotations

If you decide not to fix a result, you can justify the result by adding code annotations. If the annotations follow a specific syntax, subsequent Polyspace as You Code runs can read these annotations and suppress the corresponding result.

  • To add a code annotation, right-click a finding in the Polyspace Problems view and select Polyspace > Justify the current result. The annotation is entered on the same line as the finding. You can also apply an annotation by pointing to the code marker for that result.

  • To mass-justify findings of the same defect or coding rule violation in the current file, right-click a finding in the Polyspace Problems view and select Polyspace > Justify all instances of the selected finding. Polyspace inserts an annotation in your code on each line that contains this finding.

  • If you import review information from a baseline run, any status, severity, or comment from the baseline run is automatically applied to the corresponding Polyspace as You Code finding.

    Findings with an imported status of Not a defect, Justified, or No action planned are removed from the Polyspace Problems view and in those findings are suppressed in subsequent analyses.

If you select multiple lines of code and then right-click in the Polyspace Problems view, you can select the Polyspace > Justify the current result option to justify each result in the selected code.

Polyspace as You Code inserts code annotations as comments enclosed in "/* */" for C files and prefixed with "//" in C++ files (C++ style). The comment format in C files complies with MISRA C:2004 rule 2.2. See MISRA C:2004 and MISRA AC AGC Rules (Polyspace Bug Finder).

See also:

View Context-Sensitive Help for Result

You can see more information on a type of result by visiting the context-sensitive help page for the result.

To open the context-sensitive help for a finding, select that finding in your code or in the Polyspace Problems view, and then click Eclipse help button in the Result Details view.

You can also open the full searchable documentation for the Polyspace as You Code plugin in your system browser by clicking Eclipse help button in the Baseline, Configuration, or Quality Monitoring view.

Configure Checkers and Other Settings

Polyspace as You Code checks for a default subset of defects, but you can expand the set of checkers and perform other configuration through the Polyspace as You Code plugin settings in Eclipse. To open the settings, press Alt+W+P and go to the Polyspace as You Code node in the Preferences window.

For instance, you might want to:

For the full list of settings, see Configure Polyspace as You Code Plugin in Eclipse.