Module unused_record_fields

A rule to detect unused record fields.

Behaviours: hank_rule.

To do

Description

A rule to detect unused record fields.

The rule will detect fields that are defined as part of a record but never actually used anywhere.

To avoid this warning, remove the unused record fields.

Note that for header files, this rule will fail to detect some unused fields. Particularly, in the case where you have an unused field defined in a header file and another record with the same name and the same field defined somewhere else that is used. Since determining precisely what files are included in each -include attribute is not trivial, Hank will act conservatively and not make any effort to verify where each record field that's used is defined. So, if you have a project with multiple definitions of the same record with the same field... well... as long as one of them is used, none of them will be reported as unused.

Note

This rule assumes that your code will never use the underlying tuple structure of your records directly. If you do so, you can add an ignore rule in rebar.config for it.

Function Index

ignored/2Rule ignore specifications.

Function Details

ignored/2

ignored(Pattern::hank_rule:ignore_pattern(), RecordName::term()) -> boolean()

Rule ignore specifications. Example:

       -hank([{unused_record_fields,
                [a_record, %% Will ignore all fields in #a_record
                 {a_record, a_field} %% Will ignore #a_record.a_field
                ]}]).
       


Generated by EDoc