Skip to content
Back to skills

Run Polyspace As You Code Analysis

ASecurity

Runs Polyspace as You Code (PAYC) static analysis on a single C/C++ file — the file you are editing — to find defects and coding-standard violations. The default when the request targets one file, e.g. "run Polyspace analysis on source.c", "check my code"/"check this file", "check that my change is MISRA/CERT compliant", "find or fix the defects in this file". For several files or a whole component use run-polyspace-bug-finder-analysis; to prove absence of run-time errors use run-polyspace-co...

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 17, 2026
toolsgoc++database

Works with

  • vscode
  • cli
  • mcp

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 17, 2026

npx -y skills add zrwangems/dsh-zrwang-plugin --skill run-polyspace-as-you-code-analysis --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Run Polyspace As You Code Analysis?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Run Polyspace As You Code Analysis
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/zrwangems-run-polyspace-as-you-code-analysis/badge)](https://www.skillsdirectory.com/skills/zrwangems-run-polyspace-as-you-code-analysis)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: run-polyspace-as-you-code-analysis
description: Runs Polyspace as You Code (PAYC) static analysis on a single C/C++ file — the file you are editing — to find defects and coding-standard violations. The default when the request targets one file, e.g. "run Polyspace analysis on source.c", "check my code"/"check this file", "check that my change is MISRA/CERT compliant", "find or fix the defects in this file". For several files or a whole component use run-polyspace-bug-finder-analysis; to prove absence of run-time errors use run-polyspace-code-prover-analysis. Requires the Polyspace as You Code product.
license: MathWorks BSD-3-Clause
metadata:
  version: "1.4"
---
# How to Run Polyspace as You Code Analysis

Run Polyspace as You Code (PAYC) on a C/C++ source file to find standard violations, defects, and coding rule issues.

## When NOT to Use

- The user wants defect and coding-standard analysis **across several files / a whole component** (finding interprocedural, cross-file defects), rather than fast single-file checking — use `run-polyspace-bug-finder-analysis` instead.
- The user wants to **formally prove the absence of run-time errors** (a full Code Prover verification with red/orange/green/gray checks), rather than fast file-level defect and coding-standard checking — use `run-polyspace-code-prover-analysis` instead.

## Pre-analysis setup

Before running, gather build configuration:

1. Look for existing Polyspace IDE config in `.vscode/settings.json` (`polyspace.analysisOptions.*`), `.project`, or `.vs/`. If found, use it to populate the build options, checkers, and options file paths.
2. Otherwise, ask the user for pre-created config files or a team script that launches Polyspace.
3. Otherwise, search for `compile_commands.json` or a `Makefile`/`CMakeLists.txt` and create a build options file (invoke the `polyspace-configure-build-options` skill).
4. For simple standalone files, build options may not be needed.

If no checkers file exists, invoke the `polyspace-configure-checkers` skill to create one.

## Running the analysis

### Using the MCP tool

**If the `run_polyspace_as_you_code` tool is available**, use it:
- `source_file_path` (required): absolute path to the C/C++ file
- `checkers_file_path` (optional): path to checkers XML file
- `build_options_file_path` (optional): path to build options file
- `polyspace_options_file_path` (optional): path to additional options file
- `baseline_folder_path_to_use` (optional): path to a folder with previous results for baseline comparison
- `baseline_folder_path_to_store` (optional): path to a folder to store results persistently

### Otherwise using the binary directly

**Otherwise**, read `references/cli-usage.md` in this skill's directory for direct command-line usage.

## Handling errors

If compilation fails, check `<output_dir>/polyspace_err.log` for compiler error details. Common causes:
- Missing include paths or defines — regenerate the build options file using a build command or compilation database
- Wrong compiler, language, or target settings in the options file

## After analysis

The findings are in the tool's own response — it returns `total_findings` and `findings`. Each
finding carries `id`, `family`, `check`, `function` and `line`; `message`, `category` and
`information` appear when the analysis supplies them. `information` is the field that carries the
prioritization axis, as one string — `Impact: <level>` for a defect, `Category: <rule category>` for
a coding-rule violation — so read it before ranking anything. `status` and `severity` are present on
every finding but hold placeholders until you point the run at a baseline, and `baseline_state` and
`comment` appear only with one, so treat all four as review metadata rather than as findings data.

**A coding-rule violation often has no `message`.** Defects always carry one; rule violations
frequently do not, and for those the rule's text is in the top-level `rule_descriptions` map — look
the finding's `check` value up in it. Report the rule from there rather than reporting the violation
by number alone, and never conclude a finding is undescribed because its `message` is empty.

A per-finding `file` is absent in practice: identify the source from the `source_file_path` you
passed, or from the top-level `source_files` list. `rule_descriptions` and `source_files` are present
only when the export carries them. The response does **not** contain a results-database path, so
there is nothing for a results-database tool to open.

If the user wants to **understand or prioritize** what was found (not fix it yet) — "what did it
find", "which are serious", "explain this one" — use the `polyspace-review-findings` skill (shared
with Bug Finder) for its prioritization guidance, but apply it to the fields above rather than
re-reading a database: on an as-you-code-only installation the results-database tools that skill
calls are not available at all (they are registered only with Bug Finder or Code Prover). Only when
the user also has a `.psbf` or `.pscp` from a Bug Finder or Code Prover run should that skill's tool
calls be used, against that file.

If the user asked to fix findings or make the code compliant (not just run analysis), and findings are reported:

- **If skills are available**, invoke the `polyspace-fix-findings` skill. Do NOT skip the skill and call MCP tools directly — the skill defines the full fix/justify workflow.
- **If skills are not available**, read the `polyspace-fix-findings` and `polyspace-justify-in-code` skills (in the `polyspace-static-core` group) for the fix/justify workflows.

---

Copyright 2026 The MathWorks, Inc.

---

Files in this skill

  • SKILL.md5.6 KB
  • manifest.yaml538 B
  • references/cli-usage.md1.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.