View Source single_use_hrl_attrs (rebar3_hank v1.4.1)

A rule to detect hrl attributes used in just one module: Attributes supported: -define -record It will suggest to place those attributes inside the module to avoid having (and including) a hrl file.

note

Note

This rule assumes that hrl files will not be used outside your project. If you are writing a library that requires your clients to use some of your header files and attributes, you can add an ignore rule in rebar.config for it.

Link to this section Summary

Functions

This builds a list of header files with its attributes. Then traverse the file ASTs mapping their macros and records And checks whether they were used just once.
Rule ignore specifications. Example:
       -hank([{single_use_hrl_attrs,
               ["ALL",          %% Will ignore ?ALL, ?ALL() and ?ALL(X)
                {"ZERO", 0},    %% Will ignore ?ZERO() but not ?ZERO(X) nor ?ZERO
                {"ONE",  1},    %% Will ignore ?ONE(X) but not ?ONE()   nor ?ONE
                {"NONE", none}, %% Will ignore ?NONE but not ?NONE(X) nor ?NONE()
                record_name     %% Will ignore #record_name
               ]},
       

Link to this section Functions

Link to this function

analyze(FilesAndASTs, Context)

View Source
-spec analyze(hank_rule:asts(), hank_context:t()) -> [hank_rule:result()].
This builds a list of header files with its attributes. Then traverse the file ASTs mapping their macros and records And checks whether they were used just once.
Link to this function

ignored(RecordName, MacroName)

View Source
-spec ignored(hank_rule:ignore_pattern(), term()) -> boolean().
Rule ignore specifications. Example:
       -hank([{single_use_hrl_attrs,
               ["ALL",          %% Will ignore ?ALL, ?ALL() and ?ALL(X)
                {"ZERO", 0},    %% Will ignore ?ZERO() but not ?ZERO(X) nor ?ZERO
                {"ONE",  1},    %% Will ignore ?ONE(X) but not ?ONE()   nor ?ONE
                {"NONE", none}, %% Will ignore ?NONE but not ?NONE(X) nor ?NONE()
                record_name     %% Will ignore #record_name
               ]},