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
Rebar3 format #2996
base: master
Are you sure you want to change the base?
Rebar3 format #2996
Conversation
There is also the erlfmt.
Also have a check command:
The |
@williamthome yep, thanks, I know about this tool. But in big project the |
@williamthome another important point is that |
@vkatsuba thanks for the explanation. For my use case, the |
b13f59d
to
5fade52
Compare
@williamthome here is described config https://github.com/AdRoll/rebar3_format#configuration. Also was created a great topic https://tech.nextroll.com/blog/dev/2020/02/25/erlang-rebar3-format.html. Enjoy! |
}). | ||
|
||
-record(z_msg_v1, | ||
{qos = 0 :: 0 | 1 | 2, |
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 like this {
on this position, as either it is not a tab stop, or the list below is not a tab stop.
That is why I normally add the {
at the end of the previous line.
location :: binary() | ||
}). | ||
|
||
-record(filestore_credentials_lookup, {id :: integer(), path :: 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.
I know it fits on a single line, wouldn't it be better (and consistent) to have it on multiple lines, like the other record definitions?
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.
You can add -format #{inline_fields => none}.
to this module or the equivalent option to the rebar.config
if you want it for all modules. But… that won't put {
on the initial line.
logger:get_handler_config()), | ||
IsLogstasherNeeded = | ||
lists:any(fun(#{ module := Module }) -> Module =:= logstasher_h end, | ||
logger:get_handler_config()), |
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.
Personally I find this less readable than the non-reformatted version, also because the arguments are not a tab stop anymore.
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.
You can add -format #{inline_simple_funs => false}.
to this module or the equivalent option to the rebar.config
file if you want it for all modules.
path => MnesiaDir, | ||
result => error, | ||
reason => Reason | ||
}), |
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.
Why the extra indentation? Does it want to push it at the same indent as the #{
?
I also like to have the closing })
on the same level as the ?LOG_ERROR
, as it is easier to scan upwards to see to what it belongs.
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, sadly, is not yet an option for rebar3_format
. Feel free to open a ticket (or a PR ;)) to add it.
Processes = | ||
[% Ring buffer for http request logs | ||
{ringbuffer_normal, | ||
{ringbuffer_process, start_link, [zotonic_http_metrics_normal, LogBufferSize]}, |
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 like to have indents of a singe space, makes this less readable.
Is there a setting to have all indents on tab stops? (aka 4 chars)
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.
Sadly, no. That comes straight up from OTP's prettypr
. It's really hard to change. I know, because I also like 4-space indentations and I tried my best at achieving that and failed. Without improvements on OTP's prettypr
, I doubt that rebar3_format
will ever be available to give you that option.
terminal_notifier/1 | ||
]). | ||
-export([compile_all/0, compile_all_sync/0, reload_modules/0, reload_module/1, | ||
load_module/1, compile_options/1, terminal_notifier/1]). |
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.
Personally, I find it easier to see what is exported by having all functions on their own line.
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.
You can add -format #{inline_attributes => none}.
to this module or the equivalent option to the rebar.config
file if you want it for all modules.
Description
Add https://github.com/AdRoll/rebar3_format. For run formatting just call:
For verify if need to run formatting plugin, just need to run: