CQM-IncludeLie¶
Unused includes
Required inputs: IR
Motivation
Individual files or entire libraries are included in the source code, although they are not referenced at all. These unnecessary includes do not change the behavior of the system, but increase the demands on the build process. All listed files or libraries must be available for a successful build. In addition, an import lie creates the false impression of a dependency between included and including file.
This rule is based on the CQM Quality Indicator: Importlüge (p. 219-221).
Reference
Simon, Frank/ Seng, Olaf/ Mohaupt, Thomas (2006): Code-Quality-Management: Technische Qualität industrieller Softwaresysteme transparent und vergleichbar gemacht, 1st ed., Heidelberg, Germany: dpunkt.verlag GmbH.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
contents_covered_include |
#include {inc} can be removed as it only provides symbols covered by other #include(s) |
None |
False |
more_precise_include |
#include {inc} can be replaced with #include {srcfile} |
None |
False |
move_include |
#include {inc} can be moved into {srcfile} |
None |
False |
move_include_with_many_clients |
#include {inc} is unused locally, but there are many other files possibly relying on it |
None |
False |
unused_include |
#include {inc} can be removed as file does not use anything from it |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
accept_incomplete_arguments¶
accept_incomplete_arguments
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).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']
avoid_uncertain_messages¶
avoid_uncertain_messages : bool = True
context_macros¶
context_macros : list[str] = []
enums_can_be_redeclared¶
enums_can_be_redeclared : bool = False
#includes.
interface_headers¶
interface_headers : list[bauhaus.analysis.config.FileGlobPattern] = []
#include files without using them. #includes to these
interface files are also treated as ok.
limit_for_moving¶
limit_for_moving : int = 3
limit_for_replacing¶
limit_for_replacing : int = 3
routines_can_be_redeclared¶
routines_can_be_redeclared : bool = False
#includes.
typedefs_can_be_redeclared¶
typedefs_can_be_redeclared : bool = False
#includes.