Home/Docs/Coding Standards/Achieve Autosar C++ Guidelines Compliance with CppDepend

Achieve Autosar C++ Guidelines Compliance with CppDepend

Achieve Autosar C++ Guidelines Compliance with CppDepend

Are you struggling to maintain Autosar C++ 2014 compliance in your automotive software projects? Look no further. CppDepend is here to streamline your code analysis process and ensure adherence to the stringent Autosar C++ guidelines. In this article, we'll explore how CppDepend automates compliance checks, improves code quality, and reduces time to market for your automotive software. Say goodbye to manual code reviews and embrace the power of CppDepend to achieve seamless Autosar C++ compliance.

To learn Autosar C++ 2014 Standards, you can print the Guidelines for the use of the C++14 language in critical and safety-related systems pdf by AUTOSAR.

Using Autosar C++ 2014 Rules in CppDepend

When you create a new CppDepend Project, a pop-up will appear displaying all the coding standards you would like to include in your analysis. To include Autosar coding standards, check the Autosar C++ 2014 option.

After analyzing your project, Navigate to the Queries and Rules Explorer section, and select the Autosar C++ 2014 Rules from the left-hand menu (Highlighted in red in the image below). This will display all the related Autosar C++ 2014 rules on the right. Upon clicking a Rule, the corresponding CQLinq query and the relevant source code will be automatically generated. Additionally, the Metrics View section provides a visualization of the issue's location and significance.

Incorporating Autosar Rules into the HTML Report

To include the Autosar rules in the generated HTML Report (available in the DevOps Edition), simply right-click on the Autosar C++ 2014 group and select "List Code Queries of this Group in a dedicated section in Report."

Uncessary Constructs

Rule M0–1–1: A project shall not contains unreachable code:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Misra" && issue.Type=="Rule0-1-7" select
new { issue,issue.FilePath,Line=issue.BeginLine}

Rule M0-1-9: There shall be no dead code:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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}

Storage

Rule M0–2–1: An object shall not be assigned to an overlapping object:

This coding standard is computed with the following query:

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}

Arithmetic

Rule A0-4-2: Type long double shall not be used:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Misra" && issue.Type=="Rule0-1-7" select
new { issue,issue.FilePath,Line=issue.BeginLine}

Lexical Conventions

Rule A2–5–1: Trigraphs shall not be used:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="trigraph_ignored" select
new { issue,issue.FilePath,Line=issue.BeginLine}

Rule A2-6-1: Digraphs shall not be used:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where  issue.Type=="Rule2-13-4" select
new { issue,issue.FilePath,Line=issue.BeginLine}

Rule A2-14-3:Type wchar\_t shall not be used:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where  issue.Type=="Rule2-13-4" select
new { issue,issue.FilePath,Line=issue.BeginLine}

Basic Concepts

Rule A3–1–1: It shall be possible to include any header file in multiple translationunits without violating the one definition rule:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule3-9-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}

Standard Conversions

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:

This coding standard is computed with the following query:

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\<,\<=,\>,\>=:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule4-10-2"
select new { issue,issue.FilePath,Line=issue.BeginLine}

Expressions

Rule A5–0–1:The value of an expression shall be the same under any order of evaluation that the standard permits:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName== "operator&"
select m

Rule M5–3–4: Evaluation of the operand to the sizeof operator shall not contain side effects:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule5-18-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}

Rule A5-2-1: dynamic\_cast should not be used:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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}

Statements

Rule M6–2–1: Assignement operators shall not be used in sub-expressions:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule6-4-8"
select new { issue,issue.FilePath,Line=issue.BeginLine}

Declarations

Rule A7-1-4: The register keyword shall not be used:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m

Rule M7-3-1: The global namespace shall only contain main, namespace declarations and extern "C" declarations:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m

Rule M7–3–2: The identifier main shall not be used for a function other than the global function main:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m

Rule M7–3–3: There shall be no unnamed namespaces in header files:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m

Rule M7–4–3: Assembly language shall be encapsulated and isolated:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m

Rule A7–5–1: A function shall not return a reference or a pointer to an automatic variable(including parameters), defined within the function:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m

Rule A7-1-6: The typedef specifier shall not be used:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName=="main" && m.ParentNamespace.Name!=""
select m

Declarators

Rule A8–4–1: Functions shall not be defined using the ellipsis notation:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.IsVariadic
select m

Rule A8–4–2: All exit paths from a function with non-void return type shall have an explicit return statement with an expression:

This coding standard is computed with the following query:

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 &:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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}

Classes

Rule M9–5–1: Unions shall not be used:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from f in **JustMyCode**.Fields where !f.ParentType.IsPOD && f.IsPublic
select f

Rule 12–1–1: An object's dynamic type shall not be used from the body of its constructor or destructor:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where
&& (m.MethodsCalled.Where(vm=>vm.IsVirtual).Count()>**0** || m.IsUsing("Keywords.dynamic_cast".AllowNoMatch()))
select m

Rule 12–1–2: All constructors that are callable with a single argument of fundamental type shall be declared explicit:

This coding standard is computed with the following query:

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 m

Rule 12–8–2: The copy assignment operator shall be declared protected or private in an abstract class:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.SimpleName== "operator=="
&& m.ParentType.IsAbstract && m.IsPublic
select m

Exceptions

Rule 15–0–2: An exception object should not have pointer type:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **JustMyCode**.Methods where m.IsEntryPoint
&& m.IsUsing("Keywords.generic_catch".AllowNoMatch()) select m

Rule 15–3–5: A class type exception shall always be caught by reference:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="exceptThrowInDestructor"
select new { issue,issue.FilePath,Line=issue.BeginLine}

Preprocessor

Rule 16–0–3: \#undef shall not be used:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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}

Library

Rule 17–0–1: Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefined:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule17-0-5"
select new { issue,issue.FilePath,Line=issue.BeginLine}

Rule 18–0–1: The C library shall not be used:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

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:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.Type=="Rule18-4-1"
select new { issue,issue.FilePath,Line=issue.BeginLine}

Try CppDepend Today

Start your 14-day free trial with full access to all documentation features. No credit card required.