Main Content

Check Code Quality in IDE Before Submitting

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. (For full integration analysis of a project, use Polyspace Bug Finder or Polyspace Bug Finder Server.)

Install Polyspace as You Code Analysis Engine and IDE Extensions

Polyspace as You Code comes bundled with a Polyspace® Access™ installation meant for teams or organizations. Once the Polyspace Access web server is set up, any of the licensed users can download the Polyspace as You Code installer as a zipped file from the Polyspace Access web interface.

Download Polyspace as You Code menu

Conceptually, Polyspace as You Code consists of these parts:

  • An analysis engine

  • An IDE extension that allows you to launch an analysis and view results in your IDE

    IDE extensions are provided for these IDEs: Visual Studio, Visual Studio Code and Eclipse. If you use another IDE, you can still install the analysis engine and run the analysis from the command line or IDE console.

Unzip and start the installer and follow the on-screen instructions. After the analysis engine is installed, you have a choice to install one or more IDE extensions. For more information, see Install Polyspace as You Code Using Installer.

Alternatively, you can install the IDE extensions later. For more information, see:

Run Polyspace as You Code and Review Results

After installation, each time open your IDE, the Polyspace as You Code extension is ready to start an analysis. If you open a C or C++ file, make some changes and save the file, an analysis starts automatically. (You can disable the automatic analysis and choose to launch an analysis explicitly instead.)

To start an analysis, in your IDE, open the project or workspace that you are currently working on, and open a file in the project. Alternatively, copy the following function into a .c or .cpp file and open the file in your IDE (using a project or otherwise). The function contains bugs such as array access out of bounds, unnecessary code, and use of assignment operator instead of equality.

#define MAXBUF 20
int buf[MAXBUF];

int saturateAndShift(int limit, int* stream, int size) {
    int i;
    int numMax = 0;

    if(size > MAXBUF) {
        return -1; 
    }

    if(size <= MAXBUF) {
        for(i=0; i<size; i++) {
            if(stream[i] > limit || stream[i] < 0) {
                buf[i+1] = 0;
            }
            else if(stream[i] = limit){
                buf[i+1] = stream[i];
                numMax ++;
            }
            else {
                buf[i+1] = stream[i];
            }
        }
    }
    return numMax;
}

After a Polyspace as You Code analysis, you can see the results (bugs and coding standard violations) as source code markers on the currently active file. You can also see the results in a separate list in the IDE. For more information, see:

You can also export the results on a command line terminal or IDE console. For richer results, you can export the results to a JSON format and manipulate them further before display. For more information, see Run Polyspace as You Code from Command Line and Export Results.

Configure Polyspace as You Code IDE Extension

The default analysis is preconfigured to work on small projects in IDEs. In practice, you might have to configure the IDE extension settings further to emulate your build closely, to enable or disable checkers, to see new results only or for other adjustments.

For instance, by default, Polyspace as You Code runs each time you save your code. You can disable the automatic runs using an extension setting (and run the analysis explicitly with right-click options on the source code). For the complete list of extension settings and how to open them, see:

The extension settings fall into three major groups:

  • Build options:

    Using these settings, you specify whether to extract build information from existing artifacts in IDEs such as a Visual Studio solution or a Visual Studio Code build task, or to manually enumerate build-related Polyspace options in an options file. For more information, see Analyzing Build in Polyspace as You Code (Polyspace Bug Finder).

  • Checkers:

    Using these settings, you can enable or disable checkers. For more information, see Setting Checkers in Polyspace as You Code (Polyspace Bug Finder).

  • Baselining options:

    Using these settings, you can connect your Polyspace as You Code installation with a Polyspace Access instance, and baseline your results using a project in Polyspace Access. Baselining allows you to focus only on new results because of recent code changes. See Baselining in Polyspace as You Code (Polyspace Bug Finder).