r-lib / lintr

Static Code Analysis for R
https://lintr.r-lib.org
Other
1.19k stars 184 forks source link

Lint empty curly braces with spaces and/or line-breaks #2668

Open IndrajeetPatil opened 9 hours ago

IndrajeetPatil commented 9 hours ago

cf. https://style.tidyverse.org/syntax.html?q=empty%20curly%20braces#indenting

library(lintr)

lint(
  text = "while (waiting_for_something()) { }",
  linters = all_linters()
)
#> ℹ No lints found.

lint(
  text = "while (waiting_for_something()) {

}",
  linters = all_linters()
)
#> ℹ No lints found.

Created on 2024-10-02 with reprex v2.1.1

Instead of no lint, the {lintr} should recommend:

while (waiting_for_something()) {}
IndrajeetPatil commented 9 hours ago

Ideally, {styler} takes care of this https://github.com/r-lib/styler/issues/1232