Polyspace as You Code

The Polyspace® family of products now offers a feature designed explicitly for software developers: Polyspace as You Code. This feature brings the code checking capabilities of Polyspace Bug Finder into Integrated Development Environments (IDEs) and saves you from finding bugs late in the software development cycle.

Cost of Finding Bugs Late in Development Cycle

Software bugs can be detected at various stages of development. While some bugs show up only in the integration stage, a significant number of bugs can be found much earlier. Fixing bugs as soon as they are found saves debugging tasks later in the development cycle.

The chart below shows that the cost of fixing a defect increases exponentially as you move through the development cycle. It is more cost-effective to find and fix defects at the coding stage of the development cycle.

Polyspace as You Code

Polyspace as You Code

Polyspace as You Code lets you check for code quality even before submitting code changes to a source code repository. You can get the benefits of running Polyspace within the familiar environment of your IDE or editor by installing Polyspace as You Code as a plugin or extension. Plugins are available for IDEs such as Visual Studio®, Visual Studio Code, or Eclipse™. You can also integrate Polyspace as You Code with other IDEs or editors using a simple API.

Polyspace as You Code analyzes the files being modifed, either on demand or on save, extracting analysis settings from your build environment. New vulnerabilities and coding rule violations are then reported directly in the IDE. You can review findings that already existed in the file when you want to focus on increasing the quality of your code. For instance, in Visual Studio Code, you may see a defect reported like the one shown below after your C or C++ file is analyzed:

Polyspace as You Code

For each finding reported by PAYC, you get extensive context information to help understand the root cause of the vulnerability, such as:

  • Brief description of the defect: An implicit conversion leads to an overflow.
  • Data types involved: An unsigned integer variable (size: 32 bits) is converted to another unsigned integer type (size: 16 bits).
  • Expected values: The expected range of the unsigned integer type (size: 16 bits) is [0 ... 65535].
  • Actual values: The actual values that the variable has acquired are higher than expected.
  • Related events: The issue appears on line 138. Another line relevant to the issue is an assignment on line 134. Remember, you may need to fix a bug on a previous line and not at the immediate location of the problem.

With these details, along with context-sensitive help showing possible fixes, you can now resolve the error. If your fix works, then the highlight on the token will go away the next time you save your code.

You can use Polyspace as You Code to perform other related actions within your IDE. For instance, if you decide not to fix an issue, you can add Polyspace-specific code comments with one click to justify the result. This is a helpful tool if your quality management process requires you to fix or justify all vulnerabilities or coding rule violations of specific types. Processes that are tedious later in the development cycle can now be completed with less effort while you are developing in your IDE. Also, code reviewers can verify your justifications, making the code review process more efficient.

If you hook up your Polyspace as You Code installations to a Polyspace Access server, you can use the latest run on the server as a baseline for the results in your IDE. That way, your IDE only shows results directly caused by your code changes since the last server run and hides issues that were already present in legacy code. You can also temporarily disable the baseline and see all issues in the current file.

Like other Polyspace products, the key features of Polyspace as You Code are fully customizable.

  • Don’t like the default set of checkers? You can set the checkers that you want. You can also maintain standards across your team or organization by sharing a common checkers file.
  • Don’t want to run analysis on every save? You can disable automatic analysis when saving and explicitly run an analysis at will from your IDE.
  • Want to use your scripts in running the analysis? You can set up Polyspace as You Code to bypass the IDE plugin options and run your scripts on each save.

How Polyspace as You Code Prevents Late Bugs

Polyspace as You Code prevents late bugs by enabling you to find and fix vulnerabilities and enforce coding standards as soon as possible. This is achieved by providing you with easy-to-use code checking capabilities:

  • No context switch required: Polyspace as You Code detects software vulnerabilities, coding standard violations, overly complex code, and other issues in the current file that is open in your IDE and highlights the relevant source code tokens. The highlights are similar to what you may see in your IDE for syntax errors. Hovering on the highlighted tokens shows additional details of the issue, so you can investigate and quickly fix it.
  • Faster runs: Polyspace as You Code runs on the current file being edited. The runs are faster than a full project analysis and produce immediate and meaningful results.
  • Minimal setup required: Polyspace as You Code extracts all required information from your IDE (assuming your IDE is already setup to build your source code). The setup effort required to perform code analysis is minimal.
  • Tool runs automatically: Each time you save your code, Polyspace as You Code runs in the background and shows you any bug or coding standard violation caused by your latest changes. There is no overhead of remembering to run the tool.

In summary, Polyspace as You Code enables you to develop faster, higher-quality C and C++ code. Code analysis capabilities are available directly in your coding environment and can run as soon as the code is modified. As a result, the feedback-loop on code vulnerabilities and code quality is as short as possible, and it reduces the time spent on code-reviews.

You can use Polyspace as You Code together with Polyspace Server products for component-level or system-level code analysis. While Polyspace as You Code enables you to remove single-unit defects or coding rule violations before submitting to a code repository, Polyspace Server products can run in a continuous integration pipeline after submission and detect more complex integration issues. This is the most efficient way to keep your code quality level high across all developers and teams during the complete lifecycle of your development project.

For more information, see the release notes for Polyspace Bug Finder. Polyspace as You Code was released in R2021a.