View Source unused_record_fields (rebar3_hank v1.4.1)

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

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.

Link to this section Summary

Functions

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
                ]}]).
       

Link to this section Functions

Link to this function

ignored(Pattern, RecordName)

View Source
-spec ignored(hank_rule:ignore_pattern(), 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
                ]}]).