使用 CppDepend 实现 Autosar C++ 指南合规
使用 CppDepend 实现 Autosar C++ 指南合规
您是否在为汽车软件项目维持 Autosar C++ 2014 合规而苦恼?不用再找了。CppDepend 可以简化您的代码分析流程,并确保遵守严格的 Autosar C++ 指南。在本文中,我们将探讨 CppDepend 如何自动化合规检查、提高代码质量并缩短汽车软件的上市时间。告别手动代码审查,拥抱 CppDepend 的强大功能,实现无缝的 Autosar C++ 合规。
要了解 Autosar C++ 2014 标准,您可以打印 Guidelines for the use of the C++14 language in critical and safety-related systems PDF 由AUTOSAR。
在CppDepend中使用AUTOSAR C++ 2014规则
创建新的 CppDepend 项目时,会弹出一个窗口,显示您想要包含在分析中的所有编码标准。要包含 Autosar 编码标准,请勾选 Autosar C++ 2014 选项。
分析项目后,导航到 Queries and Rules Explorer 部分,从左侧菜单中选择 Autosar C++ 2014 规则(在下图中以红色突出显示)。这将在右侧显示所有相关的 Autosar C++ 2014 规则。单击某条规则时,将自动生成相应的 CQLinq 查询和相关源代码。此外,Metrics View 部分提供问题位置和重要性的可视化。
将 Autosar 规则纳入 HTML 报告
要在生成的 HTML 报告中包含 Autosar 规则(在 DevOps Edition 中可用),只需右键单击 Autosar C++ 2014 组并选择“List Code Queries of this Group in a dedicated section in Report”。
AUTOSAR C++ 2014规则列表
不必要的构造
Rule M0–1–1: A project shall not contains unreachable code:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unreachable" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M0–1–2: A project shall not contain infeasible paths:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="knownConditionTrueFalse" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M0–1–3: A project shall not contains unused variables:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unused_variable" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M0–1–4: A project shall not contain non-volatile POD variable having only one use:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="unreadVariable" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M0–1–5: A project shall not contains unused typedef declarations:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unused_local_typedef" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A0-1-1: A project shall not contain instances of non-volatile variables being given values that are not subsequently used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="unreadVariable" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A0-1-2: The value returned by a function having a non-voidreturn type that is not an overloaded operator shall always be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Misra" && issue.Type=="Rule0-1-7" select
new { issue,issue.FilePath,Line=issue.BeginLine}规则M0-1-9: 不得存在死代码:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unreachable" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M0–1–11: There shall be no unused parameters in non virtual functions:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues**
where issue.ToolName=="Clang" && issue.Type=="warn_unused_parameter"
&& issue.RelatedMethod!=null && issue.RelatedMethod.IsVirtual
select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M0-1-12: There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues**
where issue.ToolName=="Clang" && issue.Type=="warn_unused_parameter"
&& issue.RelatedMethod!=null && !issue.RelatedMethod.IsVirtual
select new { issue,issue.FilePath,Line=issue.BeginLine}存储
Rule M0–2–1: An object shall not be assigned to an overlapping object:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="cppcoreguidelines-pro-type-union-access" select
new { issue,issue.FilePath,Line=issue.BeginLine}算术
Rule A0-4-2: Type long double shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Misra" && issue.Type=="Rule0-1-7" select
new { issue,issue.FilePath,Line=issue.BeginLine}词法约定
规则A2–5–1: 不得使用三字符组:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="trigraph_ignored" select
new { issue,issue.FilePath,Line=issue.BeginLine}规则A2-6-1: 不得使用二合符:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_cxx98_compat_less_colon_colon" select
new { issue,issue.FilePath,Line=issue.BeginLine}RuleA2-11-1: Identifiers declared in a inner scope shall not hide an ientifier declared in out of dcope:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_decl_shadow" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M2-10-6: If an identifier refers to a type, it shall not also refer to an object or a function in the same scope:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="err_redefinition_different_kind" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A2-14-1: Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="ext_unknown_escape" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M2-13-3: A U suffix shall be applied to all octal or hexadecimal integer literals of unsigned type:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule2-13-3" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M2-13-4: Literal suffixes shall be upper case:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule2-13-4" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A2-8-1:The character \\ shall not occur as a last character of a C++ comment:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="ext_multi_line_line_comment" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A2-14-2:String literals with different encoding prefixes shall not be concatenated:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule2-13-4" select
new { issue,issue.FilePath,Line=issue.BeginLine}规则A2-14-3: 不得使用类型wchar\_t:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule2-13-4" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A2-11-2:A “using” name shall be a unique identifier within a namespace:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule2-13-4" select
new { issue,issue.FilePath,Line=issue.BeginLine}基本概念
Rule A3–1–1: It shall be possible to include any header file in multiple translationunits without violating the one definition rule:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.NbLinesOfCode>**0**
&& m.SourceDecls.First().SourceFile.FileNameExtension.StartsWith("h")
select new { m,IncludeFile=m.SourceDecls.First().SourceFile.FilePathString }Rule M3–1–2: Functions shall not be declared at block scope:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule3-1-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule A3–1–4: When an array is declared, its size shall either be stated explicitly or defined implicitily by initialization:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule3-1-3"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule A3–3–1: Functions with extern linkage shall be declared in a header file:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule3-3-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M3–3–2: If a function has internal linkage then all re-declarations shall include the static storage class specifier:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule3-3-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M3–4–1: An identifier declared to be an object or type shall be defined in a block that minimizes its visibility:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="variableScope"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule A3–9–2: typedefs that indicate size and signedness should be used in place of the basic numerical types:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule3-9-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}标准转换
Rule M4–5–1: Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator \=, the logical operators &&, ||, \!,== and \!=, the unary & operator, and the conditional operator:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule4-5-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule A4–5–1: Expressions with type enum shall not be used as operands to built-in operators other than the subscript operator \[ \], the assignment operator \=, the equality operators \== and \!=, the unary & operator, and the relational operators\<,\<=,\>,\>=:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule4-5-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M4–5–3: Expressions with type (plain) char and wchar\_t shall not be used as operands to built-in operators other than the assignment operator \=, the equality operators \== and \!=, the unary & operator:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule4-5-3"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M4–10–2: Literal zero (0) shall not be used as the null-pointer-constant:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule4-10-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule A4-10-1: Only nullptr literal shall be used as the null-pointer-constant:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule4-10-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}表达式
Rule A5–0–1:The value of an expression shall be the same under any order of evaluation that the standard permits:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unsequence_mod_use" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–0–4 : An implicit integral conversion shall not change the signedness of the underlying type:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_impcast_integer_sign" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–0–5: There shall be no implicit floating-integral conversions:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_impcast_float_integer" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–0–6: An implicit integral or floating-point conversion shall not reduce the size of the underlying type:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_impcast_integer_precision" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5-0-7: There shall be no explicit floating-integral conversions of a cvalue expression:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="bugprone-integer-division" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–0–9: An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expression:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_impcast_integer_sign" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–0–15: Array indexing shall be the only form of pointer arithmetic:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="cppcoreguidelines-pro-bounds-pointer-arithmetic" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–0–18: \>, \>=, \<, \<= shall not be applied to objects of pointer type, except where they point to the same array:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="comparePointers" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A5-1-2: Variables shall not be implicitly captured in a lambda expression:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="cppcoreguidelines-pro-bounds-pointer-arithmetic" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–2–2: A pointer to a virtual base class shall only be cast to a pointer to a derived class by means of dynamic\_cast:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="err_static_downcast_via_virtual" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A5–2–2: C-style casts(other than void casts) and functional notation casts (other than explicit constructor calls) shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_old_style_cast" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–2–6: A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_cxx98_compat_cast_fn_obj" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–3–3: The unary & operator shall not be overloaded:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName== "operator&"
select mRule M5–3–4: Evaluation of the operand to the sizeof operator shall not contain side effects:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_side_effects_unevaluated_context_sizeof" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–8–1: The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule5-8-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–14–1: The right hand operand of a logical && or || operator shall not contain side effects:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule5-14-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5–18–1: The comma operator shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule5-18-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}规则A5-2-1: 不应使用dynamic\_cast:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="cppcoreguidelines-pro-bounds-pointer-arithmetic" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A5-2-3: A cast shall not remove any const or volatile qualification from the type of a pointer or reference:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="cppcoreguidelines-pro-bounds-pointer-arithmetic" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A5-2-4: reinterpret\_cast shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="cppcoreguidelines-pro-bounds-pointer-arithmetic" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A5-2-5: An array shall not be accessed beyond its range:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang-Tidy" && issue.Type=="cppcoreguidelines-pro-bounds-pointer-arithmetic" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M5-2-11: The comma operator, && operator and the || operator shall not be overloaded:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName== "operator&"
select m\>Rule A5-3-1:Evaluation of the operand to the typeid operator shall not contain side effects:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unsequence_mod_use" select
new { issue,issue.FilePath,Line=issue.BeginLine}语句
Rule M6–2–1: Assignement operators shall not be used in sub-expressions:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-2-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–2–2: Floating-point expressions shall not be directly or indirectly tested for equality or inequality:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_floatingpoint_eq" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–2–3: Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment, provided that the first character following the null statement is a white-space character:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-2-3"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–3–1: The statement forming the body of a switch, while, do...while or for statement shall be a compound statement:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-3-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–4–1: An if(condition) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–4–2: All if ... elseif constructs shall be terminated with an else clause:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6-4-3: A switch statement shall be a well-formed switch statement:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="warn_jump_out_of_scope" || issue.Type=="Rule6-6-2" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–4–4: A switch-label shall only be used when the most closely-enclosing compound statement is the body of a switch statement:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-4"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–4–5: An unconditional throw or break statement shall terminate every non-empty switch-clause:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unannotated_fallthrough" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–4–6:The final clause of a switch statement shall be the default-clause:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-6"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–4–7: The condition of a switch statement shall not have bool type:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_bool_switch_condition" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A6-4-1: A switch statement shall have at least two case-clauses, distinct from the default label:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-8"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule A6-5-2: A for loop shall contain a single loop-counter which shall not have floatingpoint type:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-8"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–6–1: Any label referenced by a goto statement shall be declared in the same block, or in a block enclosing the goto statement:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_jump_out_of_scope" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M6–6–2: The goto statement shall jump to a label declared later in the same function body:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-6-2" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule 6–6–5: A function shall have a single point of exit at the end of the function:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-6-5" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A6-6-1: The goto statement shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-8"
select new { issue,issue.FilePath,Line=issue.BeginLine}声明
Rule A7-1-4: The register keyword shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select mRule M7-3-1: The global namespace shall only contain main, namespace declarations and extern "C" declarations:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select mRule M7–3–2: The identifier main shall not be used for a function other than the global function main:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select mRule M7–3–3: There shall be no unnamed namespaces in header files:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule7-3-3"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M7–3–4: using-directives shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule7-3-4"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule M7–4–2: Assembler instructions shall only be introduced using the asm declaration:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select mRule M7–4–3: Assembly language shall be encapsulated and isolated:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select mRule A7–5–1: A function shall not return a reference or a pointer to an automatic variable(including parameters), defined within the function:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="returnAddressOfAutoVariable" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M7–5–2: The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="deadpointer" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A7-5-2: Functions should not call themselves, either directly or indirectly:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="deadpointer" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule A7-2-1: An expression with enumunderlying type shall only have values corresponding to the enumerators of the enumeration:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select mRule A7-1-6: The typedef specifier shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m声明符
Rule A8–4–1: Functions shall not be defined using the ellipsis notation:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.IsVariadic
select mRule A8–4–2: All exit paths from a function with non-void return type shall have an explicit return statement with an expression:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_maybe_falloff_nonvoid_function" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M8–4–4: A function identifier shall either be used to call the function or it shall be preceded by &:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_duplicate_enum_values" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M8–5–1: All variables shall have a defined value before they are used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_uninit_var" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M8–5–2: Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_missing_braces" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule M8–5–3: In an enumerator list, the \= construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_duplicate_enum_values" select
new { issue,issue.FilePath,Line=issue.BeginLine}类
规则M9–5–1: 不得使用联合体:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule9-5-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule A10–1–1: Classes should not be derived from virtual bases:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule10-1-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 10–3–2: Each overriding virtual function shall be declared with the virtual keyword:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule10-3-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 11–0–1: Member data in non-POD class types shall be private:
此编码标准通过以下查询计算:
warnif **count** > **0**
from f in **JustMyCode**.Fields where !f.ParentType.IsPOD && f.IsPublic
select fRule 12–1–1: An object's dynamic type shall not be used from the body of its constructor or destructor:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where
&& (m.MethodsCalled.Where(vm=>vm.IsVirtual).Count()>**0** || m.IsUsing("Keywords.dynamic_cast".AllowNoMatch()))
select mRule 12–1–2: All constructors that are callable with a single argument of fundamental type shall be declared explicit:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.IsConstructor && m.Params.Count()==**1** && m.Params.First().ParamType!=null
&& m.Params.First().ParamType.Name=="int" && !m.IsExplicitConstructor
select mRule 12–8–2: The copy assignment operator shall be declared protected or private in an abstract class:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName== "operator=="
&& m.ParentType.IsAbstract && m.IsPublic
select m异常
Rule 15–0–2: An exception object should not have pointer type:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule15-0-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 15–3–2: There should be at least one exception handler to catch all otherwise unhandled exceptions:
此编码标准通过以下查询计算:
warnif **count** > **0**
from m in **JustMyCode**.Methods where m.IsEntryPoint
&& m.IsUsing("Keywords.generic_catch".AllowNoMatch()) select mRule 15–3–5: A class type exception shall always be caught by reference:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="catchExceptionByValue"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 15–3–7: Where multiple handlers are provided in a single try-catch statement or function-try-block, any ellipsis (catch-all) handler shall occur last:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_exception_caught_by_earlier_handler" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule 15–5–1: A class destructor shall not exit with an exception:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="exceptThrowInDestructor"
select new { issue,issue.FilePath,Line=issue.BeginLine}预处理器
规则16–0–3: 不得使用\#undef:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_undef_used" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule 16–0–7: Undefined macro identifiers shall not be used in \#if or \#elif preprocessor directives, except as operands to the defined operator:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_pp_undef_identifier" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule 16–3–1: There shall be at most one occurrence of the \# or \#\# operators in a single macro definition:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_pp_hashhash_used" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule 16–3–2: The \# and \#\# operators should not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_pp_hash_used" select
new { issue,issue.FilePath,Line=issue.BeginLine}库
Rule 17–0–1: Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefined:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_reserved_id_macro" select
new { issue,issue.FilePath,Line=issue.BeginLine}Rule 17–0–5: The setjmp macro and the longjmp function shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule17-0-5"
select new { issue,issue.FilePath,Line=issue.BeginLine}规则18–0–1: 不得使用C库:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-0-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 18–0–2: The library functions atof, atoi and atol from library cstdlib shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-0-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 18–0–3: The library functions abort, exit, getenv and system from library cstdlib shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-0-3"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 18–0–4:The time handling functions of library shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-0-4"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 18–0–5: The unbounded functions of library cstring shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-0-5"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 18–2–1: The macro offsetof shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-2-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 18–4–1: Dynamic heap memory allocation shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-4-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 18–7–1: The signal handling facilities of csignal shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-7-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 19–3–1: The error indicator errno shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule19-3-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}Rule 27–0–1: The stream input/output library shall not be used:
此编码标准通过以下查询计算:
warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-4-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}