Run Polyspace as You Code in Eclipse and Review Results

This topic describes how to run a single-file analysis in Eclipse™ using Polyspace as You Code. For Polyspace desktop products such as Polyspace Bug Finder, see the topic "Polyspace Analysis in Eclipse" in the Polyspace® Bug Finder™ documentation.

You can choose to run Polyspace as You Code on each save in the Eclipse IDE, or at will. 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.

Confirm Installation of Plugin

To confirm that your Eclipse installation has the Polyspace as You Code plugin, check the list of plugins installed.

  1. Select Help > About Eclipse.

  2. Select Installation Details and browse through the list of installed plugins.

You can also confirm that the extension starts as expected on the IDE console. To open the console explicitly, select Window > Show View > Console. If the extension starts without errors, you see a message such as:

11/25/2020 3:59:37 PM.005: Starting Polyspace Connector on port 9093...
11/25/2020 3:59:41 PM.229: Polyspace Connector successfully started

The Polyspace Connector is an internal server that handles communication between the Polyspace as You Code analysis engine and the Eclipse plugin. If the default port is not available, the plugin increments the port number and attempts to start the Polyspace Connector on the next port.

Run Analysis on Save

By default, Polyspace as You Code is configured to run analysis on save. Follow the progress of analysis on the IDE console.

After analysis, results appear as source code markers (lines below source code tokens). You also see the error locations as red marks on the scroll bar. Click an error location to navigate to the corresponding source code.

To disable analysis on save, select Polyspace > Preferences and select Manually for Analysis launch mode.

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

Run Analysis on Demand

If you disable automatic launch on save, you can also explicitly start a Polyspace analysis. To start an analysis, right-click the source code and select Run Polyspace as You Code.

Review Results

After analysis, the results appear in two forms:

  • As source code markers (with a line below source code tokens).

    You can click the circle on the left next to an underlined source code token to see more details about a result.

  • In a list on the Results List pane.

    If the list does not open automatically, select Polyspace > Show View > Show Results List. If you select a result in this list, you see further details of the result on the Result Details pane.

Image of Problems window in Eclipse

Justify Results Using Code Annotations

If you decide not to fix a result, you can add code annotations to the result to avoid having to fix the result again. If the annotations follow a specific syntax, subsequent Polyspace as You Code runs can read these annotations and suppress the corresponding results.

To add a code annotation, right-click the result on the Results List pane and select Annotate Code and Hide Result. The annotation is entered on the same line as the result.

Right-click result in list to justify result with annotation

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 result, first open the Result Details pane for a result. Then, click the question mark icon next to the result details.

  • To navigate directly to the Fix section of the context-sensitive help for a result, click the wrench icon next to the result details.

Open result details pane to visit context-sensitive help

You can also open the full searchable documentation for the Polyspace as You Code extension from within Eclipse. To open the documentation, select Polyspace > Help.

Configure Checkers and Other Settings

By default, Polyspace as You Code checks for defects that are likely to be of most interest to developers. 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, select Polyspace > Preferences or Polyspace > Configure Project.

For instance, you might want to:

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