-
Notifications
You must be signed in to change notification settings - Fork 61
Files
/
Copy pathrules.csv
1001 lines (1001 loc) · 158 KB
/
rules.csv
1 | Language | Standard | ID | Supportable | Obligation level | Enforcement level | Allocated target | Description | Similar | Package | Difficulty | Justification for querability level |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | cpp | AUTOSAR | A0-1-1 | Yes | Required | Automated | Implementation | A project shall not contain instances of non-volatile variables being given values that are not subsequently used. | M0-1-6 | DeadCode | Medium | |
3 | cpp | AUTOSAR | A0-1-2 | Yes | Required | Automated | Implementation | The value returned by a function having a non-void return type that is not an overloaded operator shall be used. | M0-1-7 | DeadCode | Easy | |
4 | cpp | AUTOSAR | A0-1-3 | Yes | Required | Automated | Implementation | Every function defined in an anonymous namespace, or static function with internal linkage, or private member function shall be used. | M0-1-10 | DeadCode | Easy | |
5 | cpp | AUTOSAR | A0-1-4 | Yes | Required | Automated | Implementation | There shall be no unused named parameters in non-virtual functions. | DeadCode | Easy | ||
6 | cpp | AUTOSAR | A0-1-5 | Yes | Required | Automated | Implementation | There shall be no unused named parameters in the set of parameters for a virtual function and all the functions that override it. | DeadCode | Easy | ||
7 | cpp | AUTOSAR | A0-1-6 | Yes | Advisory | Automated | Implementation | There should be no unused type declarations. | M0-1-5 | DeadCode | Easy | |
8 | cpp | AUTOSAR | A0-4-1 | Yes | Required | Non-Automated | Infrastructure / Toolchain | Floating-point implementation shall comply with IEEE 754 standard. | Toolchain | Easy | Find certain pairs of types and platforms which are not IEEE 754 compatible. | |
9 | cpp | AUTOSAR | A0-4-2 | Yes | Required | Automated | Implementation | Type long double shall not be used. | BannedTypes | Easy | ||
10 | cpp | AUTOSAR | A0-4-3 | Yes | Required | Automated | Toolchain | The implementations in the chosen compiler shall strictly comply with the C++14 Language Standard. | Toolchain | Easy | Find cases where -std=gnu++14 is used instead of -std=c++14. Note: this is currently only possible for compilations that do not use response files. | |
11 | cpp | AUTOSAR | A0-4-4 | Yes | Required | Partially Automated | Implementation | Range, domain and pole errors shall be checked when using math functions. | TypeRanges | Hard | ||
12 | cpp | AUTOSAR | A1-1-1 | Yes | Required | Automated | Implementation | All code shall conform to ISO/IEC 14882:2014 - Programming Language C++ and shall not use deprecated features. | Toolchain | Hard | Appendix D of the Standard lists depreceated features. List is lengthy, but otherwise easy to write. This can also be compiler checked, so we should confirm that we also want this as a CodeQL check. | |
13 | cpp | AUTOSAR | A1-1-2 | Yes | Required | Non-Automated | Implementation / Toolchain | A warning level of the compilation process shall be set in compliance with project policies. | Toolchain | Easy | Note: this is currently only possible for compilations that do not use response files. | |
14 | cpp | AUTOSAR | A1-1-3 | Yes | Required | Non-Automated | Toolchain | An optimization option that disregards strict standard compliance shall not be turned on in the chosen compiler. | Toolchain | Easy | Note: this is currently only possible for compilations that do not use response files. | |
15 | cpp | AUTOSAR | A1-2-1 | No | Required | Non-Automated | Toolchain | When using a compiler toolchain (including preprocessor, compiler itself, linker, C++ standard libraries) in safety-related software, the tool confidence level (TCL) shall be determined. In case of TCL2 or TCL3, the compiler shall undergo a 'Qualification of a software tool', as per ISO 26262-8.11.4.6 [6]. | Allocated target not covered by CodeQL | |||
16 | cpp | AUTOSAR | A1-4-1 | No | Required | Non-Automated | Implementation / Verification | Code metrics and their valid boundaries shall be defined and code shall comply with defined boundaries of code metrics. | Allocated target not covered by CodeQL | |||
17 | cpp | AUTOSAR | A1-4-3 | No | Advisory | Automated | Implementation | All code should compile free of compiler warnings. | This should be checked via the compiler output, rather than CodeQL, which adds unnecessary steps. | |||
18 | cpp | AUTOSAR | A10-0-1 | Yes | Required | Non-Automated | Design | Public inheritance shall be used to implement 'is-a' relationship. | Inheritance | Audit | Report a list of Inheritance relationships. | |
19 | cpp | AUTOSAR | A10-0-2 | Yes | Required | Non-Automated | Design | Membership or non-public inheritance shall be used to implement 'has-a' relationship. | Inheritance | Audit | Report a list of membership relationships. | |
20 | cpp | AUTOSAR | A10-1-1 | Yes | Required | Automated | Implementation | Class shall not be derived from more than one base class which is not an interface class. | Inheritance | Easy | ||
21 | cpp | AUTOSAR | A10-2-1 | Yes | Required | Automated | Implementation | Non-virtual public or protected member functions shall not be redefined in derived classes. | VirtualFunctions | Easy | ||
22 | cpp | AUTOSAR | A10-3-1 | Yes | Required | Automated | Implementation | Virtual function declaration shall contain exactly one of the three specifiers: (1) virtual, (2) override, (3) final. | VirtualFunctions | Easy | ||
23 | cpp | AUTOSAR | A10-3-2 | Yes | Required | Automated | Implementation | Each overriding virtual function shall be declared with the override or final specifier. | VirtualFunctions | Easy | ||
24 | cpp | AUTOSAR | A10-3-3 | Yes | Required | Automated | Implementation | Virtual functions shall not be introduced in a final class. | VirtualFunctions | Easy | ||
25 | cpp | AUTOSAR | A10-3-5 | Yes | Required | Automated | Implementation | A user-defined assignment operator shall not be virtual. | Operators | Easy | ||
26 | cpp | AUTOSAR | A10-4-1 | Yes | Advisory | Non-Automated | Design | Hierarchies should be based on interface classes. | Inheritance | Audit | Report a list of hierarchies which don't use interfaces. | |
27 | cpp | AUTOSAR | A11-0-1 | Yes | Advisory | Automated | Implementation | A non-POD type should be defined as class. | Classes | Easy | ||
28 | cpp | AUTOSAR | A11-0-2 | Yes | Required | Automated | Implementation | A type defined as struct shall: (1) provide only public data members, (2) not provide any special member functions or methods, (3) not be a base of another struct or class, (4) not inherit from another struct or class. | Classes | Easy | ||
29 | cpp | AUTOSAR | A11-3-1 | Yes | Required | Automated | Implementation | Friend declarations shall not be used. | cpp/jsf/av-rule-70 | BannedSyntax | Easy | |
30 | cpp | AUTOSAR | A12-0-1 | Yes | Required | Automated | Implementation | If a class declares a copy or move operation, or a destructor, either via '=default', '=delete', or via a user-provided declaration, then all others of these five special member functions shall be declared as well. | cpp/rule-of-three | Classes | Easy | |
31 | cpp | AUTOSAR | A12-0-2 | Yes | Required | Partially Automated | Implementation | Bitwise operations and operations that assume data representation in memory shall not be performed on objects. | M5-0-21 | Expressions | Medium | |
32 | cpp | AUTOSAR | A12-1-1 | Yes | Required | Automated | Implementation | Constructors shall explicitly initialize all virtual base classes, all direct non-virtual base classes and all non-static data members. | M12-1-2 | Initialization | Medium | |
33 | cpp | AUTOSAR | A12-1-2 | Yes | Required | Automated | Implementation | Both NSDMI and a non-static member initializer in a constructor shall not be used in the same type. | Initialization | Medium | ||
34 | cpp | AUTOSAR | A12-1-3 | Yes | Required | Automated | Implementation | If all user-defined constructors of a class initialize data members with constant values that are the same across all constructors, then data members shall be initialized using NSDMI instead. | Initialization | Medium | ||
35 | cpp | AUTOSAR | A12-1-4 | Yes | Required | Automated | Implementation | All constructors that are callable with a single argument of fundamental type shall be declared explicit. | Initialization | Easy | ||
36 | cpp | AUTOSAR | A12-1-5 | Yes | Required | Partially Automated | Implementation | Common class initialization for non-constant members shall be done by a delegating constructor. | Initialization | Medium | ||
37 | cpp | AUTOSAR | A12-1-6 | Yes | Required | Automated | Implementation | Derived classes that do not need further explicit initialization and require all the constructors from the base class shall use inheriting constructors. | Initialization | Easy | ||
38 | cpp | AUTOSAR | A12-4-1 | Yes | Required | Automated | Implementation | Destructor of a base class shall be public virtual, public override or protected non-virtual. | OOP52-CPP | VirtualFunctions | Easy | |
39 | cpp | AUTOSAR | A12-4-2 | Yes | Advisory | Automated | Implementation | If a public destructor of a class is non-virtual, then the class should be declared final. | VirtualFunctions | Easy | ||
40 | cpp | AUTOSAR | A12-6-1 | Yes | Required | Automated | Implementation | All class data members that are initialized by the constructor shall be initialized using member initializers. | Classes | Easy | ||
41 | cpp | AUTOSAR | A12-7-1 | Yes | Required | Automated | Implementation | If the behavior of a user-defined special member function is identical to implicitly defined special member function, then it shall be defined '=default' or be left undefined. | Classes | Easy | ||
42 | cpp | AUTOSAR | A12-8-1 | Yes | Required | Automated | Implementation | Move and copy constructors shall move and respectively copy base classes and data members of a class, without any side effects. | M12-8-1 | SideEffects2 | Hard | |
43 | cpp | AUTOSAR | A12-8-2 | Yes | Advisory | Automated | Implementation | User-defined copy and move assignment operators should use user-defined no-throw swap function. | OperatorInvariants | Easy | ||
44 | cpp | AUTOSAR | A12-8-3 | Yes | Required | Partially Automated | Implementation | Moved-from object shall not be read-accessed. | EXP63-CPP | MoveForward | Import | |
45 | cpp | AUTOSAR | A12-8-4 | Yes | Required | Automated | Implementation | Move constructor shall not initialize its class members and base classes using copy semantics. | Initialization | Easy | ||
46 | cpp | AUTOSAR | A12-8-5 | Yes | Required | Automated | Implementation | A copy assignment and a move assignment operators shall handle self-assignment. | OOP54-CPP | OperatorInvariants | Import | |
47 | cpp | AUTOSAR | A12-8-6 | Yes | Required | Automated | Implementation | Copy and move constructors and copy assignment and move assignment operators shall be declared protected or defined '=delete' in base class. | M12-8-2 | Operators | Easy | |
48 | cpp | AUTOSAR | A12-8-7 | Yes | Advisory | Automated | Implementation | Assignment operators should be declared with the ref-qualifier &. | Operators | Easy | ||
49 | cpp | AUTOSAR | A13-1-2 | Yes | Required | Automated | Implementation | User defined suffixes of the user defined literal operators shall start with underscore followed by one or more letters. | Naming | Easy | ||
50 | cpp | AUTOSAR | A13-1-3 | Yes | Required | Automated | Implementation | User defined literals operators shall only perform conversion of passed parameters. | SideEffects2 | Easy | ||
51 | cpp | AUTOSAR | A13-2-1 | Yes | Required | Automated | Implementation | An assignment operator shall return a reference to 'this'. | cpp/assignment-does-not-return-this | OperatorInvariants | Easy | |
52 | cpp | AUTOSAR | A13-2-2 | Yes | Required | Automated | Implementation | A binary arithmetic operator and a bitwise operator shall return a 'prvalue'. | OperatorInvariants | Easy | ||
53 | cpp | AUTOSAR | A13-2-3 | Yes | Required | Automated | Implementation | A relational operator shall return a boolean value. | Operators | Easy | ||
54 | cpp | AUTOSAR | A13-3-1 | Yes | Required | Automated | Implementation | A function that contains 'forwarding reference' as its argument shall not be overloaded. | Operators | Easy | ||
55 | cpp | AUTOSAR | A13-5-1 | Yes | Required | Automated | Implementation | If 'operator[]' is to be overloaded with a non-const version, const version shall also be implemented. | Operators | Easy | ||
56 | cpp | AUTOSAR | A13-5-2 | Yes | Required | Automated | Implementation | All user-defined conversion operators shall be defined explicit. | Operators | Easy | ||
57 | cpp | AUTOSAR | A13-5-3 | Yes | Advisory | Automated | Implementation | User-defined conversion operators should not be used. | Operators | Easy | ||
58 | cpp | AUTOSAR | A13-5-4 | Yes | Required | Automated | Implementation | If two opposite operators are defined, one shall be defined in terms of the other. | OperatorInvariants | Easy | ||
59 | cpp | AUTOSAR | A13-5-5 | Yes | Required | Automated | Implementation | Comparison operators shall be non-member functions with identical parameter types and noexcept. | Operators | Easy | ||
60 | cpp | AUTOSAR | A13-6-1 | Yes | Required | Automated | Implementation | Digit sequences separators ' shall only be used as follows: (1) for decimal, every 3 digits, (2) for hexadecimal, every 2 digits, (3) for binary, every 4 digits. | Literals | Easy | ||
61 | cpp | AUTOSAR | A14-1-1 | Yes | Advisory | Non-Automated | Implementation | A template should check if a specific template argument is suitable for this template. | Templates | Medium | Look for classes with default constructors or assignment operators, with a template field which is not copyable/moveable | |
62 | cpp | AUTOSAR | A14-5-1 | Yes | Required | Automated | Implementation | A template constructor shall not participate in overload resolution for a single argument of the enclosing class type. | M14-5-2 | Templates | Easy | |
63 | cpp | AUTOSAR | A14-5-2 | Yes | Advisory | Partially-Automated | Design | Class members that are not dependent on template class parameters should be defined in a separate base class. | Classes | Easy | ||
64 | cpp | AUTOSAR | A14-5-3 | Yes | Advisory | Automated | Design | A non-member generic operator shall only be declared in a namespace that does not contain class (struct) type, enum type or union type declarations. | Operators | Easy | ||
65 | cpp | AUTOSAR | A14-7-1 | Yes | Required | Automated | Implementation | A type used as a template argument shall provide all members that are used by the template. | M14-7-2 | Templates | Easy | |
66 | cpp | AUTOSAR | A14-7-2 | Yes | Required | Automated | Implementation | Template specialization shall be declared in the same file (1) as the primary template (2) as a user-defined type, for which the specialization is declared. | Templates | Easy | ||
67 | cpp | AUTOSAR | A14-8-2 | Yes | Required | Automated | Implementation | Explicit specializations of function templates shall not be used. | M14-8-1 | Templates | Easy | |
68 | cpp | AUTOSAR | A15-0-1 | Yes | Required | Non-Automated | Architecture / Design / Implementation | A function shall not exit with an exception if it is able to complete its task. | Exceptions1 | Audit | Report a list of functions which throw exceptions. | |
69 | cpp | AUTOSAR | A15-0-2 | Yes | Required | Partially Automated | Architecture / Design / Implementation | At least the basic guarantee for exception safety shall be provided for all operations. In addition, each function may offer either the strong guarantee or the nothrow guarantee | ERR56-CPP | ExceptionSafety | Import | |
70 | cpp | AUTOSAR | A15-0-3 | Yes | Required | Non-Automated | Implementation | Exception safety guarantee of a called function shall be considered. | ExceptionSafety | Hard | There are certain exception safety guarantees we can check, such as exceptions in constructor calls used in emplace (the example from the rule text). | |
71 | cpp | AUTOSAR | A15-0-4 | Yes | Required | Non-Automated | Architecture / Design / Implementation | Unchecked exceptions shall be used to represent errors from which the caller cannot reasonably be expected to recover. | Exceptions1 | Audit | Report a list of unchecked exceptions. | |
72 | cpp | AUTOSAR | A15-0-5 | Yes | Required | Non-Automated | Architecture / Design / Implementation | Checked exceptions shall be used to represent errors from which the caller can reasonably be expected to recover. | Exceptions1 | Audit | Report a list of checked exceptions. | |
73 | cpp | AUTOSAR | A15-0-6 | No | Required | Non-Automated | Verification / Toolchain | An analysis shall be performed to analyze the failure modes of exception | Allocated target not covered by CodeQL | |||
74 | cpp | AUTOSAR | A15-0-7 | No | Required | Partially Automated | Verification / Toolchain | Exception handling mechanism shall guarantee a deterministic worst-case time execution time. | Allocated target not covered by CodeQL | |||
75 | cpp | AUTOSAR | A15-0-8 | No | Required | Non-Automated | Verification / Toolchain | A worst-case execution time (WCET) analysis shall be performed to determine maximum execution time constraints of the software, covering in particular the exceptions processing. | Allocated target not covered by CodeQL | |||
76 | cpp | AUTOSAR | A15-1-1 | Yes | Advisory | Automated | Implementation | Only instances of types derived from std::exception should be thrown. | Exceptions2 | Easy | ||
77 | cpp | AUTOSAR | A15-1-2 | Yes | Required | Automated | Implementation | An exception object shall not be a pointer. | Exceptions1 | Easy | ||
78 | cpp | AUTOSAR | A15-1-3 | Yes | Advisory | Automated | Implementation | All thrown exceptions should be unique. | Exceptions1 | Easy | ||
79 | cpp | AUTOSAR | A15-1-4 | Yes | Required | Partially Automated | Implementation | If a function exits with an exception, then before a throw, the function shall place all objects/resources that the function constructed in valid states or it shall delete them. | ERR57-CPP | ExceptionSafety | Easy | |
80 | cpp | AUTOSAR | A15-1-5 | Yes | Required | Non-Automated | Implementation | Exceptions shall not be thrown across execution boundaries. | ERR59-CPP | TrustBoundaries | Import | The database holds information about which compiler binary was used for each compilation. This can be used to identify execution boundaries between compilation units. |
81 | cpp | AUTOSAR | A15-2-1 | Yes | Required | Automated | Implementation | Constructors that are not noexcept shall not be invoked before program startup. | ERR51-CPP | Exceptions1 | Medium | |
82 | cpp | AUTOSAR | A15-2-2 | Yes | Required | Partially Automated | Implementation | If a constructor is not noexcept and the constructor cannot finish object initialization, then it shall deallocate the object's resources and it shall throw an exception. | ERR57-CPP | Exceptions2 | Easy | |
83 | cpp | AUTOSAR | A15-3-2 | No | Required | Non-Automated | Implementation | If a function throws an exception, it shall be handled when meaningful actions can be taken, otherwise it shall be propagated. | Difficult to identify when meaningful action could be taken. | |||
84 | cpp | AUTOSAR | A15-3-3 | Yes | Required | Partially-Automated | Implementation | Main function and a task main function shall catch at least: base class exceptions from all third-party libraries used, std::exception and all otherwise unhandled exceptions. | M15-3-2 | Exceptions1 | Easy | |
85 | cpp | AUTOSAR | A15-3-4 | Yes | Required | Non-Automated | Implementation | Catch-all (ellipsis and std::exception) handlers shall be used only in (a) main, (b) task main functions, (c) in functions that are supposed to isolate independent components and (d) when calling third-party code that uses exceptions not according to AUTOSAR C++14 guidelines. | Exceptions1 | Medium | Identify catch-all handlers which aren't in main, aren't in functions called by std::thread or similar, and aren't wrapping external function calls. We may require some heuristics to exclude other "isolation" cases. | |
86 | cpp | AUTOSAR | A15-3-5 | Yes | Required | Automated | Implementation | A class type exception shall be caught by reference or const reference. | M15-3-5 | Exceptions2 | Easy | |
87 | cpp | AUTOSAR | A15-4-1 | Yes | Required | Automated | Implementation | Dynamic exception-specification shall not be used. | Exceptions1 | Easy | ||
88 | cpp | AUTOSAR | A15-4-2 | Yes | Required | Automated | Implementation | If a function is declared to be noexcept, noexcept(true) or noexcept(<true condition>), then it shall not exit with an exception. | M15-5-2 | Exceptions1 | Medium | |
89 | cpp | AUTOSAR | A15-4-3 | Yes | Required | Automated | Implementation | The noexcept specification of a function shall either be identical across all translation units, or identical or more restrictive between a virtual member function and an overrider. | Exceptions2 | Easy | ||
90 | cpp | AUTOSAR | A15-4-4 | Yes | Required | Automated | Implementation | A declaration of non-throwing function shall contain noexcept specification. | Exceptions1 | Easy | ||
91 | cpp | AUTOSAR | A15-4-5 | Yes | Required | Automated | Implementation | Checked exceptions that could be thrown from a function shall be specified together with the function declaration and they shall be identical in all function declarations and for all its overriders. | Exceptions2 | Easy | ||
92 | cpp | AUTOSAR | A15-5-1 | Yes | Required | Automated | Implementation | All user-provided class destructors, deallocation functions, move constructors, move assignment operators and swap functions shall not exit with an exception. A noexcept exception specification shall be added to these functions as appropriate. | M15-5-1 | Exceptions2 | Easy | |
93 | cpp | AUTOSAR | A15-5-2 | Yes | Required | Partially Automated | Implementation | Program shall not be abruptly terminated. In particular, an implicit or explicit invocation of std::abort(), std::quick_exit(), std::_Exit(), std::terminate() shall not be done. | ERR50-CPP | Exceptions1 | Easy | |
94 | cpp | AUTOSAR | A15-5-3 | Yes | Required | Automated | Implementation | The std::terminate() function shall not be called implicitly. | A15-5-2 | Exceptions1 | Medium | |
95 | cpp | AUTOSAR | A16-0-1 | Yes | Required | Automated | Implementation | The pre-processor shall only be used for unconditional and conditional file inclusion and include guards, and using the following directives: (1) #ifndef, #ifdef, (3) #if, (4) #if defined, (5) #elif, (6) #else, (7) #define, (8) #endif, (9) #include. | M16-2-1 | Macros | Easy | |
96 | cpp | AUTOSAR | A16-2-1 | Yes | Required | Automated | Implementation | The ',", /*, //, \ characters shall not occur in a header file name or in #include directive. | M16-2-4 | Macros | Easy | |
97 | cpp | AUTOSAR | A16-2-2 | Yes | Required | Automated | Implementation | There shall be no unused include directives. | cpp/dependency/useless-include | Includes | Hard | https://github.com/github/semmle-code/tree/main/packs/dependency/queries/semmlecode-cpp-queries/Dependency |
98 | cpp | AUTOSAR | A16-2-3 | No | Required | Non-Automated | Implementation | An include directive shall be added explicitly for every symbol used in a file. | There is no automated way to identify which headers are intended to be imported for each symbol. For the standard library we could scrape the documentation to determine which symbol is supposed to come from which header but the expected value is low. | |||
99 | cpp | AUTOSAR | A16-6-1 | Yes | Required | Automated | Implementation | #error directive shall not be used. | Macros | Easy | ||
100 | cpp | AUTOSAR | A16-7-1 | Yes | Required | Automated | Implementation | The #pragma directive shall not be used. | Macros | Easy | ||
101 | cpp | AUTOSAR | A17-0-1 | Yes | Required | Automated | Implementation | Reserved identifiers, macros and functions in the C++ standard library shall not be defined, redefined or undefined. | M17-0-1 | BannedLibraries | Medium | |
102 | cpp | AUTOSAR | A17-0-2 | No | Required | Non-Automated | Implementation | All project's code including used libraries (including standard and user-defined libraries) and any third-party user code shall conform to the AUTOSAR C++14 Coding Guidelines. | Self-referential. This is, in practice, covered by the rest of the queries, so I don't think we would have a specific query for this. | |||
103 | cpp | AUTOSAR | A17-1-1 | Yes | Required | Non-Automated | Implementation | Use of the C Standard Library shall be encapsulated and isolated. | Functions | Medium | Enforce that functions which call cstd functions are only calling cstd functions. | |
104 | cpp | AUTOSAR | A17-6-1 | Yes | Required | Automated | Implementation | Non-standard entities shall not be added to standard namespaces. | DCL58-CPP | Scope | Import | |
105 | cpp | AUTOSAR | A18-0-1 | Yes | Required | Automated | Implementation | The C library facilities shall only be accessed through C++ library headers. | M18-0-1 | BannedLibraries | Easy | |
106 | cpp | AUTOSAR | A18-0-2 | Yes | Required | Automated | Implementation | The error state of a conversion from string to a numeric value shall be checked. | M18-0-2 | TypeRanges | Medium | |
107 | cpp | AUTOSAR | A18-0-3 | Yes | Required | Automated | Implementation | The library <clocale> (locale.h) and the setlocale function shall not be used. | BannedLibraries | Easy | ||
108 | cpp | AUTOSAR | A18-1-1 | Yes | Required | Automated | Implementation | C-style arrays shall not be used. | BannedSyntax | Easy | ||
109 | cpp | AUTOSAR | A18-1-2 | Yes | Required | Automated | Implementation | The std::vector<bool> specialization shall not be used. | BannedTypes | Easy | ||
110 | cpp | AUTOSAR | A18-1-3 | Yes | Required | Automated | Implementation | The std::auto_ptr type shall not be used. | BannedTypes | Easy | ||
111 | cpp | AUTOSAR | A18-1-4 | Yes | Required | Automated | Implementation | A pointer pointing to an element of an array of objects shall not be passed to a smart pointer of single object type. | Pointers | Medium | ||
112 | cpp | AUTOSAR | A18-1-6 | Yes | Required | Automated | Implementation | All std::hash specializations for user-defined types shall have a noexcept function call operator. | OperatorInvariants | Easy | ||
113 | cpp | AUTOSAR | A18-5-1 | Yes | Required | Automated | Implementation | Functions malloc, calloc, realloc and free shall not be used. | BannedFunctions | Easy | ||
114 | cpp | AUTOSAR | A18-5-10 | Yes | Required | Automated | Implementation | Placement new shall be used only with properly aligned pointers to sufficient storage capacity. | MEM54-CPP | Allocations | Import | |
115 | cpp | AUTOSAR | A18-5-11 | Yes | Required | Automated | Implementation | operator new' and 'operator delete' shall be defined together. | DCL54-CPP | Declarations | Easy | |
116 | cpp | AUTOSAR | A18-5-2 | Yes | Required | Partially Automated | Implementation | Non-placement new or delete expressions shall not be used. | Allocations | Hard | ||
117 | cpp | AUTOSAR | A18-5-3 | Yes | Required | Automated | Implementation | The form of the delete expression shall match the form of the new expression used to allocate the memory. | cpp/new-free-mismatch? | Freed | Very Hard | |
118 | cpp | AUTOSAR | A18-5-4 | Yes | Required | Automated | Implementation | If a project has sized or unsized version of operator 'delete' globally defined, then both sized and unsized versions shall be defined. | Declarations | Easy | ||
119 | cpp | AUTOSAR | A18-5-5 | Yes | Required | Partially Automated | Toolchain | Memory management functions shall ensure the following: (a) deterministic behavior resulting with the existence of worst-case execution time, (b) avoiding memory fragmentation, (c) avoid running out of memory, (d) 349 of 510 Document ID 839: AUTOSAR_RS_CPP14Guidelines | Invariants | Hard | ||
120 | cpp | AUTOSAR | A18-5-6 | Yes | Required | Non-Automated | Verification / Toolchain | An analysis shall be performed to analyze the failure modes of dynamic memory management. In particular, the following failure modes shall be analyzed: (a) non-deterministic behavior resulting with nonexistence of worst-case execution time, (b) memory fragmentation, (c) running out of memory, (d) mismatched allocations and deallocations, (e) dependence on non-deterministic calls to kernel. | Allocations | Audit | Produce a list of allocations in the program. | |
121 | cpp | AUTOSAR | A18-5-7 | No | Required | Non-Automated | Implementation | If non-realtime implementation of dynamic memory management functions is used in the project, then memory shall only be allocated and deallocated during non-realtime program phases. | No specific ideas for implementing this. | |||
122 | cpp | AUTOSAR | A18-5-8 | Yes | Required | Partially Automated | Implementation | Objects that do not outlive a function shall have automatic storage duration. | Allocations | Medium | ||
123 | cpp | AUTOSAR | A18-5-9 | Yes | Required | Automated | Implementation | Custom implementations of dynamic memory allocation and deallocation functions shall meet the semantic requirements specified in the corresponding 'Required behaviour' clause from the C++ Standard. | MEM55-CPP | Allocations | Import | |
124 | cpp | AUTOSAR | A18-9-1 | Yes | Required | Automated | Implementation | The std::bind shall not be used. | BannedFunctions | Easy | ||
125 | cpp | AUTOSAR | A18-9-2 | Yes | Required | Automated | Implementation | Forwarding values to other functions shall be done via: (1) std::move if the value is an rvalue reference, (2) std::forward if the value is forwarding reference. | MoveForward | Medium | ||
126 | cpp | AUTOSAR | A18-9-3 | Yes | Required | Automated | Implementation | The std::move shall not be used on objects declared const or const&. | MoveForward | Easy | ||
127 | cpp | AUTOSAR | A18-9-4 | Yes | Required | Automated | Implementation | An argument to std::forward shall not be subsequently used. | MoveForward | Medium | ||
128 | cpp | AUTOSAR | A2-10-1 | Yes | Required | Automated | Architecture / Design / Implementation | An identifier declared in an inner scope shall not hide an identifier declared in an outer scope. | M2-10-2 | Naming | Easy | |
129 | cpp | AUTOSAR | A2-10-4 | Yes | Required | Automated | Implementation | The identifier name of a non-member object with static storage duration or static function shall not be reused within a namespace. | M2-10-5 | Naming | Easy | |
130 | cpp | AUTOSAR | A2-10-5 | Yes | Advisory | Automated | Design / Implementation | An identifier name of a function with static storage duration or a non-member object with external or internal linkage should not be reused. | M2-10-5 | Naming | Easy | |
131 | cpp | AUTOSAR | A2-10-6 | Yes | Required | Automated | Implementation | A class or enumeration name shall not be hidden by a variable, function or enumerator declaration in the same scope. | M2-10-6 | Naming | Easy | |
132 | cpp | AUTOSAR | A2-11-1 | Yes | Required | Automated | Design / Implementation | Volatile keyword shall not be used. | cpp/jsf/av-rule-205 | BannedSyntax | Easy | |
133 | cpp | AUTOSAR | A2-13-1 | Yes | Required | Automated | Architecture / Design / Implementation | Only those escape sequences that are defined in ISO/IEC 14882:2014 shall be used. | M2-13-1 | Literals | Easy | |
134 | cpp | AUTOSAR | A2-13-2 | No | Required | Automated | Implementation | String literals with different encoding prefixes shall not be concatenated. | M2-13-5 | From the sample, it looks like this is compiler enforced. | ||
135 | cpp | AUTOSAR | A2-13-3 | Yes | Required | Automated | Architecture / Design / Implementation | Type wchar_t shall not be used. | BannedTypes | Easy | ||
136 | cpp | AUTOSAR | A2-13-4 | Yes | Required | Automated | Architecture / Design / Implementation | String literals shall not be assigned to non-constant pointers. | Strings | Easy | ||
137 | cpp | AUTOSAR | A2-13-5 | Yes | Advisory | Automated | Implementation | Hexadecimal constants should be upper case. | Literals | Easy | ||
138 | cpp | AUTOSAR | A2-13-6 | Yes | Required | Automated | Architecture / Design / Implementation | Universal character names shall be used only inside character or string literals. | Naming | Easy | ||
139 | cpp | AUTOSAR | A2-3-1 | Yes | Required | Automated | Architecture / Design / Implementation | Only those characters specified in the C++ Language Standard basic source character set shall be used in the source code. | Naming | Easy | We can only provide partial coverage for this rule, because we have a semantic not syntactic model of the code. | |
140 | cpp | AUTOSAR | A2-5-1 | No | Required | Automated | Implementation | Trigraphs shall not be used. | Trigraphs/digraphs are implemented by the preprocessor in a such a way that we may not have that information in our database. We could look for compiler flags here. | |||
141 | cpp | AUTOSAR | A2-5-2 | No | Required | Automated | Implementation | Digraphs shall not be used. | Trigraphs/digraphs are implemented by the preprocessor in a such a way that we may not have that information in our database. We could look for compiler flags here. | |||
142 | cpp | AUTOSAR | A2-7-1 | Yes | Required | Automated | Implementation | The character \ shall not occur as a last character of a C++ comment. | Comments | Easy | ||
143 | cpp | AUTOSAR | A2-7-2 | Yes | Required | Non-Automated | Implementation | Sections of code shall not be 'commented out'. | M2-7-2 | Comments | Easy | We can write a heuristic query that looks for code markers in comments. |
144 | cpp | AUTOSAR | A2-7-3 | Yes | Required | Automated | Implementation | All declarations of 'user-defined' types, static and non-static data members, functions and methods shall be preceded by documentation. | Comments | Easy | ||
145 | cpp | AUTOSAR | A2-7-5 | No | Required | Non-Automated | Implementation | Comments shall not document any actions or sources (e.g. tables, figures, paragraphs, etc.) that are outside of the file. | Difficult to ascertain programmatically | |||
146 | cpp | AUTOSAR | A2-8-1 | No | Required | Non-Automated | Architecture / Design / Implementation | A header file name should reflect the logical entity for which it provides declarations. | Difficult to ascertain programmatically | |||
147 | cpp | AUTOSAR | A2-8-2 | No | Advisory | Non-Automated | Architecture / Design / Implementation | An implementation file name should reflect the logical entity for which it provides definitions. | Difficult to ascertain programmatically | |||
148 | cpp | AUTOSAR | A20-8-1 | Yes | Required | Automated | Implementation | An already-owned pointer value shall not be stored in an unrelated smart pointer. | MEM56-CPP | SmartPointers1 | Import | |
149 | cpp | AUTOSAR | A20-8-2 | Yes | Required | Automated | Implementation | A std::unique_ptr shall be used to represent exclusive ownership. | SmartPointers1 | Hard | ||
150 | cpp | AUTOSAR | A20-8-3 | Yes | Required | Automated | Implementation | A std::shared_ptr shall be used to represent shared ownership. | SmartPointers1 | Hard | ||
151 | cpp | AUTOSAR | A20-8-4 | Yes | Required | Automated | Implementation | A std::unique_ptr shall be used over std::shared_ptr if ownership sharing is not required. | SmartPointers1 | Hard | ||
152 | cpp | AUTOSAR | A20-8-5 | Yes | Required | Automated | Implementation | std::make_unique shall be used to construct objects owned by std::unique_ptr. | SmartPointers1 | Easy | ||
153 | cpp | AUTOSAR | A20-8-6 | Yes | Required | Automated | Implementation | std::make_shared shall be used to construct objects owned by std::shared_ptr. | SmartPointers1 | Easy | ||
154 | cpp | AUTOSAR | A20-8-7 | Yes | Required | Non-Automated | Implementation | A std::weak_ptr shall be used to represent temporary shared ownership. | SmartPointers2 | Hard | We can find some specific cases here: mutual assignment of two variables, for example. | |
155 | cpp | AUTOSAR | A21-8-1 | Yes | Required | Automated | Implementation | Arguments to character-handling functions shall be representable as an unsigned char. | STR37-C | TypeRanges | Hard | |
156 | cpp | AUTOSAR | A23-0-1 | Yes | Required | Automated | Implementation | An iterator shall not be implicitly converted to const_iterator. | Iterators | Easy | ||
157 | cpp | AUTOSAR | A23-0-2 | Yes | Required | Automated | Implementation | Elements of a container shall only be accessed via valid references, iterators, and pointers. | CTR51-CPP | Iterators | Import | |
158 | cpp | AUTOSAR | A25-1-1 | Yes | Required | Automated | Implementation | Non-static data members or captured values of predicate function objects that are state related to this object's identity shall not be copied. | CTR58-CPP | SideEffects2 | Import | |
159 | cpp | AUTOSAR | A25-4-1 | Yes | Required | Non-Automated | Implementation | Ordering predicates used with associative containers and STL sorting and related algorithms shall adhere to a strict weak ordering relation. | CTR57-CPP | Invariants | Import | Hard to determine in general. Easiest is likely the irreflexivity clause (specifically using std::less_equal and similar library functions) |
160 | cpp | AUTOSAR | A26-5-1 | Yes | Required | Automated | Implementation | Pseudorandom numbers shall not be generated using std::rand(). | MSC50-CPP | BannedFunctions | Import | |
161 | cpp | AUTOSAR | A26-5-2 | Yes | Required | Automated | Implementation | Random number engines shall not be default-initialized. | MSC51-CPP | Initialization | Easy | |
162 | cpp | AUTOSAR | A27-0-1 | Yes | Required | Non-Automated | Implementation | Inputs from independent components shall be validated. | TypeRanges | Medium | We can perform some checking here assuming: we have annotations which determine the boundaries between components, and the appropriate checks that should be performed. | |
163 | cpp | AUTOSAR | A27-0-2 | Yes | Advisory | Automated | Implementation | A C-style string shall guarantee sufficient space for data and the null terminator. | STR50-CPP | Strings | Import | |
164 | cpp | AUTOSAR | A27-0-3 | Yes | Required | Automated | Implementation | Alternate input and output operations on a file stream shall not be used without an intervening flush or positioning call. | FIO50-CPP | IO | Import | |
165 | cpp | AUTOSAR | A27-0-4 | Yes | Required | Automated | Implementation | C-style strings shall not be used. | Strings | Hard | ||
166 | cpp | AUTOSAR | A3-1-1 | Yes | Required | Automated | Architecture / Design / Implementation | It shall be possible to include any header file in multiple translation units without violating the One Definition Rule. | M3-1-1 | Includes | Easy | |
167 | cpp | AUTOSAR | A3-1-2 | Yes | Required | Automated | Architecture / Design / Implementation | Header files, that are defined locally in the project, shall have a file name extension of one of: ".h",".hpp" or ".hxx". | cpp/jsf/av-rule-53 | Includes | Easy | |
168 | cpp | AUTOSAR | A3-1-3 | Yes | Advisory | Automated | Architecture / Design / Implementation | Implementation files, that are defined locally in the project, should have a file name extension of ".cpp". | Includes | Easy | ||
169 | cpp | AUTOSAR | A3-1-4 | Yes | Required | Automated | Design / Implementation | When an array with external linkage is declared, its size shall be stated explicitly. | M3-1-3 | Scope | Easy | |
170 | cpp | AUTOSAR | A3-1-5 | Yes | Required | Partially-Automated | Design | A function definition shall only be placed in a class definition if (1) the function is intended to be inlined (2) it is a member function template (3) it is a member function of a class template. | Classes | Medium | ||
171 | cpp | AUTOSAR | A3-1-6 | Yes | Advisory | Automated | Design | Trivial accessor and mutator functions should be inlined. | Functions | Easy | ||
172 | cpp | AUTOSAR | A3-3-1 | Yes | Required | Automated | Implementation | Objects or functions with external linkage (including members of named namespaces) shall be declared in a header file. | M3-3-1 | Includes | Easy | |
173 | cpp | AUTOSAR | A3-3-2 | Yes | Required | Automated | Implementation | Static and thread-local objects shall be constant-initialized. | DCL56-CPP | Initialization | Medium | |
174 | cpp | AUTOSAR | A3-8-1 | Yes | Required | Non-Automated | Implementation | An object shall not be accessed outside of its lifetime. | EXP54-CPP | Freed | Import | A replica of a CERT-CPP rule, there are numerous specific cases we can cover. |
175 | cpp | AUTOSAR | A3-9-1 | Yes | Required | Automated | Implementation | Fixed width integer types from <cstdint>, indicating the size and signedness, shall be used in place of the basic numerical types. | M3-9-2 | Declarations | Easy | |
176 | cpp | AUTOSAR | A4-10-1 | Yes | Required | Automated | Architecture / Design / Implementation | Only nullptr literal shall be used as the null-pointer-constant. | Literals | Easy | ||
177 | cpp | AUTOSAR | A4-5-1 | Yes | Required | Automated | Implementation | Expressions with type enum or enum class shall not be used as operands to built-in and overloaded operators other than the subscript operator [ ], the assignment operator =, the equality operators == and ! =, the unary & operator, and the relational operators <, <=, >, >=. | M4-5-2 | Expressions | Easy | |
178 | cpp | AUTOSAR | A4-7-1 | Yes | Required | Automated | Implementation | An integer expression shall not lead to data loss. | M5-0-6 | IntegerConversion | Very Hard | |
179 | cpp | AUTOSAR | A5-0-1 | Yes | Required | Automated | Implementation | The value of an expression shall be the same under any order of evaluation that the standard permits. | M5-0-1 | OrderOfEvaluation | Hard | |
180 | cpp | AUTOSAR | A5-0-2 | Yes | Required | Automated | Implementation | The condition of an if-statement and the condition of an iteration statement shall have type bool. | M5-0-13 | Conditionals | Easy | |
181 | cpp | AUTOSAR | A5-0-3 | Yes | Required | Automated | Implementation | The declaration of objects shall contain no more than two levels of pointer indirection. | M5-0-19 | Pointers | Easy | |
182 | cpp | AUTOSAR | A5-0-4 | Yes | Required | Automated | Implementation | Pointer arithmetic shall not be used with pointers to non-final classes. | CTR56-CPP | Pointers | Easy | |
183 | cpp | AUTOSAR | A5-1-1 | Yes | Required | Partially Automated | Implementation | Literal values shall not be used apart from type initialization, otherwise symbolic names shall be used instead. | Literals | Easy | ||
184 | cpp | AUTOSAR | A5-1-2 | Yes | Required | Automated | Implementation | Variables shall not be implicitly captured in a lambda expression. | Lambdas | Easy | ||
185 | cpp | AUTOSAR | A5-1-3 | Yes | Required | Automated | Implementation | Parameter list (possibly empty) shall be included in every lambda expression. | Lambdas | Easy | ||
186 | cpp | AUTOSAR | A5-1-4 | Yes | Required | Automated | Implementation | A lambda expression object shall not outlive any of its reference-captured objects. | EXP61-CPP | Lambdas | Import | |
187 | cpp | AUTOSAR | A5-1-6 | Yes | Advisory | Automated | Implementation | Return type of a non-void return type lambda expression should be explicitly specified. | Lambdas | Easy | ||
188 | cpp | AUTOSAR | A5-1-7 | Yes | Required | Automated | Implementation | A lambda shall not be an operand to decltype or typeid. | Lambdas | Easy | ||
189 | cpp | AUTOSAR | A5-1-8 | Yes | Advisory | Automated | Implementation | Lambda expressions should not be defined inside another lambda expression. | Lambdas | Easy | ||
190 | cpp | AUTOSAR | A5-1-9 | Yes | Advisory | Automated | Implementation | Identical unnamed lambda expressions shall be replaced with a named function or a named lambda expression. | Lambdas | Very Hard | ||
191 | cpp | AUTOSAR | A5-10-1 | Yes | Required | Automated | Implementation | A pointer to member virtual function shall only be tested for equality with null-pointer-constant. | Pointers | Medium | ||
192 | cpp | AUTOSAR | A5-16-1 | Yes | Required | Automated | Implementation | The ternary conditional operator shall not be used as a sub-expression. | BannedSyntax | Easy | ||
193 | cpp | AUTOSAR | A5-2-1 | Yes | Advisory | Automated | Implementation | dynamic_cast should not be used. | BannedSyntax | Easy | ||
194 | cpp | AUTOSAR | A5-2-2 | Yes | Required | Automated | Implementation | Traditional C-style casts shall not be used. | BannedSyntax | Easy | ||
195 | cpp | AUTOSAR | A5-2-3 | Yes | Required | Automated | Implementation | A cast shall not remove any const or volatile qualification from the type of a pointer or reference. | EXP55-CPP | Const | Import | |
196 | cpp | AUTOSAR | A5-2-4 | Yes | Required | Automated | Implementation | reinterpret_cast shall not be used. | M5-2-7 | BannedSyntax | Easy | |
197 | cpp | AUTOSAR | A5-2-5 | Yes | Required | Automated | Implementation | An array or container shall not be accessed beyond its range. | CTR50-CPP | OutOfBounds | Import | |
198 | cpp | AUTOSAR | A5-2-6 | Yes | Required | Automated | Implementation | The operands of a logical && or || shall be parenthesized if the operands contain binary operators. | M5-2-1 | OrderOfEvaluation | Easy | |
199 | cpp | AUTOSAR | A5-3-1 | Yes | Required | Non-Automated | Implementation | Evaluation of the operand to the typeid operator shall not contain side effects. | SideEffects1 | Easy | We will make use of a shared "side-effects" library for this query. | |
200 | cpp | AUTOSAR | A5-3-2 | Yes | Required | Partially Automated | Implementation | Null pointers shall not be dereferenced. | Null | Very Hard | ||
201 | cpp | AUTOSAR | A5-3-3 | Yes | Required | Automated | Implementation | Pointers to incomplete class types shall not be deleted. | EXP57-CPP | Pointers | Easy | |
202 | cpp | AUTOSAR | A5-5-1 | Yes | Required | Automated | Implementation | A pointer to member shall not access non-existent class members. | OOP55-CPP | Pointers | Import |