Skip to content

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

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.

Activity

  1. lorenzwalthert commented on Jan 30, 2023

    @lorenzwalthert
    Collaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions