insightsengineering / teal

Exploratory Web Apps for Analyzing Clinical Trial Data
https://insightsengineering.github.io/teal/
Other
168 stars 33 forks source link

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

Open averissimo opened 3 months ago

averissimo commented 3 months ago

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

Contribution Guidelines

Security Policy