6.2.12. Stylechecks

Checks regarding coding style, including Misra and other checks

Nested Rules

AutosarC++

Checks for Autosar guidelines for the use of the C++14 language in critical and safety-related systems

C#

Checks for C# coding style

CQM

Code-Quality-Management Stylechecks

CUDA

Checks for CUDA C++ programming language and CUDA libraries usage

CWE

Checks for issues listed in the CWE - Common Weakness Enumeration

Cert

SEI CERT Coding Standard Security Checks

CodingStyle

Checks for coding style issues

CompilerErrata

Checks whether your code is affected by known errata in native compilers

FaultDetection

Static checks for possible runtime errors

GeneralPurpose

GeneralPurpose/Best practice checks

Miscellaneous

Miscellaneous checks that are often parts of other rule sets

Misra

Checks for Misra guidelines for the use of C/C++ in critical systems

Qt

Rulegroups for programs using Qt

Rust

Checks for Rust coding style

SecureCoding

ISO-TS-17961 C Secure Coding

6.2.12.16. Options

mixed_headers_are_c

mixed_headers_are_c : bool = False

Whether header files being included from both C and C++ units should only be seen as C files (thus not checked with C++ rules).
 

node_sort_key

node_sort_key : typing.Callable[[bauhaus.ir.Node], bauhaus.axitertools.Comparable] | None = None

Callback function used to sort IR nodes, typically by their source location.

Most rules that report a list of "Secondary SLocs" will use this option to determine the sort order in which the secondary SLocs will be displayed in the dashboard. For some rules (e.g. MisraC2012Directive-4.5 "ambiguous identifier"), the first SLoc after sorting will be used as the primary source location. For these rules, this option can be used to influence the choice of primary source location.

The configured callback function will be called with a physical IR node, and should return a Python object that is comparable with the return value of other invocations of the callback: the configured callback will be used as key argument to the Python sort() builtin.

If the callback returns equal return values for different nodes, only one source location for each equivalency class will be displayed. Thus, typically the return value should be a tuple including node.SLoc to avoid inadvertent deduplication.

The default callback if this option is not configured will sort the source locations lexicographically.

Example rule_config.py:

import axivion.config
analysis = axivion.config.get_analysis()

def my_sort_key(node):
    # Prefer definitions over declarations
    if node.is_of_type('Definition'):
        order = 0
    else:
        order = 1
    # Return a tuple.
    # For equal order, this continues to compare by source location as usual.
    return order, node.SLoc

analysis['Stylechecks'].node_sort_key = my_sort_key