teal icon indicating copy to clipboard operation
teal copied to clipboard

[Feature Request]: Move all methods from `TealAppDriver` to function calls

Open averissimo opened this issue 1 year ago • 0 comments

Feature description

The Methods' body on the TealAppDriver class should be defined as internal function calls to trigger all checks in R CMD check.

This would avoid problems such as #1197 and follow the same pattern as shinytest2::AppDriver source code.

TealAppDriver <- R6::R6Class( # nolint: object_name.
  "TealAppDriver",
  inherit = shinytest2::AppDriver,
  # public methods ----
  public = list(
    initialize = function(a, b) {
      private$a <- a
      private$b <- b
    },
    foo = function(d, e) {
      private$a + self$bar() + d + e
    },
    bar = function() {
      private$b * 2
    }
  ),
  private = list(a = 0, b = 0)
)

To:

TealAppDriver <- R6::R6Class( # nolint: object_name.
  "TealAppDriver",
  inherit = shinytest2::AppDriver,
  # public methods ----
  public = list(
    initialize = function(a, b) app_driver_initialize(self, private, a, b),
    foo = function(d, e) app_driver_foo(self, private, d ,e),
    bar = function() app_driver_bar(self, private)
  ),
  private = list(a = 0, b = 0)
)

# Functions below defined on a different file (either 1 file per function or grouping related functions in a file `TealAppDriver-methods.R`)

app_driver_initialize <- function(self, private, a, b) {
  private$a <- a
  private$b <- b
}

app_driver_foo <- function(self, private, d, e) {
  private$a + self$bar() + d + e
}

app_driver_bar <- function(self, private) {
  private$b * 2
}

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • [X] I agree to follow this project's Contribution Guidelines.

Security Policy

  • [X] I agree to follow this project's Security Policy.

averissimo avatar Apr 11 '24 08:04 averissimo