Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audit linter exceptions #1119

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ ui_teal <- function(id,
)

# show busy icon when `shiny` session is busy computing stuff
# based on https://stackoverflow.com/questions/17325521/r-shiny-display-loading-message-while-function-is-running/22475216#22475216 # nolint
# based on https://stackoverflow.com/questions/17325521/r-shiny-display-loading-message-while-function-is-running/22475216#22475216 # nolint: line_length.
shiny_busy_message_panel <- conditionalPanel(
condition = "(($('html').hasClass('shiny-busy')) && (document.getElementById('shiny-notification-panel') == null))", # nolint
condition = "(($('html').hasClass('shiny-busy')) && (document.getElementById('shiny-notification-panel') == null))", # nolint: line_length.
div(
icon("arrows-rotate", "spin fa-spin"),
"Computing ...",
Expand Down
6 changes: 3 additions & 3 deletions R/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
#'
module <- function(label = "module",
server = function(id, ...) {
moduleServer(id, function(input, output, session) {}) # nolint
moduleServer(id, function(input, output, session) {})
},
ui = function(id, ...) {
tags$p(paste0("This module has no UI (id: ", id, " )"))
Expand Down Expand Up @@ -281,7 +281,7 @@ modules <- function(..., label = "root") {

#' @rdname teal_modules
#' @export
format.teal_module <- function(x, indent = 0, ...) { # nolint
format.teal_module <- function(x, indent = 0, ...) {
paste0(paste(rep(" ", indent), collapse = ""), "+ ", x$label, "\n", collapse = "")
}

Expand All @@ -296,7 +296,7 @@ print.teal_module <- function(x, ...) {

#' @rdname teal_modules
#' @export
format.teal_modules <- function(x, indent = 0, ...) { # nolint
format.teal_modules <- function(x, indent = 0, ...) {
paste(
c(
paste0(rep(" ", indent), "+ ", x$label, "\n"),
Expand Down
2 changes: 1 addition & 1 deletion R/tdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ new_tdata <- function(data, code = "", join_keys = NULL, metadata = NULL) {
#' my_env <- isolate(tdata2env(data))
#'
#' @export
tdata2env <- function(data) { # nolint
tdata2env <- function(data) {
checkmate::assert_class(data, "tdata")
list2env(lapply(data, function(x) if (is.reactive(x)) x() else x))
}
Expand Down
2 changes: 1 addition & 1 deletion R/teal_reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' meta data.
#' @export
#'
TealReportCard <- R6::R6Class( # nolint: object_name_linter.
TealReportCard <- R6::R6Class( # nolint: object_name.
classname = "TealReportCard",
inherit = teal.reporter::ReportCard,
public = list(
Expand Down
2 changes: 1 addition & 1 deletion R/teal_slices.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ teal_slices <- function(...,
#' @export
#' @keywords internal
#'
as.teal_slices <- function(x) { # nolint
as.teal_slices <- function(x) { # nolint: object_name.
checkmate::assert_list(x)
lapply(x, checkmate::assert_list, names = "named", .var.name = "list element")

Expand Down
6 changes: 3 additions & 3 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.onLoad <- function(libname, pkgname) { # nolint
.onLoad <- function(libname, pkgname) {
# adapted from https://github.com/r-lib/devtools/blob/master/R/zzz.R
teal_default_options <- list(teal.show_js_log = FALSE)

Expand All @@ -14,7 +14,7 @@
invisible()
}

.onAttach <- function(libname, pkgname) { # nolint
.onAttach <- function(libname, pkgname) {
packageStartupMessage(
"\nYou are using teal version ",
# `system.file` uses the `shim` of `system.file` by `teal`
Expand All @@ -28,7 +28,7 @@ setdiff_teal_slices <- getFromNamespace("setdiff_teal_slices", "teal.slice")
# This one is here because it is needed by c.teal_slices but we don't want it exported from teal.slice.
coalesce_r <- getFromNamespace("coalesce_r", "teal.slice")
# all *Block objects are private in teal.reporter
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") # nolint
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") # nolint: object_name.

# Use non-exported function(s) from teal.code
# This one is here because lang2calls should not be exported from teal.code
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-module_teal_with_splash.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ testthat::test_that("srv_teal_with_splash gets observe event from srv_teal", {

testthat::test_that("srv_teal_with_splash accepts data after within.teal_data_module", {
tdm <- teal_data_module(ui = function(id) div(), server = function(id) reactive(teal_data(IRIS = iris)))
tdm2 <- within(tdm, IRIS$id <- seq_len(NROW(IRIS$Species))) # nolint: object_name_linter.
tdm2 <- within(tdm, IRIS$id <- seq_len(NROW(IRIS$Species))) # nolint: object_name.

testthat::expect_no_error(
shiny::testServer(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ testthat::test_that("modules_depth increases depth by 1 for each teal_modules",
# is_arg_used -----
get_srv_and_ui <- function() {
list(
server_fun = function(id, datasets) {}, # nolint
server_fun = function(id, datasets) {},
ui_fun = function(id, ...) {
tags$p(paste0("id: ", id))
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-teal_data_module-eval_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ testthat::test_that("within.teal_data_module returns an object with teal_data_mo
}
)

tdm2 <- within(tdm, IRIS$id <- seq_len(nrow(IRIS))) # nolint: object_name_linter.
tdm2 <- within(tdm, IRIS$id <- seq_len(nrow(IRIS))) # nolint: object_name.

testthat::expect_s3_class(tdm2, "teal_data_module")
})
Expand Down Expand Up @@ -41,7 +41,7 @@ testthat::test_that("within.teal_data_module modifies the reactive tea_data obje
}
)

tdm2 <- within(tdm, IRIS$id <- seq_len(nrow(IRIS))) # nolint: object_name_linter.
tdm2 <- within(tdm, IRIS$id <- seq_len(nrow(IRIS))) # nolint: object_name.

testthat::expect_no_error(
shiny::testServer(
Expand Down
12 changes: 10 additions & 2 deletions vignettes/bootstrap-themes-in-teal.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

```{r, include=FALSE}
knitr::opts_template$set(
remove_linter_comments = list(tidy = function(code, ...) gsub(pattern = "#\\s?nolint.*", replacement = "", code))
)
```


## Introduction

We offer an easy application of a custom Bootstrap theme in a `teal` app. `teal` uses the `bslib` `R` package which provides tools for customizing Bootstrap themes, including those of `shiny` apps.
Expand Down Expand Up @@ -91,13 +98,14 @@ If you want to update the theme in a regular `shiny::fluidPage`-like app, you do

In this section we provide a step-by-step guide to customizing a `teal` application theme interactively with `bslib::run_with_themer()`. We recommend starting with a simple case and once you are satisfied, verifying with your full application. To that end we will use the `teal` application below. For this example we assume that we want to use Bootstrap 5. To start, we launch the app with `bslib::run_with_themer(app$ui, app$server)` instead of `shiny::shinyApp`.

```{r, eval = FALSE}

```{r, eval = FALSE, opts.label=c("remove_linter_comments")}
options("teal.bs_theme" = bslib::bs_theme(version = "5"))

library(teal)

app <- init(
data = teal_data(IRIS = iris), # nolint
data = teal_data(IRIS = iris), # nolint: line_length.
filter = teal_slices(teal_slice("IRIS", "Sepal.Length", selected = c(5, 7))),
modules = modules(example_module(), example_module()),
header = "My first teal application"
Expand Down
Loading