Open rlaboiss opened 2 months ago
There is definitely an inconsistency here. Thanks for pointing out.
cat("if (TRUE)\n x")
#> if (TRUE)
#> x
cat("for (i in 0)\n x")
#> for (i in 0)
#> x
cat("while (TRUE)\n x")
#> while (TRUE)
#> x
lintr::lint(text= "if (TRUE)\n x", linters = lintr::indentation_linter())
lintr::lint(text= "for (i in 0)\n x", linters = lintr::indentation_linter())
#> <text>:2:2: style: [indentation_linter] Indentation should be 0 spaces but is 2 spaces.
#> x
#> ~^
lintr::lint(text= "while (TRUE)\n x", linters = lintr::indentation_linter())
Created on 2024-04-23 with reprex v2.1.0
R accepts single-line bodies, without curly braces, for the
if
and thefor
statements.Is there any reason why lintr accepts that for
if
but not forfor
? For instance: