简体   繁体   English

cppcheck的规则集

[英]Rulesets for cppcheck

Cppcheck allows you to create your own rules files, but I don't know how much of cppcheck's functionality is exposed. Cppcheck允许您创建自己的规则文件,但我不知道公开了多少cppcheck的功能。

Is anyone working on a set that would enforce JSF or MISRA rules? 是否有人在执行JSFMISRA规则的电视机上工作

You won't be able to implement all MISRA/JSF rules and directives as cppcheck rules, mostly only the straightforward ones restricting certain C language features and constructions or that are style-related (some that come to mind: spaces before/after ./->, # of arguments on a single line, use of unions to provide different methods of accessing memory, presence of unsigned/signed before char, etc). 您将无法将所有MISRA / JSF规则和指令实现为cppcheck规则,大部分只能是那些限制某些C语言功能和构造或与样式相关的简单命令(有些是想到的:./之前/之后的空格)。 ->,单行中的参数个数,使用并集提供不同的访问内存的方法,在char之前存在未签名/已签名等)。

User Ira Baxter pretty much nailed it in a comment on another question touching cppcheck: not everything can be represented/simplified as a pattern. 用户Ira Baxter在涉及cppcheck的另一个问题的评论中几乎将其钉上了钉:不是所有事物都可以表示/简化为模式。 Relying on patterns for custom rules makes it difficult to handle and detect higher level issues, related for example to types (eg sizeof() on types; you would have to parse and collect tokens (typedefs, enums) used as a type representation) , inheritance (eg classes, incl. derived ones, used both as virtual and non-virtual) , and scope . 依靠自定义规则的模式使处理和检测与类型 例如, 类型上的 sizeof()等)相关的更高级别的问题变得困难, 您必须解析和收集用作类型表示形式的令牌(typedefs,enums)继承 (例如,用作虚拟和非虚拟的类,包括派生类)scope Those need to be hard-coded into cppcheck (you could always fork cppcheck...) 那些需要被硬编码到cppcheck中(您可以随时派生cppcheck ...)

In any case, have you touched MISRA (or JSF) rules? 无论如何,您是否触及了MISRA(或JSF)规则? Is this a requirement for a project? 这是项目的要求吗? If not, you could grab a copy of the MISRA guidelines (you already have the JSF ones) and check the ones you can implement using PCRE patterns. 如果没有,您可以获取MISRA指南的副本(您已经拥有JSF指南)并检查可以使用PCRE模式实现的指南。 If it is a requirement, I suggest you "invest" in a commercial product that does check for MISRA/JSF guidelines and use both tools. 如果需要,我建议您“投资”确实检查MISRA / JSF准则并使用这两种工具的商业产品。

A final note: you don't need all the MISRA/JSF rules, and many tools leave a small percentage of those out. 最后一点:您不需要所有MISRA / JSF规则,许多工具将其中的一小部分排除在外。

From what I can tell, looking through the documentation, It looks pretty exposed. 据我所知,翻阅文档,看起来很暴露。 http://cppcheck.sourceforge.net/manual.pdf . http://cppcheck.sourceforge.net/manual.pdf

Cppcheck has MISRA support. Cppcheck具有MISRA支持。 Here is an overview about the supported rules: supported MISRA rules 以下是有关受支持规则的概述: 受支持的MISRA规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM