Skip to content

Commit

Permalink
Address lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-ebs-ext committed Dec 1, 2024
1 parent 629a179 commit c7380e1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
21 changes: 21 additions & 0 deletions .lintr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
linters <- lintr::default_linters # -[ diff with dv.templates 3ca8d7a10cfc7ad2307644dcac603e1f1f0feb72]-
linters <- lintr::modify_defaults(
linters
, line_length_linter = NULL # we see how long lines are when we write them
, indentation_linter = NULL
, trailing_whitespace_linter = NULL
, cyclocomp_linter = NULL # prevents trivial amount of nesting and long but straightforward functions
, object_name_linter = NULL # we have reasons to capitalize. nobody in our team CamelCase. shiny does
, object_length_linter = NULL # we don't type long var names just because
, pipe_continuation_linter = NULL # wickham being overly prescriptive
, trailing_blank_lines_linter = NULL # natural extension of trailing_whitespace_linter, present on the template
)

if(identical(Sys.getenv('CI'), "true")){
linters <- lintr::modify_defaults(
linters
, object_usage_linter = NULL # R lacks var declarations; it's easy to assign to the wrong variable by mistake
) # We only disable this lint rule on github because it fails there because
} # of a long-standing lintr bug

linters
2 changes: 1 addition & 1 deletion R/mock_local_filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mock_local_filter_server <- function(input, output, session) {
data_list$adae <- data_list$adae %>%
dplyr::mutate(
# Note: conversion below is only for mock purpose and changes the data
AEREL = dplyr::if_else(AEREL == "NONE", "N", "Y")
AEREL = dplyr::if_else(.data[["AEREL"]] == "NONE", "N", "Y")
)
data_list <- purrr::set_names(names(data_list)) %>%
purrr::map(function(x) {
Expand Down
19 changes: 9 additions & 10 deletions R/mod_clinical_timelines.R
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,13 @@ mod_clinical_timelines_API_spec <- TC$group(
trt_start_var = TC$col("subject_level_dataset_name", TC$or(TC$date(), TC$datetime())),
trt_end_var = TC$col("subject_level_dataset_name", TC$or(TC$date(), TC$datetime())),
icf_date_var = TC$col("subject_level_dataset_name", TC$or(TC$date(), TC$datetime()))
) |> TC$flag('ignore'),
mapping = TC$group() |> TC$flag('ignore'),
drug_admin = TC$group() |> TC$flag('ignore'),
filter = TC$group() |> TC$flag('ignore'),
subjid_var = TC$character() |> TC$flag("optional", "ignore"), # TODO: TC$col("subject_level_dataset_name", TC$or(TC$factor(), TC$character())) |> TC$flag("subjid_var"),
default_plot_settings = TC$group() |> TC$flag('ignore'),
ms = TC$group() |> TC$flag('ignore'),
) |> TC$flag("ignore"),
mapping = TC$group() |> TC$flag("ignore"),
drug_admin = TC$group() |> TC$flag("ignore"),
filter = TC$group() |> TC$flag("ignore"),
subjid_var = TC$character() |> TC$flag("optional", "ignore"), # TODO: Maybe TC$col("subject_level_dataset_name", TC$or(TC$factor(), TC$character())) |> TC$flag("subjid_var"),
default_plot_settings = TC$group() |> TC$flag("ignore"),
ms = TC$group() |> TC$flag("ignore"),
receiver_id = TC$character() |> TC$flag("optional", "ignore")
) |> TC$attach_docs(mod_clinical_timelines_API_docs)

Expand All @@ -538,15 +538,14 @@ dataset_info_clinical_timelines <- function(basic_info, mapping, filter, ...) {
}

check_mod_clinical_timelines <- function(
afmm, datasets, module_id, basic_info, mapping, drug_admin, filter, subjid_var, default_plot_settings, ms, receiver_id
) {
afmm, datasets, module_id, basic_info, mapping, drug_admin, filter, subjid_var, default_plot_settings, ms, receiver_id) {
warn <- CM$container()
err <- CM$container()

# TODO: Replace this function with a generic one that performs the checks based on mod_clinical_timelines_API_spec.
# Something along the lines of OK <- CM$check_API(mod_clinical_timelines_API_spec, args = match.call(), warn, err)

OK <- check_mod_clinical_timelines_auto(
OK <- check_mod_clinical_timelines_auto( # nolint
afmm, datasets,
module_id, basic_info, mapping, drug_admin, filter, subjid_var, default_plot_settings, ms, receiver_id,
warn, err
Expand Down
2 changes: 1 addition & 1 deletion R/mod_main_view.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ mod_main_view_server <- function(module_id, initial_data, changed,
# (which is produced by a ggplot2 internal function)
ggdata_y <- create_ggdata_y(plot_obj()$plot, input$plot_hover)

hover_info <- create_hover_info(
hover_info <- create_hover_info( # nolint
input$plot_hover,
ggdata_y,
initial_data(),
Expand Down
2 changes: 1 addition & 1 deletion R/server_functions_local_filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ get_filter_status <- function(all_filters, chosen_filters) {
#' @keywords internal
set_pts <- function(status_filters, soc, prepped_data, filter) {
if (status_filters[["soc"]] && !is.null(soc)) {
pt_choices <- prepped_data %>%
pt_choices <- prepped_data %>% # nolint
dplyr::filter(.data[[filter$soc_var]] %in% soc) %>%
dplyr::select(tidyselect::all_of(filter$pref_term_var)) %>%
dplyr::distinct() %>%
Expand Down
10 changes: 5 additions & 5 deletions R/server_functions_main_view.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ color_lookup <- function(groups) {
#'
create_plot_data <- function(work_data, time_range, filter_event) {
if (lubridate::is.timepoint(time_range)) {
first <- "start_dt_var"
last <- "end_dt_var"
first_exp <- "start_exp"
last_exp <- "end_exp"
first <- "start_dt_var" # nolint
last <- "end_dt_var" # nolint
first_exp <- "start_exp" # nolint
last_exp <- "end_exp" # nolint
} else {
first <- "start_dy_var"
last <- "end_dy_var"
Expand Down Expand Up @@ -429,7 +429,7 @@ create_tooltip <- function(hover, y_screen_pct) {
# Calculate cursor position as percent
left_pct <- (hover$x - hover$domain$left) /
(hover$domain$right - hover$domain$left)
top_pct <- (hover$domain$top - hover$y) /
top_pct <- (hover$domain$top - hover$y) / # nolint
(hover$domain$top - hover$domain$bottom)

# Distance from left and top side of the picture in pixels
Expand Down

0 comments on commit c7380e1

Please sign in to comment.