styler icon indicating copy to clipboard operation
styler copied to clipboard

R6 methods don't allow double-indented formals?

Open MichaelChirico opened this issue 1 year ago • 3 comments

The following should be allowed (ref: https://style.tidyverse.org/functions.html#long-lines-1 doesn't mention R6):

R6Class("MyClass",
  public = list(
    param = NULL,
    initialize = function(
        my_long_parameter = getOption("default_long_parameter", 1)) {
      self$param <- my_long_parameter
    }
  )
)

But it's currently re-styled (style_text() output):

R6Class("MyClass",
  public = list(
    param = NULL,
    initialize = function(my_long_parameter = getOption("default_long_parameter", 1)) {
      self$param <- my_long_parameter
    }
  )
)

Which of course creates an over-full line.

MichaelChirico avatar Jul 13 '23 22:07 MichaelChirico

Right… but I think in your example, you only put one level of indention. Shouldn’t it be

R6Class("MyClass",
  public = list(
    param = NULL,
    initialize = function(
        my_long_parameter = getOption("default_long_parameter", 1)) {
      self$param <- my_long_parameter
    }
  )
)

lorenzwalthert avatar Jul 15 '23 11:07 lorenzwalthert

ah yes, my mistake. edited in the description

MichaelChirico avatar Jul 15 '23 16:07 MichaelChirico

Seems like detection of double indention is based on the absolute indention of the formals, instead of the relative...

lorenzwalthert avatar Jul 16 '23 12:07 lorenzwalthert