Skip to content

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

@MichaelChirico

Description

@MichaelChirico

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions