AutosarC++17_03-A16.2.2

There shall be no unused include directives

Required inputs: IR

Including as few headers as possible makes the dependencies in the code more explicit, and can help reduce compilation time.

Possible Messages

Key

Text

Severity

Disabled

unused_include

#include {inc} can be removed as file does not use anything from it

None

False

Options

accept_incomplete_arguments

accept_incomplete_arguments

Type: list[bauhaus.analysis.config.ShortTypeName]

Default: ['shared_ptr', 'unique_ptr', 'weak_ptr', 'auto_ptr', 'default_delete', 'enable_shared_from_this', 'list', 'forward_list', 'vector', 'allocator', 'polymorphic_allocator', 'is_void', 'is_null_pointer', 'is_integral', 'is_floating_point', 'is_array', 'is_pointer', 'is_lvalue_reference', 'is_rvalue_reference', 'is_member_object_pointer', 'is_member_function_pointer', 'is_enum', 'is_union', 'is_class', 'is_function', 'is_reference', 'is_arithmetic', 'is_fundamental', 'is_object', 'is_scalar', 'is_compound', 'is_member_pointer', 'is_const', 'is_volatile', 'is_signed', 'is_unsigned', 'rank', 'extent', 'is_same', 'remove_const', 'remove_volatile', 'remove_cv', 'add_const', 'add_volatile', 'add_cv', 'remove_reference', 'add_lvalue_reference', 'add_rvalue_reference', 'make_signed', 'make_unsigned', 'remove_extent', 'remove_all_extents', 'remove_pointer', 'add_pointer', 'decay', 'enable_if', 'conditional']

Names of templates for which incomplete types should be accepted as allowed template type arguments (so forward declarations of these arguments are enough to instantiate the template).
 

avoid_uncertain_messages

avoid_uncertain_messages : bool = True

Whether messages should be omitted if they are tagged as uncertain due to possibly unknown symbol references in templates.
 

context_macros

context_macros : list[str] = []

List of macro names which are intentionally not defined inside a file or in files included from it. The names can contain regexp patterns.
 

enums_can_be_redeclared

enums_can_be_redeclared : bool = False

Whether local redeclarations of enums should be allowed to avoid #includes.
 

interface_headers

interface_headers : list[bauhaus.analysis.config.FileGlobPattern] = []

Globbing patterns for files which should be seen as ok although they might just #include files without using them. #includes to these interface files are also treated as ok.
 

limit_for_moving

limit_for_moving : int = 3

If an include is unused locally, but used in client files or inside subsequently included headers, this limit determines the maximum number of such target files up to which a Move_Include suggestion will be generated; if there are too many target files, a Move_Include_With_Many_Clients will be reported instead.
 

limit_for_replacing

limit_for_replacing : int = 3

If an include can be replaced by forward declarations and other, more precise #includes covering only parts of the previous #include, this limit determines the maximum number of such replacements up to which such a suggestion is generated; if there are too many replacements, the include is accepted instead.
 

routines_can_be_redeclared

routines_can_be_redeclared : bool = False

Whether local redeclarations of functions should be allowed to avoid #includes.
 

typedefs_can_be_redeclared

typedefs_can_be_redeclared : bool = False

Whether local redeclarations of typedefs should be allowed to avoid #includes.