-
Notifications
You must be signed in to change notification settings - Fork 56
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
Ets fun2ms without ms transform #374
Ets fun2ms without ms transform #374
Conversation
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.
For performance (and semantics) sake, I would do the check in the opposite direction. In other words, instead of first looking for all files that don't include ms_transform and checking each one to see if they use ets:fun2ms… I would look for all files that use ets:fun2ms (which are surely far less than the ones that don't include ms_transform) and then check if they include the hrl or not.
You should also add a test with a file that has the -include
but not the usage of fun2ms
, for completeness sake. Like…
-module(pass_ms_transform_included_too).
-include_lib("stdlib/include/ms_transform.hrl").
-export([test/0]).
test() -> ok.
And maybe another one like…
-module(pass_ms_transform_included_as_well).
-export([test/0]).
test() -> {this, is, "not", ets, my:fun2ms("It's my own")}.
Co-authored-by: Brujo Benavides <[email protected]>
Oh yes, that is a way better approach. Thanks! |
I made some changes based on your suggestions. However, I believe this rule could be more generic. Currently, it only checks for a specific scenario, but we can expand it. We could create a rule that detects any function call that requires an include but does not have it. |
@bormilan We can do that in another ticket. Please write a ticket for that. |
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.
A few tiny improvements in code and docs… and do consider adding the tests I requested in my previous review, @bormilan.
Thanks.
Okay, it sounds
Yes, I will add that test, I didn't forget. |
Okay, It sounds good! |
Co-authored-by: Brujo Benavides <[email protected]>
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.
A little bit of nit-picking, but overall the code is great.
If you feel like ignoring the nit-picky comments, @bormilan … just let me know and I'll merge the PR as-is.
No, I'm grateful for your time, and I want to bring home as much as I can from these, so please be as nit-picky as you want, I really appreciate it! 🙌 Some say, "God is in the details." |
@@ -0,0 +1,13 @@ | |||
-module(used_ignored_variable_in_macro). |
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 don't think this file belongs to this PR.
@@ -113,6 +114,7 @@ rules(beam_files) -> | |||
invalid_dynamic_call, | |||
max_anonymous_function_arity, | |||
max_function_arity, | |||
ms_transform_included, |
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.
@elbrujohalcon, I wonder if, in the future, to ease maintenance, this list should be build like a sub-set of _strict
, for example...
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 a good idea, yeah.
Description
It detects if a module that does not include
ms_transform.hrl
has anyets:fun2ms
function call.Closes #313;