You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
code<-'long_function_name <- function( a = "a long argument", b = "another argument", c = "another long argument") { # As usual code is indented by two spaces.}'
cat(code)
#> long_function_name <- function(#> a = "a long argument",#> b = "another argument",#> c = "another long argument"#> ) {#> # As usual code is indented by two spaces.#> }lintr::lint(code)
#> <text>:2:4: style: [indentation_linter] Indentation should be 2 spaces but is 4 spaces.#> a = "a long argument",#> ~^
This occurs both with v3.2.0 from CRAN and commit a2b8d6f from GitHub.
In contrast, moving ) { onto the line of the last argument produces no lint:
code<-'long_function_name <- function( a = "a long argument", b = "another argument", c = "another long argument") { # As usual code is indented by two spaces.}'
cat(code)
#> long_function_name <- function(#> a = "a long argument",#> b = "another argument",#> c = "another long argument") {#> # As usual code is indented by two spaces.#> }lintr::lint(code)
#> ℹ No lints found.
Ah - I didn't realize that those indents had gotten doubled when I set up the reprex (they are un-doubled in the style guide).
I think "Reindent lines" (Ctrl-I) in RStudio still adds the double-indent (c.f. rstudio/rstudio#10752 and rstudio/rstudio#11101).
If double-indentation has been removed from the style guide, should the second example above also throw a lint? It also has double indentation, but currently no lint is thrown. Here's a slightly clearer version:
code<-'long_function_name <- function( a = "a long argument", b = "another argument", c = "another long argument") { # As usual code is indented by two spaces.}'
cat(code)
#> #> long_function_name <- function(#> a = "a long argument",#> b = "another argument",#> c = "another long argument") {#> # As usual code is indented by two spaces.#> }lintr::lint(code)
#> ℹ No lints found.
Yes I agree that could lint.
IMO it's not an indentation lint though, I think the lint should land on ) which should be on a new line since the corresponding ( is last-on-line.
The "Good" "Single-indent" example of "Multi-line function definitions" from the tidyverse style guide (https://style.tidyverse.org/functions.html#multi-line-function-definitions) currently generates a lint from
indentation_linter
:Created on 2025-03-10 with reprex v2.1.1
This occurs both with v3.2.0 from CRAN and commit a2b8d6f from GitHub.
In contrast, moving
) {
onto the line of the last argument produces no lint:Created on 2025-03-10 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: