-
Notifications
You must be signed in to change notification settings - Fork 71
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
Indentation issue in multi-line conditional expressions #1065
Comments
This is intentional (not the {lintr} conflict). There is at most one level of indention triggered per line. The style guide does not specify that clearly IIRC, so there's some ambiguity. When you type the code in RStudio, I think it's compliant with what {styler} does. See also #549, where a {lintr} conflict was mentioned as well. I think it would be greate if {lintr} could be configured to accept current behaviour of {styler} here. |
The reason we do it like this is to disambiguate, especially such cases: fun(arg1 &&
still_arg1,
arg2)
fun(arg1,
arg2,
arg3) If lines get longer, the |
Thanks for adding the clarification, @AshesITR. @lorenzwalthert TBH, I also personally prefer an extra indent in such contexts, and if the style guide is ambiguous in this regard, maybe we should try to be consistent with |
I think we should file an issue in https://github.com/tidyverse/style and get it clarified. That's how we solved these conflicts in the past. As I said, I think it's easier if the IDE already has styling aligned and if we keep the rule that there is at most one additional level of indention per line. That's why we also have test_that('x', {
# one level
)} # edit: }) I mean |
@AshesITR Would you be willing to file an issue? You are the indentation expert now 🙃 |
That code, when fixed by swapping |
Thanks for creating the issue, @AshesITR! |
Currently, the multi-line conditional expressions don't have the same indentation.
E.g., the following code, when styled with
{styler}
remains unchanged:Shouldn't it instead be styled to the following?
As an aside, the current behaviour in
{styler}
conflicts with{lintr}
, which produces lint for the styled code (cc @AshesITR):Created on 2022-11-21 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: