Skip to content

New double-indented function style gets undone, causing lint #1092

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

Closed
MichaelChirico opened this issue Jan 26, 2023 · 1 comment · Fixed by #1094
Closed

New double-indented function style gets undone, causing lint #1092

MichaelChirico opened this issue Jan 26, 2023 · 1 comment · Fixed by #1094

Comments

@MichaelChirico
Copy link
Contributor

MichaelChirico commented Jan 26, 2023

I tried to adjust a wide function declaration to use the new double-indented style:

# before
xxxxxxxxxx_xxxxxxxxxxx <- function(yyyyyyyyyy.yyyy = c(
                                     "aaaaaaaaaa", "bbbbbbbbb", "cccc"
                                   )) {
  ...
}

# after
xxxxxxxxxx_xxxxxxxxxxx <- function(
    yyyyyyyyyy.yyyy = c("aaaaaaaaaa", "bbbbbbbbb", "cccc")) {
  ...
}

But under styler 1.9.0 this gets edited:

styler::style_text('
xxxxxxxxxx_xxxxxxxxxxx <- function(
    yyyyyyyyyy.yyyy = c("aaaaaaaaaa", "bbbbbbbbb", "cccc")) {
  ...
}
')
# xxxxxxxxxx_xxxxxxxxxxx <- function(yyyyyyyyyy.yyyy = c("aaaaaaaaaa", "bbbbbbbbb", "cccc")) {
#   ...
# }

AFAICT the after style is style guide compliant (https://style.tidyverse.org/functions.html#long-lines-1); the key may be:

Prefer function-indent style to double-indent style when it fits.

Under the tidyverse guidance of 80 characters per line, the function doesn't"fit" in function-indent style, hence double-indenting is OK.

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Jan 30, 2023

Under the tidyverse guidance of 80 characters per line

For that we can't account, see #247. But we can not remove the line break in general if there is one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants