-
Notifications
You must be signed in to change notification settings - Fork 21
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
Formatter remove single quotes from macros containing dashes #311
Comments
First of all, as usual with macros… 😱 OMG! Do people really do that thing? 🤦🏻 Now… Thanks, @carlosedp for the report. I'll eventually check it out, but I have to tell you: This will not be fixed soon… …unless you feel like sending a PR to fix it 😉 And also… 😱 OMG! Do people really do that thing? 🤦🏻 |
Hahaha, it's an internal macro that is compiled from Diameter files... I do not have control of its generated name. I was looking at the code and laughed about the macro comments.. 😂 |
You should probably start by checking what If I'm not mistaken… it's very very likely that |
I created a small test file as: -module(test_format).
-include_lib("rfc4006_cc_Gy.hrl").
-define(WORK, abc).
-define(CCR_INITIAL, ?'CC-REQUEST-TYPE_INITIAL_REQUEST').
-define(CCR_UPDATE, ?'WORK'). parsing it gave me: 1> ktn_dodger:parse_file("apps/dccaserver/src/test_format.erl").
{ok,[{tree,attribute,
{attr,1,[],none},
{attribute,{tree,atom,{attr,1,[],none},module},
[{tree,atom,{attr,1,[],none},test_format}]}},
{tree,attribute,
{attr,3,[],none},
{attribute,{atom,3,include_lib},
[{string,3,"rfc4006_cc_Gy.hrl"}]}},
{tree,attribute,
{attr,5,[],none},
{attribute,{tree,atom,{attr,5,[],none},define},
[{var,5,'WORK'},{tree,text,{attr,5,[],none},"abc"}]}},
{tree,attribute,
{attr,6,[],none},
{attribute,{tree,atom,{attr,6,[],none},define},
[{var,6,'CCR_INITIAL'},
{tree,text,
{attr,6,[],none},
"?CC - REQUEST - TYPE_INITIAL_REQUEST"}]}},
{tree,attribute,
{attr,7,[],none},
{attribute,{tree,atom,{attr,7,[],none},define},
[{var,7,'CCR_UPDATE'},
{tree,text,{attr,7,[],none},"?WORK"}]}}]} As seen, ktn_dodger separated the word in the dashes but it's quoted(the attr 6)... should I open the issue on katana_code so? |
Yeah… it parsed it as raw |
Same issue with standard erlang module public_key. It contains many macros like ?'id-ce-subjectAltName' that are used when parsing certificates. Any chance to fix this in the the plugin? |
@shapovalovts To be honest, nobody is planning to work on this any time soon. The fix probably requires a bunch of non-trivial changes. All for not a huge gain, unless you are telling me that the OTP team is planning to start using this formatter for its code. On the other hand, pull requests are more than welcomed both here and in katana-code repositories ;) |
Thank you for the clarification. To make it clear: I have no idea about OTP team plans regarding their code re-formatting (though would be cool if they start using your plugin). The macros like the one I mentioned are used outside OTP code in different projects when certificates meta data is parsed. |
Describe the bug
Formatter remove single quotes from macros containing dashes.
To Reproduce
The code below:
becomes:
Removing the single quotes, making the code unable to compile.
Expected behavior
Do not remove quotes from macros that have dashes. This doesn't happen when using erlfmt external formatter.
Rebar3 Log
Run rebar3 with
DEBUG=1
and paste its output here.Additional context
Below the format config in my rebar.config:
The text was updated successfully, but these errors were encountered: