From 67c456c816a3d56fbfbfbb0305276e5b262f25c9 Mon Sep 17 00:00:00 2001 From: jimbrig Date: Wed, 28 Aug 2024 13:45:48 +0000 Subject: [PATCH] Style code (GHA) --- R/utils_css.R | 5 +---- R/utils_html.R | 12 ++---------- R/utils_js.R | 1 - R/utils_reactivity.R | 3 --- R/utils_schemas.R | 10 ++-------- R/utils_text.R | 1 - R/utils_urls.R | 1 - data-raw/entrata.R | 1 - data-raw/entrata/entrata_endpoints.R | 19 ++++++++----------- data-raw/internal.R | 1 - data-raw/schemas.R | 24 ++++++++++-------------- tests/spelling.R | 9 ++++++--- tests/testthat/setup.R | 1 - tests/testthat/test-entrata_request.R | 2 -- tests/testthat/test-verify_css.R | 5 +++-- 15 files changed, 32 insertions(+), 63 deletions(-) diff --git a/R/utils_css.R b/R/utils_css.R index 8ab32d0..7b8de1a 100644 --- a/R/utils_css.R +++ b/R/utils_css.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : CSS Utilities @@ -29,7 +28,6 @@ #' @importFrom glue glue #' @importFrom shiny isolate verify_css <- function(selector, css) { - css_props <- jsonlite::toJSON(css, auto_unbox = TRUE) js <- glue::glue(" @@ -51,8 +49,7 @@ verify_css <- function(selector, css) { }} }} return true; - }})();" - ) + }})();") result <- shiny::isolate(shinyjs::runjs(js)) diff --git a/R/utils_html.R b/R/utils_html.R index d016c74..e28a1bf 100644 --- a/R/utils_html.R +++ b/R/utils_html.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : HTML Utilities @@ -44,12 +43,11 @@ centered <- function(...) { #' @importFrom htmltools tags HTML #' @importFrom shiny icon help_mark <- function(help_txt) { - htmltools::tagList( htmltools::tags$head( htmltools::tags$style( htmltools::HTML( - ".helper { + ".helper { display: inline-block; position: relative; margin-left: 0.5em; @@ -78,7 +76,7 @@ help_mark <- function(help_txt) { .helper:hover::after { display: block; }" - ) + ) ) ), htmltools::tags$div( @@ -87,7 +85,6 @@ help_mark <- function(help_txt) { `data-help` = help_txt ) ) - } #' @rdname utils_html @@ -100,8 +97,3 @@ help_label <- function(label_text, help_text) { help_mark(help_text) ) } - - - - - diff --git a/R/utils_js.R b/R/utils_js.R index 169c245..11829b9 100644 --- a/R/utils_js.R +++ b/R/utils_js.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : JavaScript Utilities diff --git a/R/utils_reactivity.R b/R/utils_reactivity.R index 5c306f1..3dd4f25 100644 --- a/R/utils_reactivity.R +++ b/R/utils_reactivity.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : Reactivity Utilities @@ -32,7 +31,6 @@ #' # create a reactive trigger #' trigger <- make_reactive_trigger(dev = TRUE, label = "my_trigger") make_reactive_trigger <- function(dev = FALSE, label = "") { - rv <- shiny::reactiveValues(a = 0) list( @@ -46,5 +44,4 @@ make_reactive_trigger <- function(dev = FALSE, label = "") { rv$a <- shiny::isolate(rv$a + 1) } ) - } diff --git a/R/utils_schemas.R b/R/utils_schemas.R index ebb1115..2ae8349 100644 --- a/R/utils_schemas.R +++ b/R/utils_schemas.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : Schema (JSON/YAML) Utilities @@ -9,7 +8,6 @@ write_json_schema <- function(schema, path) { - json <- jsonlite::toJSON(schema, auto_unbox = TRUE) |> jsonlite::prettify() @@ -21,23 +19,19 @@ write_json_schema <- function(schema, path) { write(json, file = path) return(invisible(path)) - } yaml_to_json <- function(yaml) { - yaml <- yaml_to_list(yaml) json <- jsonlite::toJSON(yaml, auto_unbox = TRUE) |> jsonlite::prettify() return(json) - } yaml_to_list <- function(yaml) { - - if (!ymlthis:::is_yml(yaml)) + if (!ymlthis:::is_yml(yaml)) { return(yaml) - + } } diff --git a/R/utils_text.R b/R/utils_text.R index 5eb8d91..1875297 100644 --- a/R/utils_text.R +++ b/R/utils_text.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : Text Utilities diff --git a/R/utils_urls.R b/R/utils_urls.R index a93f770..368dbed 100644 --- a/R/utils_urls.R +++ b/R/utils_urls.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : URL Utilities diff --git a/data-raw/entrata.R b/data-raw/entrata.R index a62ce7a..7185238 100644 --- a/data-raw/entrata.R +++ b/data-raw/entrata.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : Entrata Data Preparation diff --git a/data-raw/entrata/entrata_endpoints.R b/data-raw/entrata/entrata_endpoints.R index c3dd10a..d9b57e3 100644 --- a/data-raw/entrata/entrata_endpoints.R +++ b/data-raw/entrata/entrata_endpoints.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : Entrata Endpoints Data Preparation @@ -250,19 +249,17 @@ entrata_api_request_endpoint_methods <- tibble::enframe( tidyr::unnest(cols = c(method)) |> dplyr::left_join( y = tibble::enframe( - important_entrata_request_endpoint_methods, - name = "endpoint", - value = "method" - ) |> - tidyr::unnest(cols = c(method)) |> - dplyr::mutate( - important = TRUE - ), + important_entrata_request_endpoint_methods, + name = "endpoint", + value = "method" + ) |> + tidyr::unnest(cols = c(method)) |> + dplyr::mutate( + important = TRUE + ), by = c("endpoint", "method") ) |> dplyr::mutate( important = dplyr::coalesce(important, FALSE) ) |> dplyr::arrange(dplyr::desc(important)) - - diff --git a/data-raw/internal.R b/data-raw/internal.R index 3d6423c..774a382 100644 --- a/data-raw/internal.R +++ b/data-raw/internal.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : Internal Package Data Preparations diff --git a/data-raw/schemas.R b/data-raw/schemas.R index ecd2a31..89d585a 100644 --- a/data-raw/schemas.R +++ b/data-raw/schemas.R @@ -1,4 +1,3 @@ - # ------------------------------------------------------------------------ # # Title : Schemas Data Preparation @@ -14,19 +13,16 @@ # db config --------------------------------------------------------------- db_config_schema <- list( - host = "", - port = 5432, - dbname = "", - user = "", - password = "", - url = "", - sslmode = "" + host = "", + port = 5432, + dbname = "", + user = "", + password = "", + url = "", + sslmode = "" ) -db_config_schema |> jsonlite::toJSON(auto_unbox = TRUE) |> - - - -jsonlite::toJSON(db_config_schema, pretty = TRUE) |> +db_config_schema |> + jsonlite::toJSON(auto_unbox = TRUE) |> + jsonlite::toJSON(db_config_schema, pretty = TRUE) |> cat(file = "data-raw/meta/schemas/config.db.schema.json") - diff --git a/tests/spelling.R b/tests/spelling.R index 6713838..13f77d9 100644 --- a/tests/spelling.R +++ b/tests/spelling.R @@ -1,3 +1,6 @@ -if(requireNamespace('spelling', quietly = TRUE)) - spelling::spell_check_test(vignettes = TRUE, error = FALSE, - skip_on_cran = TRUE) +if (requireNamespace("spelling", quietly = TRUE)) { + spelling::spell_check_test( + vignettes = TRUE, error = FALSE, + skip_on_cran = TRUE + ) +} diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 4e17af6..8dcee03 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,4 +1,3 @@ - # setup ------------------------------------------------------------------- library(httr2) diff --git a/tests/testthat/test-entrata_request.R b/tests/testthat/test-entrata_request.R index d3c6f7e..ef01bd0 100644 --- a/tests/testthat/test-entrata_request.R +++ b/tests/testthat/test-entrata_request.R @@ -1,4 +1,3 @@ - httptest2::with_mock_dir( dir = "status", test_that("Can ping API status endpoint", { @@ -23,4 +22,3 @@ httptest2::with_mock_api({ expect_equal(res$status_code, 200) }) }) - diff --git a/tests/testthat/test-verify_css.R b/tests/testthat/test-verify_css.R index f1e17d0..4866302 100644 --- a/tests/testthat/test-verify_css.R +++ b/tests/testthat/test-verify_css.R @@ -1,4 +1,6 @@ -mock_runjs <- function(js_code) { TRUE } +mock_runjs <- function(js_code) { + TRUE +} # Tests for verify_css function test_that("verify_css function works as implemented", { @@ -20,4 +22,3 @@ test_that("verify_css function works as implemented", { verify_css(".helper", list("margin-left" = "2px", "margin-right" = "2px", "color" = "red")) ) }) -