配置编码规则检查项和代码度量
激活 MISRA™、AUTOSAR、CERT® 和 JSF® 编码规则集、自定义编码规则和代码度量
您可以使用 Polyspace® Bug Finder™ 检查违反编码标准的情形并计算编码度量。
要检查编码违规,请使用“检查项选择”窗口激活一组编码规则和缺陷。将一组激活的检查项保存到检查项激活文件 (.xml) 中,然后在后续分析中使用该激活文件。请参阅检查项激活文件 (-checkers-activation-file)。
或者,您可以激活从特定编码标准中预先选择的规则集。例如,通过使用检查 MISRA C:2023 (-misra-c-2023) 选项,并将其值设置为 mandatory,可激活 MISRA C™:2023 中的强制规则。
您还可以通过指定计算代码度量 (-code-metrics) 选项来计算函数级、文件级和工程级代码度量。此选项可计算工程中的一组代码度量,例如圈复杂度、注释密度或递归次数。
Polyspace 选项
系统命令
polyspace-catalog-bundler | (System Command) Create user-defined Polyspace coding standards at the DOS or UNIX command line |
主题
配置检查项
- 指定 Polyspace 分析选项
在 Polyspace 用户界面、其他 IDE 或脚本中指定 Polyspace 分析选项。 - 检查并审查编码标准违规
使用 Polyspace Bug Finder 检查代码是否违反了 AUTOSAR C++14、CERT C、CERT C++、CWE、MISRA C、MISRA C++、JSF AV C++ 或 ISO-17961 标准。 - Prepare Checkers Configuration for Polyspace Bug Finder Analysis
Deploy common checkers configuration to enforce uniform standards, mix defect and coding rule checkers. - Create New Checkers Activation File Without Polyspace User Interface
When Polyspace user interface is unavailable, configure checkers by creating a checkers activation file in a text editor.
MISRA 规则
- Avoid Violations of MISRA C Rules 8.x
Avoid conflicting declarations or unintended modification of variables. - Coding Rule Subsets Checked Early in Analysis
Adjust your coding rules checking for a faster analysis.
CWE
- Polyspace 对 CWE 类别的支持
按类别对 CWE 结果分组。
用户定义的编码标准
- Create User-Defined Coding Standard by Using Polyspace Query Language
Create new user defined defects and use these defects along with existing bug Finder checkers to create a user-defined coding standard in a sharable
.pschkfile. - Create User-Defined Coding Standard by Using Polyspace Bug Finder Checkers
Map Bug Finder checkers to coding rules in a user-defined coding standard in a sharable.pschkfile.
代码复杂度度量
- 使用 Polyspace 计算代码复杂度度量
对代码复杂度度量(例如圈复杂度和嵌套深度)强制施加限制。 - HIS 代码复杂度度量
查看 Polyspace 中支持的哪些代码复杂度度量是 Hersteller Initiative Software (HIS) 标准的一部分。
Polyspace 规范
- Reduce Software Complexity by Using Polyspace Checkers
Enable and configure the software complexity checkers to identify issues that make your code difficult to read, understand, and debug.
Polyspace 自定义规则
- Enforce Naming Conventions for C/C++ Variables and Functions
Enforce naming conventions and other style guidelines on C/C++ code with Polyspace.