-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
R6 methods don't allow multi-line formals? #1136
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
Seems like detection of double indention is based on the absolute indention of the formals, instead of the relative... |
This is actually fixed with #1235 I belive, as double indention is not allowed anymore. Can you double check @MichaelChirico? |
Unfortunately no, the same bug still applies to the new style guide approach: styler::style_text(R"(
R6Class("MyClass",
public = list(
param = NULL,
initialize = function(
my_long_parameter = getOption("default_long_parameter", 1)
) {
self$param <- my_long_parameter
}
)
)
)") gives output R6Class("MyClass",
public = list(
param = NULL,
initialize = function(my_long_parameter = getOption("default_long_parameter", 1)) {
self$param <- my_long_parameter
}
)
) |
(updated the bug title since it's not about double-indentation per se, but about declaring R6 methods with multi-line formals, under either old or new guide style) |
Seems not a problem in unnested case: styler::style_text('initialize <- function(
my_long_parameter = getOption("default_long_parameter", 1)) {
self$param <- my_long_parameter
}')
#> Warning: Could not use `colored = TRUE`, as the package prettycode is not installed.
#> Please install it if you want to see colored output or see
#> `?styler::print.vertical()` for more information.
#> initialize <- function(
#> my_long_parameter = getOption("default_long_parameter", 1)) {
#> self$param <- my_long_parameter
#> } Created on 2024-12-05 with reprex v2.1.0 |
The following should be allowed (ref: https://style.tidyverse.org/functions.html#long-lines-1 doesn't mention R6):
But it's currently re-styled (
style_text()
output):Which of course creates an over-full line.
The text was updated successfully, but these errors were encountered: