23.LDRA_Testbed_C++编码规则列表1.0
更新时间:2024-05-08 09:09:01 阅读量: 综合文库 文档下载
LDRA Testbed
C++ 编 码 规 则 列 表
www.visionmc.com
联系电话: 021-68534562(上海),010-62131690(北京)
028-86527582(成都),0755-3581788(深圳)
LDRA TESTBED.........................................................................................................................................................1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
过程名被重用 ..................................................................................................................................................1 标号名被重用 ..................................................................................................................................................1 文件中可执行格式化代码行超过***行 ...................................................................................................1 程序格式化代码行超过***行 .....................................................................................................................1 THEN语句为空 .............................................................................................................................................1 声明函数指针 ..................................................................................................................................................1 跳出程序体 ......................................................................................................................................................1 ELSE语句为空...............................................................................................................................................1 在非赋值表达式中出现了赋值操作符 .....................................................................................................1 未使用 ...........................................................................................................................................................1 循环体没有用大括号括起来 ...................................................................................................................1 THEN/ELSE中的语句没有用大括号括起来 .................................................................................1 使用GOTO语句 .......................................................................................................................................1 将过程定义为参数.....................................................................................................................................1 结构体定义中含有空域............................................................................................................................1 声明多重标号..............................................................................................................................................1 内嵌使用汇编代码.....................................................................................................................................2 函数参数超过***个...................................................................................................................................2 未被调用的函数使用函数作为参数......................................................................................................2 参数未使用类型声明 ................................................................................................................................2 未使用 ...........................................................................................................................................................2 使用一些模糊的语句(如=+,=-).........................................................................................................2 函数未被调用..............................................................................................................................................2 使用让工具不进行分析的注释/*LDRA_NOANALYSIS*/............................................................2 CASW语句为空 ........................................................................................................................................2 使用无限循环..............................................................................................................................................2
Testbed 术语表 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
返回类型为VOID的函数有RETURN语句 .....................................................................................2 继承类中复用基类.....................................................................................................................................2 使用-=或+=操作符.....................................................................................................................................2 使用++或者—操作符................................................................................................................................2 在循环中使用BREAK语句 ...................................................................................................................2 使用CONTINUE语句.............................................................................................................................2 使用三重表达式 .........................................................................................................................................3 对过程的声明中未对参数进行说明......................................................................................................3 圈复杂度大于*** .......................................................................................................................................3 过程不是单纯的顺序嵌套循环 ..............................................................................................................3 函数包含基本结点.....................................................................................................................................3 函数非结构化..............................................................................................................................................3 函数包含无限循环.....................................................................................................................................3 未使用的函数参数.....................................................................................................................................3 函数不是所有的路径上都有返回值......................................................................................................3 函数的实参是全局变量............................................................................................................................3 代码中有多余变量.....................................................................................................................................3 存在UR(变量未赋初值就引用)数据流异常.................................................................................3 使用函数递归调用.....................................................................................................................................3 存在DU(定义后未引用就退出作用域)数据流异常 ...................................................................3 存在DD(定义后未被引用就被再定义)数据流异常 ...................................................................3 被定义的参数可能存在CLEAR PATH..............................................................................................3 在函数内部使用全局变量 .......................................................................................................................3 参数与期望的作用不匹配 .......................................................................................................................4 被引用的变量可能存在CLEAR PATH..............................................................................................4 函数中全局变量使用与局部变量作用类似 ........................................................................................4 改变变量已被传递的值............................................................................................................................4 存在未被使用的过程参数 .......................................................................................................................4
上海创景计算机系统有限公司 3
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 71 72 74 75 76 77 78 80 81 82 83 84 85
函数调用中存在相同的实参 ...................................................................................................................4 局部变量对结果没有意义 .......................................................................................................................4 函数有多入口..............................................................................................................................................4 函数有多出口..............................................................................................................................................4 静态过程没有被调用 ................................................................................................................................4 函数没有返回语句.....................................................................................................................................4 过程参数只有类型没有标识符 ..............................................................................................................4 使用静态类成员 .........................................................................................................................................4 使用不恰当的循环变量类型 ...................................................................................................................4 循环变量必须是局部的............................................................................................................................4 在函数参数表中使用省略号 ...................................................................................................................4 在结构体定义中使用位域 .......................................................................................................................4 使用SETJMP/LONGJMP .....................................................................................................................5 使用禁用的过程,函数,文件或名称 .................................................................................................5 未使用 ...........................................................................................................................................................5 数组越界.......................................................................................................................................................5 在SWITCH语句中没有DEFAULT 语句 .........................................................................................5 对有符号类型进行移位操作 ...................................................................................................................5 移位运算溢出..............................................................................................................................................5 禁止给无符号变量赋负值 .......................................................................................................................5 使用逗号操作符 .........................................................................................................................................5 长度操作符SIZEOF的副作用 ..............................................................................................................5 禁止对实数类型的变量做相等比较操作.............................................................................................5 使用不起作用的语句 ................................................................................................................................5 存在空语句 ..................................................................................................................................................5 IF语句中没有ELSE分支 ......................................................................................................................5 禁止SWITCH语句为空 .........................................................................................................................5 SWITCH语句中只包含DEFAULT ....................................................................................................5
Testbed 术语表 86 87 88 89 90 93 95 96 97 98 99 100 103 104 105 106 107 108 109 110 111 112 113 115 116 117 118 119
SWITCH语句中的CASE语句没有由BREAK语句来终止 .......................................................6 过程/函数的参数表为空...........................................................................................................................6 返回类型为VOID的的过程出现在表达式中 ...................................................................................6 VOID类型的变量作为参数进行传递 ..................................................................................................6 函数中只有RETURN语句没有返回值 ..............................................................................................6 使用#PRAGMA .........................................................................................................................................6 指针指向比分配更大的范围 ...................................................................................................................6 有符号的位域少于2个比特位的空间 .................................................................................................6 位域既不是有符号的整型也不是无符号的整型 ...............................................................................6 声明联合.......................................................................................................................................................6 在头文件前有可执行代码 .......................................................................................................................6 宏中使用了多个#和## ..............................................................................................................................6 禁止定义不像函数的宏............................................................................................................................6 指针的指针超过两级 ................................................................................................................................6 使用三字母词..............................................................................................................................................6 使用WCHAR_T类型..............................................................................................................................7 使用八进制数..............................................................................................................................................7 使用寄存器变量 .........................................................................................................................................7 枚举元素的初始化不完整 .......................................................................................................................7 重新定义保留字 .........................................................................................................................................7 用指针进行代数运算 ................................................................................................................................7 嵌入汇编程序时,嵌入的过程不是纯汇编程序 ...............................................................................7 字符类型没有标明是有符号还是无符号.............................................................................................7 对变量重命名..............................................................................................................................................7 在枚举中重复使用一个名字 ...................................................................................................................7 未使用 ...........................................................................................................................................................7 对指针变量使用强制类型转换 ..............................................................................................................7 对其它类型变量强制转换成指针变量 .................................................................................................7
上海创景计算机系统有限公司 5
Testbed 术语表 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
访问标识应当有有效的顺序 .................................................................................................................16 结构中包含私有语句 ..............................................................................................................................16 使用匿名的名称空间 ..............................................................................................................................16 用宏定义数字常量...................................................................................................................................16 在表达式中使用替代数字的文字 ........................................................................................................16 类成员不是私有的...................................................................................................................................16 对常量强制类型转换 ..............................................................................................................................16 保留字CONTIUE和GOTO没有被定义成垃圾...........................................................................16 不要使用多重继承...................................................................................................................................16 文件间递归 ................................................................................................................................................16 在系统中任何地方程序都没有被调用 ...............................................................................................16 类初始化器顺序错乱 ..............................................................................................................................16 存在被0除 ................................................................................................................................................17 其它文件没有调用这个文件的程序....................................................................................................17 在C++中使用老式的/*注释符 .............................................................................................................17 私有成员名称末尾需要下划线 ............................................................................................................17 预处理命令没有缩进 ..............................................................................................................................17 宏名称没有大写 .......................................................................................................................................17 重载了&&, ||和逗号 ................................................................................................................................17 类中使用了友元函数 ..............................................................................................................................17 使用了友元类............................................................................................................................................17 成员没有声明为虚拟 ..............................................................................................................................17 构造函数或类被成员变量调用 ............................................................................................................17 指针名称没有必须的后缀 .....................................................................................................................17 变量名称只有大小写不同 .....................................................................................................................17 函数名和库函数名相同..........................................................................................................................17 使用以下划线开始的变量名 .................................................................................................................17 全局类型没有前缀...................................................................................................................................17
上海创景计算机系统有限公司 11
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
类/结构/联合/枚举的名称以小写字符开始 .......................................................................................17 变量名的第一个字符是大写的 ............................................................................................................18 全局函数没有前缀...................................................................................................................................18 枚举类型变量的第一个字符是大写的 ...............................................................................................18 文件的扩展名不是CPP或HPP..........................................................................................................18 文件名包含大写字母 ..............................................................................................................................18 位域不是八进制,十六进制或没有后缀U ......................................................................................18 位操作数不是八进制,十六进制或没有后缀U .............................................................................18 在宏定义中,“(”或“{”不匹配 ...............................................................................................18 在宏定义中,“)”或“}”不匹配 ...............................................................................................18 没有类的拷贝构造函数的定义 ............................................................................................................18 没有类的赋值操作的定义 .....................................................................................................................18 没有类的析构函数的定义 .....................................................................................................................18 没有类拷贝构造函数的指针定义 ........................................................................................................18 没有类的赋值操作的指针定义 ............................................................................................................18 没有类的析构函数的指针定义 ............................................................................................................18 类中没有使用新的赋值操作 .................................................................................................................18 赋值操作的参数不是常量 .....................................................................................................................18 模版的数目超过***.................................................................................................................................19 类中没有使用拷贝构造函数 .................................................................................................................19 使用动态造型............................................................................................................................................19 使用REINTERRUPT造型 ..................................................................................................................19 使用CONST造型 ...................................................................................................................................19 带有#DEFINE的被包含文件没有被保护 ........................................................................................19 重载NEW和DELETE .........................................................................................................................19 在嵌套模块中有CASE语句 ................................................................................................................19 类缺少访问标识 .......................................................................................................................................19 宏定义调用自己 .......................................................................................................................................19
Testbed 术语表 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
在预处理程序中被0除 ..........................................................................................................................19 对布尔类型的操作不当..........................................................................................................................19 未使用 .........................................................................................................................................................19 被包含文件内包含文件..........................................................................................................................19 使用了STDIO.H而不是IOSTREAM.H .........................................................................................19 文字数字使用小写后缀..........................................................................................................................19 忽略了相反类型操作符..........................................................................................................................19 运算没有返回THIS指针的引用.........................................................................................................20 使用#IF,#IFDEF,#ELSE,#ELSEIF ....................................................................................................20 程序原代码超过***行 ............................................................................................................................20 #INCLUDE后的文件名没有加“< >” ..............................................................................................20 头文件中包含多个类 ..............................................................................................................................20 语句没有另起一行开始写 .....................................................................................................................20 类中没有缺省的构造函数声明 ............................................................................................................20 未使用 .........................................................................................................................................................20 非虚函数重定义 .......................................................................................................................................20 禁用命名空间............................................................................................................................................20 禁用类模版 ................................................................................................................................................20 函数模版禁用............................................................................................................................................20 类声明中有构造函数定义 .....................................................................................................................20 用小写字符表示十六进制数 .................................................................................................................20 FOR循环语句使用空初始化表达式 ..................................................................................................20 FOR循环语句使用空增量表达式.......................................................................................................20 FOR循环语句的初始化表达式很复杂..............................................................................................20 FOR循环语句的增量表达式很复杂 ..................................................................................................21 使用#IFNDEF(参考删除)....................................................................................................................21 使用#DEFINE ........................................................................................................................................21 变量名称的长小于*** ............................................................................................................................21
上海创景计算机系统有限公司 13
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
结构,联合或枚举缺少标识符 ............................................................................................................21 CASE不是SWITCH语句的枚举部分 .............................................................................................21 SWITCH语句的选择不是枚举 ...........................................................................................................21 SWITCH语句缺少附加的CASE语句 .............................................................................................21 使用TRY关键字.....................................................................................................................................21 使用CATCH关键字 ..............................................................................................................................21 使用THROW关键字 ............................................................................................................................21 使用易变关键字 .......................................................................................................................................21 使用多个直接继承...................................................................................................................................21 强制转换之前有强制转换 .....................................................................................................................21 类不需要定义在文件中..........................................................................................................................21 在头文件中定义函数 ..............................................................................................................................21 在头文件中定义变量 ..............................................................................................................................21 头文件的扩展名不是.H..........................................................................................................................22 头文件名不包含类名 ..............................................................................................................................22 文件名不包含被定义的类名 .................................................................................................................22 函数的第一个参数与函数不同行 ........................................................................................................22 #INCLUDE和文件名之间没有空格 ..................................................................................................22 使用非标准的构造...................................................................................................................................22 被嵌套的命名空间超过*** ...................................................................................................................22 使用连字.....................................................................................................................................................22 函数/过程在块范围内中声明................................................................................................................22 内联函数多于***行.................................................................................................................................22 使用非CONST指针指向函数 .............................................................................................................22 函数指针的声明没有使用TYPEDEF................................................................................................22 指针在使用之前没有检查是不是为NULL ......................................................................................22 存在不可达代码 .......................................................................................................................................22 文件扩展名不是.CPP .............................................................................................................................22
Testbed 术语表 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
“}”和“{”不在同一条垂直线上 ...............................................................................................22 注释中可能包含代码 ..............................................................................................................................22 虚类成员函数必须要虚析构函数 ........................................................................................................23 成员函数应该定义成常量类型 ............................................................................................................23 使用无符号数进行运算..........................................................................................................................23 对标准...未使用的检查标注 ..................................................................................................................23 未使用的检查标注...................................................................................................................................23 使用了C类型转换 ..................................................................................................................................23 使用#LINE,#ERROR预处理指示......................................................................................................23 未使用的检查标注...................................................................................................................................23 未使用 .........................................................................................................................................................23 “*”或“&”没有和类型连在一起 ...........................................................................................................23 发现有数组参数 .......................................................................................................................................23 非局部定义不在命名空间里 .................................................................................................................23 函数名称不全是小写 ..............................................................................................................................23 变量名称不全是小写 ..............................................................................................................................23 企图写未打开的文件 ..............................................................................................................................23 文件指针在退出时没有关闭 .................................................................................................................23 SWITCH语句只有一条CASE和DEFAULT................................................................................23 在“.”操作符的前后是空白 ....................................................................................................................24 位域不是无符号整型 ..............................................................................................................................24 TYPEDEF定义的名称以小写字母开始 ...........................................................................................24 名称的第一个字母之后不是小写的....................................................................................................24 构造函数没有完全初始化 .....................................................................................................................24 未使用 .........................................................................................................................................................24 未使用 .........................................................................................................................................................24 被包含的文件有路径 ..............................................................................................................................24 DEFAULT不是SWITCH语句最后的CASE................................................................................24
上海创景计算机系统有限公司 15
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
SWITCH有多个DEFAULT ...............................................................................................................24 宏调用时,参数个数不正确 .................................................................................................................24 标记符使用不一致...................................................................................................................................24 声明变量缺少变量类型..........................................................................................................................24 结构成员名称重用...................................................................................................................................24 在位域结构中存在非位域成员 ............................................................................................................24 无格式字符操作不当 ..............................................................................................................................24 存在潜在的类型转换 ..............................................................................................................................24 字面值需要一个U后缀 .........................................................................................................................25 强制扩展复杂的整型表达式 .................................................................................................................25 强制扩展复杂的浮点型表达式 ............................................................................................................25 当”~”或“<<”操作符应用于小类型时,没有强制转换 .............................................................25 被定义的操作符包含非法项 .................................................................................................................25 #IF扩展包含DEFINE操作符.............................................................................................................25 在#IF中使用未定义的宏变量..............................................................................................................25 #INCLUDE之前有非预处理指示.......................................................................................................25 #INCLUDE 带有非法项 ........................................................................................................................25 像使用宏一样使用函数..........................................................................................................................25 预处理程序构造作为宏参数 .................................................................................................................25 在预处理程序之后有额外的字符 ........................................................................................................25 在同一个文件中#ELSE没有#IF .........................................................................................................25 强制转换VOLATILE 型的值 .............................................................................................................25 位操作带有浮点操作数..........................................................................................................................25 位域既不是整型也不是枚举类型 ........................................................................................................25 宏参数列表有主要的间隔 .....................................................................................................................25 使用NULL宏...........................................................................................................................................26 枚举变量不全是小写的..........................................................................................................................26 常量不全是小写的...................................................................................................................................26
Testbed 术语表 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
类型声明带有变量定义..........................................................................................................................26 不在头文件中声明类型..........................................................................................................................26 内存没有被释放 .......................................................................................................................................26 从释放内存读数据...................................................................................................................................26 内联函数多于***条语句........................................................................................................................26 外部声明不在头文件中..........................................................................................................................26 变量名不超过***个字符........................................................................................................................26 声明指针的指针 .......................................................................................................................................26 基类有虚基类和非虚基类 .....................................................................................................................26 类的成员名重用 .......................................................................................................................................26 使用缺省参数............................................................................................................................................26 矛盾的类型 ................................................................................................................................................26 表达式需要括号 .......................................................................................................................................26 命名空间里存在MAIN函数 ................................................................................................................26 成员变量不是用“=”赋值 ...................................................................................................................27 未使用 .........................................................................................................................................................27 继承类对缺省的参数重定义 .................................................................................................................27 十六进制数用大写字符..........................................................................................................................27 字符串的延续使用“” ..............................................................................................................................27 宏的延续使用“” .......................................................................................................................................27 PRAGMA的延续使用“”.......................................................................................................................27 变量名称的长度大于***........................................................................................................................27 IF嵌套深度大于***................................................................................................................................27 参数列表中的逗号之后没有空格间隔 ...............................................................................................27 “*”/“&”没有和变量名称连在一起 ...................................................................................................27 使用整数除法............................................................................................................................................27 变量名称与类型冲突 ..............................................................................................................................27 使用八进制的出口顺序..........................................................................................................................27
上海创景计算机系统有限公司 17
447 448 449 450 451 452 453 454 455 456 457
字符串中使用空格字符..........................................................................................................................27 在结构/联合/枚举中标识符和类型不一致 ........................................................................................27 宏代码超过***行 .....................................................................................................................................27 枚举元素没有在新的一行书写 ............................................................................................................28 枚举,结构和联合的变量没有被TYPEDEF ..................................................................................28 没有返回值的声明缺少VOID .............................................................................................................28 标识符名称和宏的名称一致 .................................................................................................................28 在31个字符内,标识符和宏的名称一致.........................................................................................28 MISRA的SWITCH语句有语法违反...............................................................................................28 所有的内部联接调用不可达 .................................................................................................................28 程序之后少于***行空白行 ...................................................................................................................28
Testbed 编码规则列表 1
1 2
过程名被重用
1 S Procedure name reused. 801 MISRA-C2 5.2 MISRA/DERA 21
标号名被重用
2 S Label name reused. MISRA/DERA 12
3 4
5 6 7 8 9
文件中可执行格式化代码行超过***行 程序格式化代码行超过***行 then语句为空
3 S More than *** executable reformatted lines in file. EADS-C 4
4 S Procedure exceeds *** reformatted lines.
5 S Empty then clause. DERA 141
声明函数指针
6 S Procedure pointer declared.
跳出程序体
7 S Jump out of procedure.
else语句为空
8 S Empty else clause.
在非赋值表达式中出现了赋值操作符
9 S Assignment operation in expression. MISRA/DERA 33, 35, 40, 46 EADS-C 166,167
10 11
未使用
循环体没有用大括号括起来
10 S Not used
11 S No brackets to loop body (added by Testbed). MISRA/DERA 59 MISRA-C2 14.8 EADS-C 145,165,166,167
12 then/else中的语句没有用大括号括起来
12 S No brackets to then/else (added by Testbed). MISRA/DERA 59 MISRA-C2 14.9 EADS-C 145 13 使用goto语句
13 S goto detected. MISRA/DERA 56 MISRA-C2 14.4 EADS-C 119
14 15
将过程定义为参数 结构体定义中含有空域
14 S Procedural parameter declared. DERA 149
15 S Anonymous field to structure. MISRA/DERA 108, 113 16 声明多重标号
16 S Multiple labels declared.
上海创景计算机系统有限公司 1 Testbed 术语表
17 内嵌使用汇编代码
17 S Code insert found. MISRA/DERA 3 18 函数参数超过***个
18 S More than *** parameters in procedure.
19 未被调用的函数使用函数作为参数
19 S Procedural para used in an uncalled procedure. 20 参数未使用类型声明
20 S Parameter not declared explicitly. 21 未使用 21 S Not in use.
22 23 24
使用一些模糊的语句(如=+,=-) 函数未被调用
使用让工具不进行分析的注释/*LDRA_NOANALYSIS*/
22 S Use of obsolete language feature ( use = - ) MISRA/DERA 1 DERA 137
23 S Procedure is not called in text analysed.
24 S Use of Noanalysis annotation. 25 casw语句为空
25 S Null case(s) in switch statement.
26 使用无限循环
26 S Infinite loop used. DERA 142 EADS-C 133 27 返回类型为VOID的函数有return语句
27 S VOID procedure with return statement. MISRA/DERA 84 EADS-C 112 28 继承类中复用基类
28 S Duplicated Base Classes in a Derived class. 29 使用-=或+=操作符
29 S Use of += or -= operators found.
30 使用++或者—操作符
30 S Deprecated usage of ++ or -- operators found. MISRA/DERA 33, 46 MISRA-C2 12.13
31 在循环中使用break语句
31 S Use of break statement in loop. MISRA/DERA 58 MISRA-C2 14.6 EADS-C 120
32 使用continue语句
32 S Use of continue statement. MISRA/DERA 57 MISRA-C2 14.5 EADS-C 119
上海创景计算机系统有限公司 2
Testbed 术语表 33 34 35 36
使用三重表达式
对过程的声明中未对参数进行说明 圈复杂度大于***
过程不是单纯的顺序嵌套循环 函数包含基本结点 函数非结构化 函数包含无限循环 未使用的函数参数
函数不是所有的路径上都有返回值 函数的实参是全局变量 代码中有多余变量
存在UR(变量未赋初值就引用)数据流异常 使用函数递归调用
33 S Use of ternary expression found. EADS-C 134
34 S No parameters declared in proc specification.
1 C Cyclomatic complexity greater than ***.
2 C Procedure is not reducible in terms of intervals.
37 38 39 40 41 42 43 44 45
3 C Procedure contains essential knots.
4 C Procedure is not structured.
5 C Procedure contains infinite loop. DERA 142
1 D Unused procedure parameter.
2 D Function does not return a value on all paths. MISRA/DERA 75 MISRA-C2 16.8
3 D Actual parameter is also global to procedure. DERA 148
4 D Variables declared but not used in code analysed. DERA 143
5 D UR data flow anomalies found. MISRA/DERA 30 MISRA-C2 9.1
6 D Recursion in procedure calls found. MISRA/DERA 70 MISRA-C2 16.2 EADS-C 117
46 47 48 49
存在DU(定义后未引用就退出作用域)数据流异常 存在DD(定义后未被引用就被再定义)数据流异常 被定义的参数可能存在Clear Path 在函数内部使用全局变量
7 D DU data flow anomalies found.
8 D DD data flow anomalies found.
9 D Defined parameter has possible clear path. DERA 151
10 D Globals used inside procedure.
上海创景计算机系统有限公司 3 Testbed 术语表 50 51 52 53 54 55 56 57 58
参数与期望的作用不匹配
被引用的变量可能存在Clear Path 函数中全局变量使用与局部变量作用类似 改变变量已被传递的值 存在未被使用的过程参数 函数调用中存在相同的实参 局部变量对结果没有意义 函数有多入口 函数有多出口
11 D Parameters do not match expected actions.
12 D Referenced parameter has possible clear path.
13 D Global used in procedure matches local parameter.
14 D Attempt to change parameter passed by value. DERA 152
15 D Unused procedural parameter.
16 D Identical actual parameters in call DERA 153
1 I Local variables contribute nothing to results.
6 C Procedure has more than one entry point.
7 C Procedure has more than one exit point. MISRA/DERA 82 MISRA-C2 14.7 EADS-C 111
59 60 61 62 63 64 65 66
静态过程没有被调用 函数没有返回语句
过程参数只有类型没有标识符 使用静态类成员
使用不恰当的循环变量类型 循环变量必须是局部的 在函数参数表中使用省略号 在结构体定义中使用位域
35 S Static Procedure is not called in text analysed.
36 S Function has no return statement. MISRA/DERA 75 MISRA-C2 16.8
37 S Procedure Parameter has a type but no identifier. MISRA/DERA 73 MISRA-C2 16.3
38 S Use of Static class member.
39 S Unsuitable type for loop variable. MISRA/DERA 65 MISRA-C2 13.4
40 S Loop index is not declared locally.
41 S Ellipsis used in procedure parameter list. MISRA/DERA 69 MISRA-C2 16.1
42 S Use of bit field in structure declaration. MISRA/DERA 111 MISRA-C2 3.5
上海创景计算机系统有限公司 4 Testbed 术语表 67 68
使用setjmp/longjmp
使用禁用的过程,函数,文件或名称
43 S Use of setjmp/longjmp. MISRA/DERA 122 AV 20 MISRA-C2 20.7
44 S Use of banned function or variable. MISRA/DERA 118 AV 17,18,19,21,22,23,24,25 MISRA
69 71 72
未使用 数组越界
在switch语句中没有default 语句
45 S Not in use.
47 S Array Bound exceeded. MISRA/DERA 4
48 S No default case in switch statement. MISRA/DERA 62 AV 194,196 MISRA-C2 15.3 EADS-C 1
74 75 76
对有符号类型进行移位操作 移位运算溢出
禁止给无符号变量赋负值
50 S Use of shift operator on signed type. MISRA/DERA 37
51 S Shifting value too far. MISRA/DERA 38 AV 164 MISRA-C2 12.8
52 S Unsigned expression negated. MISRA/DERA 39 AV 165 MISRA-C2 12.9
77 使用逗号操作符
53 S Use of comma operator. MISRA/DERA 42 AV 168 MISRA-C2 12.10
78 长度操作符sizeof的副作用
54 S Sizeof operator with side effects. MISRA/DERA 40 AV 166 MISRA-C2 12.3
80 禁止对实数类型的变量做相等比较操作
56 S Equality comparison of floating point. MISRA/DERA 50 AV 202 MISRA-C2 13.3 EADS-C 102 81 使用不起作用的语句
57 S Statement with no side effect. MISRA/DERA 53 AV 187 MISRA-C2 14.2 82 存在空语句
58 S Null statement found. MISRA/DERA 54 83 if语句中没有else分支
59 S Else alternative missing in if. MISRA/DERA 60 AV 192 MISRA-C2 14.10 84 禁止switch语句为空
60 S Empty switch statement. MISRA/DERA 64 AV 64 85 switch语句中只包含default
61 S Switch contains default only. MISRA/DERA 64 AV 64 MISRA-C2 15.5
上海创景计算机系统有限公司 5 Testbed 术语表 86 switch语句中的case语句没有由break语句来终止
62 S Switch Case not terminated with break. MISRA/DERA 61 AV 193 MISRA-C2 15.2 15.5 EADS-C 87 过程/函数的参数表为空
63 S Empty parameter list to procedure/function. MISRA/DERA 76 MISRA-C2 16.5 EADS-C 109 88 返回类型为void的的过程出现在表达式中
64 S Void procedure used in expression. MISRA/DERA 79 89 void类型的变量作为参数进行传递
65 S Void variable passed as parameter. MISRA/DERA 80 90 函数中只有return语句没有返回值
66 S Function with empty return expression. MISRA/DERA 83 MISRA-C2 16.8 93 使用#pragma
69 S #pragma used. MISRA/DERA 99 AV 26 MISRA-C2 3.4 95 指针指向比分配更大的范围
71 S Pointer assignment to wider scope. MISRA/DERA 106 AV 111,173 MISRA-C2 17.6 96 有符号的位域少于2个比特位的空间
72 S Signed bit field less than 2 bits wide. MISRA/DERA 111, 112 MISRA-C2 6.5 97 位域既不是有符号的整型也不是无符号的整型
73 S Bit field not signed or unsigned int. MISRA/DERA 111 MISRA-C2 6.4 98 声明联合
74 S Union declared. MISRA/DERA 109, 110 DERA 164 AV 153 MISRA-C2 18 99 在头文件前有可执行代码
75 S Executable code before an included file. MISRA/DERA 87 MISRA-C2 19.1
100 宏中使用了多个#和##
76 S More than one of # or ## in a macro. MISRA/DERA 98 MISRA-C2 19.12
103 禁止定义不像函数的宏
79 S Macro contains unacceptable items MISRA/DERA 90 DERA 157 MISRA-C2 19.4 EADS-C++ 4
104 指针的指针超过两级
80 S Pointer indirection exceeds 2 levels. MISRA/DERA 102 AV 169,170 MISRA-C2 17.5
105 使用三字母词
81 S Use of trigraphs. MISRA/DERA 7 AV 11 MISRA-C2 4.2 EADS-C++ 52
上海创景计算机系统有限公司 6 Testbed 术语表 106 使用wchar_t类型
82 S Use of wide string literal. MISRA/DERA 8 AV 13
107 使用八进制数
83 S Octal number found. MISRA/DERA 19 AV 149 MISRA-C2 7.1
108 使用寄存器变量
84 S Register variable declared. MISRA/DERA 28 AV 140
109 枚举元素的初始化不完整
85 S Incomplete initialisation of enumerator. MISRA/DERA 32 AV 145 MISRA-C2 9.3 EADS-C 81 EAD
110 重新定义保留字
86 S Attempt to define reserved word. MISRA/DERA 114 MISRA-C2 20.1
111 用指针进行代数运算
87 S Use of pointer arithmetic. MISRA/DERA 101 AV 215 MISRA-C2 17.1 17.4
112 嵌入汇编程序时,嵌入的过程不是纯汇编程序
88 S Procedure is not pure assembler. MISRA/DERA 3 MISRA-C2 2.1
113 字符类型没有标明是有符号还是无符号
89 S char type not signed or unsigned. MISRA/DERA 14
115 对变量重命名
91 S Name redeclared in another namespace (MR). MISRA/DERA 12 801 MISRA-C2 5.6 EADS-C 53
116 在枚举中重复使用一个名字
92 S Duplicate use of a name in an enumeration. MISRA/DERA 12 801 MISRA-C2 5.2
117 未使用
93 S Not in use MISRA/DERA 18, 48 MISRA-C2 6.1
118 对指针变量使用强制类型转换
94 S Casting operation on a pointer. MISRA/DERA 45 AV 182 MISRA-C2 11.2 11.3 11.4 EA
119 对其它类型变量强制转换成指针变量
95 S Casting operation to a pointer. MISRA/DERA 45 AV 182 MISRA-C2 11.4 EADS-C++ 28
122 未使用
98 S Not used. MISRA-C2 16.6
123 非调用的方式使用函数
99 S Function use is not a call. MISRA/DERA 85
124 未使用
100 S Not used. MISRA-C2 19.2
上海创景计算机系统有限公司 7
Testbed 术语表 125 函数返回类型不一致
101 S Function return type inconsistent. MISRA/DERA 83iii 801
126 函数和函数的原型的返回不一致
102 S Function and prototype return inconsistent (MR). MISRA/DERA 72 MISRA-C2 8.3
127 函数和函数的原型的形参不一致
103 S Function and prototype param inconsistent (MR). MISRA/DERA 72, 26 MISRA-C2 8.4
128 结构体变量的初始化类型不一致
104 S Struct field initialisation incorrect. MISRA/DERA 31
129 结构体变量初始化的嵌套结构不一致
105 S Struct field initialisation brace fault. MISRA/DERA 29 AV 144 MISRA-C2 9.2
130 标识符超出***字符
17 D Identifier not unique within *** characters. MISRA/DERA 11 AV 46 MISRA-C2 1.4 5.1
131 标识符名称重用
18 D Identifier name reused MISRA/DERA 12 AV 135 MISRA-C2 5.5
132 过程在被定义前调用
19 D Procedure called before being defined. MISRA/DERA 20, 71
133 变量在使用前没有被声明
20 D No declaration for variable found before use. MISRA/DERA 20
134 过程的声明在模块的内部
21 D Procedure declared in inner block MISRA/DERA 68
135 函数存在全局变量的副作用
22 D Function has global variable side effects MISRA/DERA 33, 46 MISRA-C2 12.4
136 函数存在形参的副作用
23 D Function has parameter side effects MISRA/DERA 33, 46
137 函数没有定义原型
24 D Procedure definition has no associated prototype MISRA/DERA 71 MISRA-C2 8.1 EADS-C 107,118
138 变量的范围可以减少
25 D Scope of variable could be reduced MISRA/DERA 22 MISRA-C2 8.7
139 变量在一个文件中只能被定义一次
26 D Variable should be defined once in only one file MISRA/DERA 25 AV 139 MISRA-C2 8.8
140 一个文件的变量应该被声明为静态的
27 D Variable should be declared static MISRA/DERA 23 MISRA-C2 8.10 8.11 EADS-C 97
上海创景计算机系统有限公司 8 Testbed 术语表 141 使用volatile类型的定义
106 S Volatile declaration. AV 205
142 三重表达式中类型不匹配
107 S Type mismatch in ternary expression. DERA 144
143 未使用 108 S Not used.
144 数组的下标不是整形
109 S Array subscript is not integral. DERA 162
146 标号不是包含在switch语句中的
111 S Label is not part of switch statement (MR). MISRA/DERA 55 AV 188
147 用typedef定义的类型名被重新定义
112 S Typedef name redeclared. MISRA/DERA 17 MISRA-C2 5.3 5.6
148 存在潜在的无限循环
28 D Potentially infinite loop found EADS-C 133
149 部分地使用结构体变量
29 D Partially used structure parameter
150 未使用
30 D Unused in C/C++
151 参数结构不一致
31 D Parameter structure mismatch
152 形参没有定义
32 D Formal parameter not defined
153 外部变量没有真实的声明
33 D No real declaration for external variable MISRA/DERA 25
154 源程序中使用非标准字符
113 s Non standard character in source. MISRA/DERA 5 AV 9 70 外部的在头文件中没有提及
46 S extern not in nominated include file. MISRA/DERA 27 73 逻辑上关联的表达式需要括号
49 S Logical conjunctions need brackets. MISRA/DERA 34 AV 158,213 EADS-C 98 79 一个表达式有多个功能
55 S Expression with more than one function. MISRA/DERA 46 91 在模块中使用#define
67 S #Define used in a block. MISRA/DERA 91 MISRA-C2 19.5
上海创景计算机系统有限公司 9 Testbed 术语表 92 使用#undef
68 S #undef used. MISRA/DERA 92 MISRA-C2 19.6 20.1
94 使用指针做逻辑比较
70 S Logical comparison of pointers. MISRA/DERA 103 AV 171 MISRA-C2 17.3
101 宏表示的带参数的函数,宏没有附上括号
77 S Macro is not function like. MISRA/DERA 96 AV 29 EADS-C 92
102 宏的参数没有括号
78 S Macro parameter not in brackets. MISRA/DERA 96 MISRA-C2 19.10 EADS-C 92
114 使用基本类型的声明
90 S Basic type declaration used. MISRA/DERA 13 AV 209 MISRA-C2 6.3 EADS-C 84
120 使用混合方式运算
96 S Use of mixed mode arithmetic. MISRA/DERA 43, 48 AV 162,180,184 MISRA-C2 6.2 1
121 多余的类型转换
97 S Use of redundant cast. MISRA/DERA 44, 48 AV 181
145 使用单行注释//
110 S Use of single line comment //. MISRA/DERA 1 MISRA-C2 2.2
155 表达式不是逻辑表达式
114 S Expression is not Boolean. MISRA/DERA 35,36,49 (One of) MISRA-C2 12.6 13.2
156 使用不正确的终止字符串 115 S String incorrectly terminated.
157 建议与0进行逻辑比较
116 S Boolean comparison with 0 preferred. DERA 138
158 对常量值进行逻辑非的运算 117 S Logical negation of constant value.
159 主函数必须为int(void)或者int(int,char*[]) 118 S Main must be int (void) or int (int,char*[]). DERA 146
160 存在嵌套注释
119 S Nested comment found MISRA/DERA 9 MISRA-C2 2.3
161 对有符号类型使用位操作
120 S Use of bit operator on signed type. MISRA/DERA 37 AV 161 MISRA-C2 12.7
上海创景计算机系统有限公司 10 Testbed 术语表 162 switch语句的表达式是逻辑表达式
121 S Use of boolean expression in switch. MISRA/DERA 63 AV 195 MISRA-C2 15.4
163 使用abort,exit等函数
122 S Use of abort, exit, etc. MISRA/DERA 126 AV 24 MISRA-C2 20.11
164 枚举类型的越限使用
123 S Banned use of enumerated type. DERA 139 EADS-C++ 56,57
165 使用前缀“++”、“――”
124 S Use of prefix ++ or -- DERA 136
166 在宏中使用“##”、“#”
125 S Use of ## or # in a macro DERA 155 MISRA-C2 19.13
167 在同一个文件中#if没有#endif
126 S A #if has no #endif in the same file. DERA 156 MISRA-C2 19.17
168 数组没有边界限定
127 S Array has no bounds specified. DERA 162, DERA 166 MISRA-C2 8.12
169 参数与全局变量同名
128 S Parameter has same name as global variable. MISRA/DERA 12 DERA 128 801 MISRA-C2 5.2
170 参数与类型或标识符同名
129 S Parameter has same name as type or tag. MISRA/DERA 12 801 MISRA-C2 5.2
171 禁止使用头文件的内容
130 S Included file is not permitted. MISRA/DERA 123,124 AV 17,19,21,22,25 MISRA-C2 2
172 在整个系统中声明的类型不一致
1 X Declaration types do not match across a system. MISRA/DERA 26 MISRA-C2 8.4
173 不同的文件中过程名被重用
34 D Procedure name re-used in different files. MISRA/DERA 25
174 在函数内部变量名被重用
131 S Name reused in inner scope. MISRA/DERA 21 DERA 128 AV 135,138 801 MISRA-C2
175 在逻辑表达式中使用赋值操作符
132 S Assignment operator in boolean expression. MISRA/DERA 35 AV 160 MISRA-C2 13.1
176 赋值操作符与“&&”或“||”连用
133 S Assignment operator in RHS of && or || MISRA/DERA 33 AV 157
177 在复杂的表达式中使用volatile类型的变量
134 S Volatile variable in complex expression. MISRA/DERA 46 MISRA-C2 12.2
上海创景计算机系统有限公司 11 Testbed 术语表 178 参数表定义是KR形式
135 S Parameter list is KR. AV 8
179 位操作符带有布尔型的操作数
136 S Bit operator with boolean operand. MISRA/DERA 36
180 表达式有副作用
35 D Expression has side effects. MISRA/DERA 46 AV 157 MISRA-C2 12.4
181 位操作符作用于布尔值
137 S Bit operator acting on boolean value. MISRA/DERA 36
182 结构体中使用无名位域
138 S Anonymous bit field used in structure. MISRA/DERA 113 AV 156
183 由于设计原因导致某些代码不可执行
139 S Construct leads to infeasible code. MISRA/DERA 52
184 存在不可控制的循环条件
140 S Infeasible loop condition found. MISRA/DERA 52
185 结构声明不完整
141 S Incomplete structure or class declaration. MISRA/DERA 108
186 变量声明不明确
2 X Ambiguous declaration of variable. MISRA/DERA 25
187 形参的声明形式上不一致
142 S Parameter list declarations are inconsistent. MISRA/DERA 73
188 函数的原形与定义的形参名称不一致
36 D Prototype and Definition name mismatch. MISRA/DERA 74 MISRA-C2 16.4
189 函数调用有执行顺序副作用
1 Q Call has execution order dependant side effects. MISRA/DERA 33, 46 AV 157,204 MISRA-C2 12.2
190 函数有静态局部变量的副影响
37 D Function has persistent local side effects. MISRA/DERA 33, 46
191 表达式中使用{}
143 S Curly brackets used in expression.
192 禁止使用浮点运算
144 S Floating point not permitted. DERA 129
193 194
无效的 #if表达式 #define有空的参数列表
145 S #if has invalid expression.
146 S #define with empty parameter list.
上海创景计算机系统有限公司 12
正在阅读:
23.LDRA_Testbed_C++编码规则列表1.005-08
医学微生物学试题集(详细答案)05-05
在传承和创新中前进,让爱心与质量同行05-08
Book 1unit1 Grammar Direct speech & Indirect speech08-06
海船建造检验规程(2010)01-09
掉牙记作文500字06-30
静静地想你抒情诗歌03-21
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 编码
- 规则
- Testbed
- 列表
- LDRA
- 1.0
- 23