Skip to content

Commit 400d8cd

Browse files
authored
Adds common @return for modules and corrects linting (#670)
Part of #624 From this #624 (comment) #### Changes description - Adds `@return` tag to `shared_params` to be reused across all documentation - Corrects linter errors
1 parent c57bc17 commit 400d8cd

File tree

9 files changed

+85
-35
lines changed

9 files changed

+85
-35
lines changed

R/tm_g_bivariate.R

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -954,38 +954,67 @@ coloring_ggplot_call <- function(colour,
954954
fill,
955955
size,
956956
is_point = FALSE) {
957-
if (!identical(colour, character(0)) && !identical(fill, character(0)) &&
958-
is_point && !identical(size, character(0))) {
957+
if (
958+
!identical(colour, character(0)) &&
959+
!identical(fill, character(0)) &&
960+
is_point &&
961+
!identical(size, character(0))
962+
) {
959963
substitute(
960964
expr = aes(colour = colour_name, fill = fill_name, size = size_name),
961965
env = list(colour_name = as.name(colour), fill_name = as.name(fill), size_name = as.name(size))
962966
)
963-
} else if (identical(colour, character(0)) && !identical(fill, character(0)) &&
964-
is_point && identical(size, character(0))) {
967+
} else if (
968+
identical(colour, character(0)) &&
969+
!identical(fill, character(0)) &&
970+
is_point &&
971+
identical(size, character(0))
972+
) {
965973
substitute(expr = aes(fill = fill_name), env = list(fill_name = as.name(fill)))
966-
} else if (!identical(colour, character(0)) && !identical(fill, character(0)) &&
967-
(!is_point || identical(size, character(0)))) {
974+
} else if (
975+
!identical(colour, character(0)) &&
976+
!identical(fill, character(0)) &&
977+
(!is_point || identical(size, character(0)))
978+
) {
968979
substitute(
969980
expr = aes(colour = colour_name, fill = fill_name),
970981
env = list(colour_name = as.name(colour), fill_name = as.name(fill))
971982
)
972-
} else if (!identical(colour, character(0)) && identical(fill, character(0)) &&
973-
(!is_point || identical(size, character(0)))) {
983+
} else if (
984+
!identical(colour, character(0)) &&
985+
identical(fill, character(0)) &&
986+
(!is_point || identical(size, character(0)))
987+
) {
974988
substitute(expr = aes(colour = colour_name), env = list(colour_name = as.name(colour)))
975-
} else if (identical(colour, character(0)) && !identical(fill, character(0)) &&
976-
(!is_point || identical(size, character(0)))) {
989+
} else if (
990+
identical(colour, character(0)) &&
991+
!identical(fill, character(0)) &&
992+
(!is_point || identical(size, character(0)))
993+
) {
977994
substitute(expr = aes(fill = fill_name), env = list(fill_name = as.name(fill)))
978-
} else if (identical(colour, character(0)) && identical(fill, character(0)) &&
979-
is_point && !identical(size, character(0))) {
995+
} else if (
996+
identical(colour, character(0)) &&
997+
identical(fill, character(0)) &&
998+
is_point &&
999+
!identical(size, character(0))
1000+
) {
9801001
substitute(expr = aes(size = size_name), env = list(size_name = as.name(size)))
981-
} else if (!identical(colour, character(0)) && identical(fill, character(0)) &&
982-
is_point && !identical(size, character(0))) {
1002+
} else if (
1003+
!identical(colour, character(0)) &&
1004+
identical(fill, character(0)) &&
1005+
is_point &&
1006+
!identical(size, character(0))
1007+
) {
9831008
substitute(
9841009
expr = aes(colour = colour_name, size = size_name),
9851010
env = list(colour_name = as.name(colour), size_name = as.name(size))
9861011
)
987-
} else if (identical(colour, character(0)) && !identical(fill, character(0)) &&
988-
is_point && !identical(size, character(0))) {
1012+
} else if (
1013+
identical(colour, character(0)) &&
1014+
!identical(fill, character(0)) &&
1015+
is_point &&
1016+
!identical(size, character(0))
1017+
) {
9891018
substitute(
9901019
expr = aes(colour = colour_name, fill = fill_name, size = size_name),
9911020
env = list(colour_name = as.name(fill), fill_name = as.name(fill), size_name = as.name(size))

R/tm_g_distribution.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,13 @@ srv_distribution <- function(id,
802802
)
803803
}
804804

805-
if (length(s_var) == 0 && length(g_var) == 0 && main_type_var == "Density" &&
806-
length(t_dist) != 0 && main_type_var == "Density") {
805+
if (
806+
length(s_var) == 0 &&
807+
length(g_var) == 0 &&
808+
main_type_var == "Density" &&
809+
length(t_dist) != 0 &&
810+
main_type_var == "Density"
811+
) {
807812
map_dist <- stats::setNames(
808813
c("dnorm", "dlnorm", "dgamma", "dunif"),
809814
c("normal", "lognormal", "gamma", "unif")

R/tm_g_response.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,8 @@ srv_g_response <- function(id,
368368
# nolint end
369369

370370
plot_call <- substitute(
371-
expr =
372-
ggplot(ANL2, aes(x = x_cl, y = ns)) +
373-
geom_bar(aes(fill = resp_cl), stat = "identity", position = arg_position),
371+
expr = ggplot(ANL2, aes(x = x_cl, y = ns)) +
372+
geom_bar(aes(fill = resp_cl), stat = "identity", position = arg_position),
374373
env = list(
375374
x_cl = x_cl,
376375
resp_cl = resp_cl,

R/tm_g_scatterplot.R

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,13 @@ srv_g_scatterplot <- function(id,
459459
teal.transform::compose_and_enable_validators(iv, selector_list)
460460
})
461461
iv_facet <- shinyvalidate::InputValidator$new()
462-
iv_facet$add_rule("add_density", ~ if (isTRUE(.) &&
463-
(length(selector_list()$row_facet()$select) > 0L ||
464-
length(selector_list()$col_facet()$select) > 0L)) {
462+
iv_facet$add_rule("add_density", ~ if (
463+
isTRUE(.) &&
464+
(
465+
length(selector_list()$row_facet()$select) > 0L ||
466+
length(selector_list()$col_facet()$select) > 0L
467+
)
468+
) {
465469
"Cannot add marginal density when Row or Column facetting has been selected"
466470
})
467471
iv_facet$enable()
@@ -524,8 +528,10 @@ srv_g_scatterplot <- function(id,
524528
observeEvent(
525529
eventExpr = merged$anl_input_r()$columns_source[c("col_facet", "row_facet")],
526530
handlerExpr = {
527-
if (length(merged$anl_input_r()$columns_source$col_facet) == 0 &&
528-
length(merged$anl_input_r()$columns_source$row_facet) == 0) {
531+
if (
532+
length(merged$anl_input_r()$columns_source$col_facet) == 0 &&
533+
length(merged$anl_input_r()$columns_source$row_facet) == 0
534+
) {
529535
shinyjs::hide("free_scales")
530536
} else {
531537
shinyjs::show("free_scales")
@@ -582,9 +588,11 @@ srv_g_scatterplot <- function(id,
582588
\n Uncheck the 'Add marginal density' checkbox to display the plot."
583589
))
584590
validate(need(
585-
!(inherits(ANL[[color_by_var]], "Date") ||
586-
inherits(ANL[[color_by_var]], "POSIXct") ||
587-
inherits(ANL[[color_by_var]], "POSIXlt")),
591+
!(
592+
inherits(ANL[[color_by_var]], "Date") ||
593+
inherits(ANL[[color_by_var]], "POSIXct") ||
594+
inherits(ANL[[color_by_var]], "POSIXlt")
595+
),
588596
"Marginal plots cannot be produced when the points are colored by Date or POSIX variables.
589597
\n Uncheck the 'Add marginal density' checkbox to display the plot."
590598
))

R/tm_missing_data.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,11 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par
554554
# display those previously selected values that are still available
555555
selected <- if (!is.null(prev_choices) && any(prev_choices %in% choices)) {
556556
prev_choices[match(choices[choices %in% prev_choices], prev_choices)]
557-
} else if (!is.null(prev_choices) &&
558-
!any(prev_choices %in% choices) &&
559-
isolate(prev_group_by_var()) == input$group_by_var) {
557+
} else if (
558+
!is.null(prev_choices) &&
559+
!any(prev_choices %in% choices) &&
560+
isolate(prev_group_by_var()) == input$group_by_var
561+
) {
560562
# if not any previously selected value is available and the grouping variable is the same,
561563
# then display NULL
562564
NULL

R/tm_outliers.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,10 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
417417
expr = dplyr::mutate(is_outlier_selected = {
418418
q1_q3 <- stats::quantile(outlier_var_name, probs = c(0.25, 0.75))
419419
iqr <- q1_q3[2] - q1_q3[1]
420-
!(outlier_var_name >= q1_q3[1] - outlier_definition_param * iqr &
421-
outlier_var_name <= q1_q3[2] + outlier_definition_param * iqr)
420+
!(
421+
outlier_var_name >= q1_q3[1] - outlier_definition_param * iqr &
422+
outlier_var_name <= q1_q3[2] + outlier_definition_param * iqr
423+
)
422424
}),
423425
env = list(
424426
outlier_var_name = as.name(outlier_var),

R/tm_t_crosstable.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ srv_t_crosstable <- function(id, data, reporter, filter_panel_api, label, x, y,
283283
substitute(
284284
expr = {
285285
lyt <- basic_tables %>%
286-
split_call %>% # styler: off
286+
split_call %>% # styler: off
287287
rtables::add_colcounts() %>%
288288
tern::analyze_vars(
289289
vars = x_name,

R/utils.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#' @param post_output (`shiny.tag`, optional) with text placed after the output to put the output
2626
#' into context. For example the [shiny::helpText()] elements are useful.
2727
#'
28+
#' @return Object of class `teal_module` to be used in `teal` applications
29+
#'
2830
#' @name shared_params
2931
#' @keywords internal
3032
NULL

man/shared_params.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)