Skip to content

Clarify empty braced statements #191

Closed
@MichaelChirico

Description

@MichaelChirico

The guide currently has pretty broad rules about braces:

https://style.tidyverse.org/syntax.html#indenting

One edge case apparently precluded by the current rules is an empty expression: { } or {}, for example empty while loops:

while (some_updating_condition()) { }

I don't think splitting the braces is a good choice in this case:

while (some_updating_condition()) {
}

styler already enforces what looks to me like a good rule:

library(styler)

style_text("while (TRUE) { }")
# while (TRUE) { }
style_text("while (TRUE) {}")
# while (TRUE) {}
style_text("while (TRUE) { 1 }")
# while (TRUE) {
#   1
# }

Is it worth codifying this behavior in the guide?

We are wondering how to handle this in lintr: r-lib/lintr#1346

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