-
Notifications
You must be signed in to change notification settings - Fork 19
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
Elvis integration? #14
Comments
That's a good idea - I assume you mean that we could autocorrect some style issues that elvis reports, using elvis.config as guide/config? It's definitely a useful feature. This will be something for later (for what I am concerned, I want to get the server going first). The code formatter right now is actually an indenter only, as we don't break any lines. Breaking lines at the right place is not very easy to do right. As long as we don't have a full formatter, I would probably do these fixes as a separate command. If elvis is integrated in the editor/IDE, then the user can choose a "quick fix" operation for each one (or each type) and see and review the results right away. |
ok, I'll do this as a separate command, maybe reusing some of (or depending on) the elvis core (https://github.com/inaka/elvis_core). What you think? something like |
There should be some configuration to specify which fixes to apply (to which elvis rules). Maybe "--elvis" to use info in config file and "--elvis ruleX,ruleY" will correct only ruleX and ruleY. This functionality is in a bit of gray zone: elvis could just as well have a "--fix" parameter that would make the corrections. I don't think that the implementation will make use of any sourcer-specific code. |
I agree, at least right now adding this directly to elvis might be a better idea. I was trying to study indenter code a bit more, but there lots of things are going on. Any documentation/blog post? In theory if it's building AST, then said AST could be dumped as text following configured formatting rules. I feel like indenter and elvis probably overlap here to some extent. |
Sorry, there is no documentation but the code. I didn't wrote any of it, so I confess I don't know much about how it works. I don't think it parses into an AST, because then we could have had a full formatter (like erl_tidy) and also it would only have worked on compileable code (which when editing is not always the case). I think it uses empiric rules and looks at the previous row to decide how to indent the current one (a bit simplified, of course). |
Elvis is the Erlang style reviewer (https://github.com/inaka/elvis).
Many use elvis to enforce code style (me included). There are rules related to text formatting, such as:
I would like to have sourcer_indent integrated with elvis, i.e. understand formatting specific rules and apply them (e.g. add space after ,).
The text was updated successfully, but these errors were encountered: