6.2.1. Global Options¶
These options affect all rules in this aspect.
6.2.1.1. global_excludes¶
global_excludes : set[bauhaus.analysis.config.FileGlobPattern] = set()
If this set is non-empty, no violations matching any of the glob patterns will be reported.
If both includes and excludes are used, the analysis will run on all files that match at least one include pattern, and do not match any exclude patterns.
The globbing patterns are applied to the project-directory relative paths.
Examples:
*/generated/* excludes violations in all files anywhere inside a
directory called generated (except for project toplevel).
generated/* excludes violations in all files beneath toplevel
directory generated (but not other generated folders
nested more deeply).
/usr/include/mylib/* excludes violations in headers of the third-party
library at /usr/include/mylib.
Note:
The axivion_analysis --exclude command-line option
has the effect of adding to this set.
6.2.1.2. global_includes¶
global_includes : set[bauhaus.analysis.config.FileGlobPattern] = set()
If this set is non-empty, only violations matching one of the glob patterns will be reported.
If both includes and excludes are used, the analysis will run on all files that match at least one include pattern, and do not match any exclude patterns.
The globbing patterns are applied to the project-directory relative paths.
Examples:
*/checkme/* reports violations in all files anywhere inside a
directory called checkme (except for project toplevel).
checkme/* reports violations in all files beneath toplevel
directory checkme (but not other checkme folders nested
more deeply).
subproject/part/* reports violations in files in the
project subtree subproject/part.
Note:
The axivion_analysis --include command-line option
has the effect of adding to this set.
6.2.1.3. global_post_processing¶
global_post_processing : bauhaus.analysis.post_processing.PostProcessingSettings = <PostProcessingSettings(0 filters)>
6.2.1.4. log_violations¶
log_violations : bool = False
6.2.1.5. message_format¶
Options regarding the formatting of messages for console output
message_format.architecture
Options for architecture message formatting.
message_format.architecture.absence_string : str =
String to show for an absence (defines the value to be used when replacing the 'violation_message' placeholder in the primary line).'Missing dependency'
message_format.architecture.after_justification : str =
Value for the 'after_justification' placeholder in the primary/secondary line.'] '
message_format.architecture.before_justification : str =
Value for the 'before_justification' placeholder in the primary/secondary line.'['
message_format.architecture.convergence_string : str =
String to show for a convergence (defines the value to be used when replacing the 'violation_message' placeholder in the primary line).'Expected dependency'
message_format.architecture.disabled_string : str =
String to show when an issue is disabled (defines the value to be used when replacing the 'disabled' placeholder in the primary/secondary line).'DISABLED: '
message_format.architecture.divergence_string : str =
String to show for a divergence (defines the value to be used when replacing the 'violation_message' placeholder in the primary line).'Forbidden dependency'
message_format.architecture.message_string : str =
String to show as message (defines the value to be used when replacing the 'message' placeholder in the primary line).'Architecture violation'
message_format.architecture.primary_line : str =
Format of the primary line in console outputs. Available placeholders are:'%(disabled)s%(filename)s:%(line)d:%(column)d: %(message)s: %(violation_message)s [%(target_entity)s] (Rule %(errno)s)'
- filename, line, column: Position information of the source of the architecture violation
- target_filename, target_line, target_column: Position information of the target of the architecture violation
- message: Custom text describing the issue
- violation_message: Custom text being selected based on whether it is a divergence, absence or convergence
- edge_type, violation_type: Classification of the violation; edge_type is the RFG edge type in the source, like Static_Call, while violation_type is one of Absence/Divergence/Convergence
- errno: Rulename of the rule reporting the issue
- disabled, justification: Non-empty when the issue is disabled / has a justification
- before_justification, after_justification: Strings to be printed before/after the justification, if any, as configured with corresponding options
message_format.clone
Options for clone message formatting.
message_format.clone.after_justification : str =
Value for the 'after_justification' placeholder in the primary/secondary line.'] '
message_format.clone.before_justification : str =
Value for the 'before_justification' placeholder in the primary/secondary line.'['
message_format.clone.disabled_string : str =
String to show when an issue is disabled (defines the value to be used when replacing the 'disabled' placeholder in the primary/secondary line).'DISABLED: '
message_format.clone.message_string : str =
String to show as message (defines the value to be used when replacing the 'message' placeholder in the primary line).'Cloned code section'
message_format.clone.primary_line
Format of the primary line in console outputs. Available placeholders are:Type: str
Default:
'%(disabled)s%(filename)s:%(line)d:%(column)d: %(message)s (%(clone_type)s) having length %(length)s; other code section at %(other_filename)s:%(other_line)d'
- filename, line, column: Position information
- other_filename, other_line, other_column: Position information of the second part in the clone pair
- message: Custom text describing the issue
- clone_type, length: Classification and number of lines of the clone
- disabled, justification: Non-empty when the issue is disabled / has a justification
- before_justification, after_justification: Strings to be printed before/after the justification, if any, as configured with corresponding options
message_format.cycle
Options for cycle message formatting.
message_format.cycle.after_justification : str =
Value for the 'after_justification' placeholder in the primary/secondary line.'] '
message_format.cycle.before_justification : str =
Value for the 'before_justification' placeholder in the primary/secondary line.'['
message_format.cycle.disabled_string : str =
String to show when an issue is disabled (defines the value to be used when replacing the 'disabled' placeholder in the primary/secondary line).'DISABLED: '
message_format.cycle.message_string : str =
String to show as message (defines the value to be used when replacing the 'message' placeholder in the primary line).'Recursive call'
message_format.cycle.primary_line : str =
Format of the primary line in console outputs. Available placeholders are:'%(disabled)s%(filename)s:%(line)d:%(column)d: %(message)s [%(entity)s]'
- filename, line, column: Position information
- message: Custom text describing the issue
- entity, entity_type: Name and type of the entity being reported (e.g., a function)
- disabled, justification: Non-empty when the issue is disabled / has a justification
- before_justification, after_justification: Strings to be printed before/after the justification, if any, as configured with corresponding options
message_format.deadcode
Options for deadcode message formatting.
message_format.deadcode.after_justification : str =
Value for the 'after_justification' placeholder in the primary/secondary line.'] '
message_format.deadcode.before_justification : str =
Value for the 'before_justification' placeholder in the primary/secondary line.'['
message_format.deadcode.disabled_string : str =
String to show when an issue is disabled (defines the value to be used when replacing the 'disabled' placeholder in the primary/secondary line).'DISABLED: '
message_format.deadcode.message_string : str =
String to show as message (defines the value to be used when replacing the 'message' placeholder in the primary line).'Dead code detected'
message_format.deadcode.primary_line : str =
Format of the primary line in console outputs. Available placeholders are:'%(disabled)s%(filename)s:%(line)d:%(column)d: %(message)s [%(entity)s]'
- filename, line, column: Position information
- message: Custom text describing the issue
- entity, entity_type: Name and type of the entity being reported (e.g., a function)
- disabled, justification: Non-empty when the issue is disabled / has a justification
- before_justification, after_justification: Strings to be printed before/after the justification, if any, as configured with corresponding options
message_format.metric
Options for metric message formatting.
message_format.metric.after_justification : str =
Value for the 'after_justification' placeholder in the primary/secondary line.'] '
message_format.metric.before_justification : str =
Value for the 'before_justification' placeholder in the primary/secondary line.'['
message_format.metric.disabled_string : str =
String to show when an issue is disabled (defines the value to be used when replacing the 'disabled' placeholder in the primary/secondary line).'DISABLED: '
message_format.metric.primary_line
Format of the primary line in console outputs. Available placeholders are:Type: str
Default:
'%(disabled)s%(filename)s:%(line)d:%(column)d: %(metric_name)s, %(display_name)s: %(metric_value)f; %(min_value)f; %(max_value)f%(violation)s: %(entity_type)s: %(entity)s'
- filename, line, column: Position information
- severity: The issue's severity
- metric_name, display_name: Text describing the metric being reported
- entity, entity_type: Name and type of the entity for which the metric was computed (e.g., a function)
- disabled, justification: Non-empty when the issue is disabled / has a justification
- before_justification, after_justification: Strings to be printed before/after the justification, if any, as configured with corresponding options
- metric_value, violation: Value of the metric and custom string if the metric thresholds are violated
- min_value, max_value: Metric thresholds
message_format.metric.show_all_values : bool =
Whether all metric values or only violations of the thresholds should be shown.False
message_format.metric.violation_string : str =
String to show when an issue is a violation of metric thresholds (defines the value to be used when replacing the 'violation' placeholder in the primary line).' VIOLATION'
message_format.style
Options for stylecheck message formatting.
message_format.style.additional_header_prefix : str =
Separator before intermediate header (e.g. "Additional SLocs:" or "Context:"). Only used in non-brief mode.'n '
message_format.style.after_justification : str =
Value for the 'after_justification' placeholder in the primary/secondary line.'] '
message_format.style.before_justification : str =
Value for the 'before_justification' placeholder in the primary/secondary line.'['
message_format.style.brief_secondary_line_prefix : str =
Separator before secondary sloc in brief mode.', '
message_format.style.disabled_string : str =
String to show when an issue is disabled (defines the value to be used when replacing the 'disabled' placeholder in the primary/secondary line).'DISABLED: '
message_format.style.macro_context_at_definition : str =
Macro context to be shown if the issue is reported at the macro definition (defines the value to be used when replacing the 'macro_context' placeholder in the primary/secondary line).' (when expanded at %(expansion_filename)s:%(expansion_line)d:%(expansion_column)d)'
message_format.style.macro_context_at_invocation : str =
Macro context to be shown if the issue is reported at the macro invocation (defines the value to be used when replacing the 'macro_context' placeholder in the primary/secondary line).' (%(macro_expansion)s)'
message_format.style.previous_position_line : str =
Format of the console output line giving the previous position, if any, when migrating from old to new Axivion Suite versions. Used for tests.'Previous position: %(filename)s:%(line)d:%(column)d: %(message)s'
message_format.style.primary_line
Format of the primary line in console outputs. Available placeholders are:Type: str
Default:
'%(disabled)s%(filename)s:%(line)d:%(column)d: %(severity)s:%(macro_context)s%(template_instantiation_context)s %(message)s (Rule %(errno)s)'
- filename, line, column: Position information
- severity: The issue's severity
- message: The message describing the issue
- disabled, justification: Non-empty when the issue is disabled / has a justification
- before_justification, after_justification: Strings to be printed before/after the justification, if any, as configured with corresponding options
- errno: Rulename of the rule reporting the issue
- macro_context, template_instantiation_context: Non-empty if there is a relevant macro or template context
message_format.style.secondary_line : str =
Format of any secondary line in console output. A secondary line has its own position and message information.'%(filename)s:%(line)d:%(column)d: %(message)s'
message_format.style.secondary_line_prefix : str =
Separator before secondary sloc in normal mode.'n '
message_format.style.show_macro_context : bool =
Whether the macro_context placeholder is supported and replaced by either macro_context_at_invocation or macro_context_at_definition.False
message_format.style.show_previous_position : bool =
Whether a line with the previous position should be printed. Used for tests.False
message_format.style.template_instantiation_context : str =
Value for the 'template_instantiation_context' placeholder in the primary/secondary line.' (%(template_instantiations)s)'
6.2.1.6. scanner¶
Several options related to low-level scanning of source files during analyses.
scanner.additional_basic_characters : str =
Additional characters that should be treated as basic characters. Characters with special meaning within a regex character group''[...]should be escaped with\.
scanner.additional_basic_characters_in_comments : str =
Additional characters that should be treated as basic characters inside comments. Characters with special meaning within a regex character group''[...]should be escaped with\. Rules concerned with comments take "additional_basic_characters" into account as well, so these characters do not have to be repeated here.
scanner.ignore_tokens_in_disabled_sections : bool =
Whether tokens in #if 0 sections should be ignored.True
6.2.1.7. side_effects¶
Several options related to side-effects of functions and volatile variables.
side_effects.effect_free_atomic_variables : set[str] =
Names of variables that can be read without side-effect despite being atomic. If this list contains a macro name, any atomic reads within the macro expansion are treated as free of side effects; as well as any atomic variables declared within the macro expansion. This can be used for memory-mapped IO when the hardware guarantees that reads have no side effect. Write accesses continue to be seen as side-effect.set()
side_effects.effect_free_functions : set[bauhaus.analysis.config.QualifiedName] =
Names of functions that should be assumed to have no side effects. This causes the analysis to ignore the body of the function. For C++, use qualified names without template arguments, e.g.set()std::numeric_limits::max.If you have a function that has a side effect that you wish to ignore for the purposes of the analysis (e.g. logging), consider using the option side_effects.local_effect_functions.
Adding a function to this configuration option is equivalent to marking it as
[[axivion::pure]]. See rule Miscellaneous-InvalidEffectAttributes for a more detailed description of effect attributes.
side_effects.effect_free_volatile_variables : set[str] =
Names of variables that can be read without side-effect despite being volatile. If this list contains a macro name, any volatile reads within the macro expansion are treated as free of side effects; as well as any volatile variables declared within the macro expansion. This can be used for memory-mapped IO when the hardware guarantees that reads have no side effect. Write accesses continue to be seen as side-effect.set()
side_effects.local_effect_functions : set[bauhaus.analysis.config.QualifiedName] =
Names of functions for which side effects should not be propagated up the call graph. For C++, use qualified names without template arguments, e.g.set()std::__assert_fail.Calls to these functions can be seen as having an effect within the caller function (thus there is no "Statement has no side effect" violation when calling these functions); but the effect will not be propagated further up the call stack into the caller's caller. The effect remains "local" to the function's direct callers.
This option is intended to be used with assertion failures or logging output: these are technically side effects, but the effect is irrelevant to the normal functionality of the program.
The following example illustrates the difference between
side_effects.effect_free_functionsandside_effects.local_effect_functions:void abort(); int foo(int* p) { if (p == NULL) { abort(); } return *p; } int main(int argc, char** argv) { int a = argc; int b = argc; foo(&a); if (argc && foo(&b)) {} }Without any extra configuration, this code example will result in a MisraC2012-13.5 violation: "Side-effect in right-hand-side of &&"With
effect_free_functions=["abort"], the MisraC2012-13.5 violation will not be reported, but instead there will be two MisraC2012-2.2 "Statement without side-effect" violations reported for theabort()call and for thefoo(&a)call.With
local_effect_functions=["abort"], the MisraC2012-13.5 violation will also not be reported, but there will only be a single MisraC2012-2.2 "Statement without side-effect" violation: thefoo(&a)call. Theabort()call is still considered a side effect -- but only locally within the body of foo. For the purpose of foo's callers, the potential abort call is ignored.
side_effects.side_effect_functions : set[bauhaus.analysis.config.QualifiedName] =
Names of functions that cause an external side effect, e.g. file operations. For C++, use qualified names without template arguments, e.g.{'fclose', 'fopen', 'fprintf', 'fputs', 'freopen', 'printf', 'tmpfile'}std::vector::push_back.
6.2.1.8. types¶
Several options related to types of the analysed project.
types.allow_single_bitfield_as_bool : bool =
If true, bitfields of size "1 bit" are effectively boolFalse
types.enums_as_integer_constants : set[str] =
Enum type name patterns which should be seen as collection of integer constants.set()
types.external_functions_returning_bool : set[bauhaus.analysis.config.QualifiedName] =
Qualified function names for external functions which should be seen as returning boolset()
types.fixed_size_int_typedefs : set[str] =
Regular expression strings for names of typedefs for fixed-size integers, e.g. 'char(\d)*_t$', 'u?int\d+_t$', 'float\d+_t$'set()
types.user_bool_macros : set[bauhaus.analysis.config.MacroName] =
Names of macros that should be considered to have type bool. This option is intended to be used in combination with user_bool_types.set()This option only works for macros defined as a simple integer literal:
typedef unsigned int bool_t; #define FALSE 0 #define TRUE 1Configuration:"user_bool_types": [ "bool_t" ], "user_bool_macros": [ "FALSE", "TRUE" ]If the macros instead contain a cast,
user_bool_macroswill have no effect. With a cast, it is sufficient to set option types.user_bool_types.
types.user_bool_types : set[str] =
Used to configure additional boolean types in C.set()You can configure the names of typedefs, enums or macros.
This option influences "essentially boolean" in MisraC2012 and "effectively boolean" in the other Misra standards.
Example with boolean typedef:
typedef unsigned int bool_t; #define FALSE ((bool_t)0) #define TRUE ((bool_t)1)Configuration:"user_bool_types": [ "bool_t" ]Example with boolean enum:
enum bool_tag { FALSE = 0, TRUE = 1 }; typedef enum bool_tag bool_t;Configuration:"user_bool_types": [ "bool_tag", "bool_t" ]Example with macro:
#define BOOL unsigned char #define FALSE ((BOOL)0) #define TRUE ((BOOL)1)Configuration:"user_bool_types": [ "BOOL" ]If your
TRUE/FALSEmacros do not contain a cast to the boolean type, you will need to also configure option types.user_bool_macros.