No Includes

View Source

Note

This rule was named no_nested_hrls before 4.2.0.

-include and -include_lib attributes in header files should be avoided.

Quick fix

Move the -include[_lib] attributes to the modules that actually need them.

Rationale

Nesting include files makes it harder for the reader of a module to understand the origin of macros, records, or other attributes found in them. It also leads to the usage of macros like the one shown below to avoid duplicate definitions if more than one header file includes the same (different) header file, too.

-ifndef(HEADER_FILE).

-endif.

The code becomes unnecessarily complex and harder to maintain.

Options

  • None.

Example configuration

{elvis_style, no_includes, #{}}