r-lib / lintr

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

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

Open IndrajeetPatil opened 2 months ago

IndrajeetPatil commented 2 months 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 2 months ago

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