-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1098] Detect unused record fields #1099
Conversation
e6c43c9
to
532a154
Compare
532a154
to
1cb142e
Compare
1cb142e
to
e43534b
Compare
{RecordName, RecordField} -> | ||
els_utils:to_binary( | ||
lists:flatten(io_lib:format("~p/~p", [RecordName, RecordField]))); | ||
Id -> atom_to_binary(Id, utf8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in which case can the Id be an atom?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's copy-paste from the Unused Macro diagnostics backend, cleaning.
case POIId of | ||
{RecordName, RecordField} -> | ||
els_utils:to_binary( | ||
lists:flatten(io_lib:format("~p/~p", [RecordName, RecordField]))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: what about ~p.~p
or #~p.~p
? (looks more recody syntax)
FullName = | ||
case POIId of | ||
{RecordName, RecordField} -> | ||
els_utils:to_binary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
els_utils:to_binary(
supports deep lists (unicode:chardata()
) so no need to flatten. On the other hand should we use ~tp
instead of ~p
to properly print unicode atoms? (I am always confused with unicode, maybe a new atom_to_label
function in els_utils
could have it right once and that could be used in the whole code base)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that approach. So, I will keep it for now and handle this as a follow up (feel free to contribute on that).
find_unused_record_fields(Document) -> | ||
Definitions = els_dt_document:pois(Document, [record_def_field]), | ||
Usages = els_dt_document:pois(Document, [record_field]), | ||
UsagesIds = [Id || #{id := Id} <- Usages], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimisation: UsagesIds could be an usort-ed list
Description