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

Cleanup of # nolint comments #1091

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
5 changes: 4 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL,
indentation_linter = NULL
object_name_linter = object_name_linter(
styles = c("snake_case", "symbols"),
regexes = c(ANL = "^ANL_?[0-9A-Z_]*$", ADaM = "^r?AD[A-Z]{2,3}_?[0-9]*$")
)
)
13 changes: 6 additions & 7 deletions R/string_ops.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@
#' )
#' lapply(dta, as_num)
#' @export
as_num <- function(str) { # nolint # nousage
as_num <- function(str) {
UseMethod("as_num")
}

#' @export
#' @rdname as_num
as_num.default <- function(str) { # nolint # nousage
as_num.default <- function(str) {
stop("No default implementation for `as_num.default`.")
}

#' @export
#' @rdname as_num
as_num.character <- function(str) { # nolint # nousage

as_num.character <- function(str) {
y <- regmatches(
x = str,
m = gregexpr(
Expand All @@ -53,21 +52,21 @@ as_num.character <- function(str) { # nolint # nousage

#' @export
#' @rdname as_num
as_num.numeric <- function(str) { # nolint # nousage
as_num.numeric <- function(str) {
return(str)
}

#' @export
#' @rdname as_num
as_num.factor <- function(str) { # nolint # nousage
as_num.factor <- function(str) {
y <- as.character(str)
y <- as_num(y)
return(y)
}

#' @export
#' @rdname as_num
as_num.logical <- function(str) { # nolint # nousage
as_num.logical <- function(str) {
y <- as.numeric(str)
return(y)
}
6 changes: 3 additions & 3 deletions R/tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ srv_mmrm <- function(id,
state_has_changed <- shiny::reactive({
shiny::req(state$input)
displayed_state <- mmrm_inputs_reactive()
equal_ADSL <- all.equal(state$input$adsl_filtered, displayed_state$adsl_filtered) # nolint
equal_ADSL <- all.equal(state$input$adsl_filtered, displayed_state$adsl_filtered) # nolint: object_name.
equal_dataname <- all.equal(state$input$anl_filtered, displayed_state$anl_filtered)
true_means_change <- vapply(
sync_inputs,
Expand Down Expand Up @@ -1292,8 +1292,8 @@ srv_mmrm <- function(id,

anl_m_inputs <- anl_inputs()

ANL <- qenv[["ANL"]] # nolint
ANL_ADSL <- qenv[["ANL_ADSL"]] # nolint
ANL <- qenv[["ANL"]]
ANL_ADSL <- qenv[["ANL_ADSL"]]
paramcd <- unique(ANL[[unlist(paramcd$filter)["vars_selected"]]])

basic_table_args$subtitles <- paste0(
Expand Down
6 changes: 3 additions & 3 deletions R/tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ srv_g_barchart_simple <- function(id,
ggplot2_args = all_ggplot2_args
)

ANL <- count_q()[["ANL"]] # nolint
ANL <- count_q()[["ANL"]]

all_q <- count_q() %>%
teal.code::eval_code(substitute(
Expand Down Expand Up @@ -689,11 +689,11 @@ make_barchart_simple_call <- function(y_name,
# center text and move slightly to the top or to the right (depending on flip axes)
# see https://stackoverflow.com/questions/7263849/what-do-hjust-and-vjust-do-when-making-a-plot-using-ggplot
if (isTRUE(flip_axis)) {
hjust <- if (barlayout == "stacked") 0.5 else -1 # put above bars if not stacked # nolint
hjust <- if (barlayout == "stacked") 0.5 else -1 # put above bars if not stacked
vjust <- 0.5
} else {
hjust <- 0.5
vjust <- if (barlayout == "stacked") 0.5 else -1 # put above bars if not stacked # nolint
vjust <- if (barlayout == "stacked") 0.5 else -1 # put above bars if not stacked
}

plot_args <- c(plot_args, bquote(
Expand Down
2 changes: 1 addition & 1 deletion R/tm_g_ipp.R
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ srv_g_ipp <- function(id,
validate_checks()
anl_m <- anl_inputs()

ANL <- anl_q()[["ANL"]] # nolint
ANL <- anl_q()[["ANL"]]
teal::validate_has_data(ANL, 2)

arm_var <- unlist(arm_var$filter)["vars_selected"]
Expand Down
6 changes: 3 additions & 3 deletions R/tm_g_km.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ ui_g_km <- function(id, ...) {
label = shiny::HTML(
paste(
"p-value method for ",
shiny::span(class = "text-primary", "Coxph"), # nolint
shiny::span(class = "text-primary", "Coxph"),
" (Hazard Ratio)",
sep = ""
)
Expand All @@ -493,7 +493,7 @@ ui_g_km <- function(id, ...) {
label = shiny::HTML(
paste(
"Ties for ",
shiny::span(class = "text-primary", "Coxph"), # nolint
shiny::span(class = "text-primary", "Coxph"),
" (Hazard Ratio)",
sep = ""
)
Expand Down Expand Up @@ -711,7 +711,7 @@ srv_g_km <- function(id,

anl_m <- anl_inputs()

anl <- anl_q()[["ANL"]] # nolint
anl <- anl_q()[["ANL"]]
teal::validate_has_data(anl, 2)

input_xticks <- if (!is.null(input$xticks)) {
Expand Down
2 changes: 1 addition & 1 deletion R/tm_g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ srv_g_lineplot <- function(id,

all_q <- shiny::reactive({
validate_checks()
ANL <- merged$anl_q()[["ANL"]] # nolint
ANL <- merged$anl_q()[["ANL"]]
teal::validate_has_data(ANL, 2)

whiskers_selected <- if ("Lower" %in% input$whiskers) 1 else NULL
Expand Down
4 changes: 2 additions & 2 deletions R/tm_g_pp_adverse_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ srv_g_adverse_events <- function(id,
teal::validate_inputs(iv_r())
anl_m <- anl_inputs()

ANL <- anl_q()[["ANL"]] # nolint
ANL <- anl_q()[["ANL"]]

teal::validate_has_data(ANL[ANL[[patient_col]] == input$patient_id, ], min_nrow = 1)

Expand All @@ -525,7 +525,7 @@ srv_g_adverse_events <- function(id,
substitute(
expr = {
pt_id <- patient_id
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
8 changes: 5 additions & 3 deletions R/tm_g_pp_patient_timeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,10 @@ srv_g_patient_timeline <- function(id,
shiny::validate(
shiny::need(
input$relday_x_axis ||
(sum(stats::complete.cases(p_time_data_pat[, c(aetime_start, aetime_end)])) > 0 ||
sum(stats::complete.cases(p_time_data_pat[, c(dstime_start, dstime_end)])) > 0),
(
sum(stats::complete.cases(p_time_data_pat[, c(aetime_start, aetime_end)])) > 0 ||
sum(stats::complete.cases(p_time_data_pat[, c(dstime_start, dstime_end)])) > 0
),
"Selected patient is not in dataset (either due to filtering or missing values). Consider relaxing filters."
)
)
Expand Down Expand Up @@ -890,7 +892,7 @@ srv_g_patient_timeline <- function(id,
anl_q(),
substitute(
expr = {
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
2 changes: 1 addition & 1 deletion R/tm_g_pp_therapy.R
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ srv_g_therapy <- function(id,
substitute(
expr = {
pt_id <- patient_id
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
2 changes: 1 addition & 1 deletion R/tm_g_pp_vitals.R
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ srv_g_vitals <- function(id,
merged$anl_q(),
substitute(
expr = {
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
8 changes: 4 additions & 4 deletions R/tm_t_abnormality_by_worst_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#'
#' @seealso [tm_t_abnormality_by_worst_grade()]
#' @keywords internal
template_abnormality_by_worst_grade <- function(parentname, # nolint
template_abnormality_by_worst_grade <- function(parentname, # nolint: object_length.
dataname,
arm_var,
id_var = "USUBJID",
Expand Down Expand Up @@ -291,7 +291,7 @@ template_abnormality_by_worst_grade <- function(parentname, # nolint
#' shinyApp(app$ui, app$server)
#' }
#'
tm_t_abnormality_by_worst_grade <- function(label, # nolint
tm_t_abnormality_by_worst_grade <- function(label, # nolint: object_length.
dataname,
parentname = ifelse(
inherits(arm_var, "data_extract_spec"),
Expand Down Expand Up @@ -383,7 +383,7 @@ tm_t_abnormality_by_worst_grade <- function(label, # nolint
}

#' @keywords internal
ui_t_abnormality_by_worst_grade <- function(id, ...) { # nolint
ui_t_abnormality_by_worst_grade <- function(id, ...) { # nolint: object_length.

ns <- shiny::NS(id)
a <- list(...) # module args
Expand Down Expand Up @@ -480,7 +480,7 @@ ui_t_abnormality_by_worst_grade <- function(id, ...) { # nolint
}

#' @keywords internal
srv_t_abnormality_by_worst_grade <- function(id, # nolint
srv_t_abnormality_by_worst_grade <- function(id, # nolint: object_length.
data,
reporter,
filter_panel_api,
Expand Down
4 changes: 2 additions & 2 deletions R/tm_t_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ srv_ancova <- function(id,
"ANCOVA table cannot be calculated as all values are missing."
))
# check that for each visit there is at least one record with no missing data
all_NA_dataset <- merged$anl_q()[["ANL"]] %>% # nolint
all_NA_dataset <- merged$anl_q()[["ANL"]] %>% # nolint: object_name.
dplyr::group_by(dplyr::across(dplyr::all_of(c(input_avisit, input_arm_var)))) %>%
dplyr::summarize(all_NA = all(is.na(.data[[input_aval_var]])))
shiny::validate(shiny::need(
Expand Down Expand Up @@ -888,7 +888,7 @@ srv_ancova <- function(id,
# The R-code corresponding to the analysis.
table_q <- shiny::reactive({
validate_checks()
ANL <- merged$anl_q()[["ANL"]] # nolint
ANL <- merged$anl_q()[["ANL"]]

label_paramcd <- get_paramcd_label(ANL, paramcd)
input_aval <- as.vector(merged$anl_input_r()$columns_source$aval_var)
Expand Down
2 changes: 1 addition & 1 deletion R/tm_t_coxreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ srv_t_coxreg <- function(id,
all_q <- shiny::reactive({
validate_checks()

ANL <- merged$anl_q()[["ANL"]] # nolint
ANL <- merged$anl_q()[["ANL"]]
paramcd <- as.character(unique(ANL[[unlist(paramcd$filter)["vars_selected"]]]))
multivariate <- input$type == "Multivariate"
strata_var <- as.vector(merged$anl_input_r()$columns_source$strata_var)
Expand Down
2 changes: 1 addition & 1 deletion R/tm_t_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ srv_t_events_byterm <- function(id,
# The R-code corresponding to the analysis.
table_q <- shiny::reactive({
validate_checks()
ANL <- merged$anl_q()[["ANL"]] # nolint
ANL <- merged$anl_q()[["ANL"]]

input_hlt <- as.vector(merged$anl_input_r()$columns_source$hlt)
input_llt <- as.vector(merged$anl_input_r()$columns_source$llt)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_t_events_by_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,10 @@ srv_t_events_by_grade <- function(id,
shiny::need(
is.factor(anl_filtered[[input_grade]]) &&
all(as.character(unique(anl_filtered[[input_grade]])) %in% as.character(c(1:5))),
"Data includes records with grade levels outside of 1-5. Please use filter panel to exclude from analysis in order to display grade grouping in nested columns." # nolint
paste(
"Data includes records with grade levels outside of 1-5.",
"Please use filter panel to exclude from analysis in order to display grade grouping in nested columns."
)
)
)
} else {
Expand All @@ -1141,7 +1144,7 @@ srv_t_events_by_grade <- function(id,
# The R-code corresponding to the analysis.
table_q <- shiny::reactive({
validate_checks()
ANL <- merged$anl_q()[["ANL"]] # nolint
ANL <- merged$anl_q()[["ANL"]]

input_hlt <- as.vector(merged$anl_input_r()$columns_source$hlt)
input_llt <- as.vector(merged$anl_input_r()$columns_source$llt)
Expand Down
4 changes: 2 additions & 2 deletions R/tm_t_events_patyear.R
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ srv_events_patyear <- function(id,
table_q <- shiny::reactive({
validate_checks()

ANL <- merged$anl_q()[["ANL"]] # nolint
ANL <- merged$anl_q()[["ANL"]]
label_paramcd <- get_paramcd_label(ANL, paramcd)

my_calls <- template_events_patyear(
Expand All @@ -525,7 +525,7 @@ srv_events_patyear <- function(id,
total_label = total_label,
na_level = na_level,
control = control_incidence_rate(
conf_level = as.numeric(input$conf_level), # nolint
conf_level = as.numeric(input$conf_level),
conf_type = if (input$conf_method == "Normal (rate)") {
"normal"
} else if (input$conf_method == "Normal (log rate)") {
Expand Down
8 changes: 4 additions & 4 deletions R/tm_t_logistic.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ template_logistic <- function(dataname,
data_list <- add_expr(
data_list,
substitute(
expr = ANL <- data_pipe, # nolint
expr = ANL <- data_pipe,
env = list(data_pipe = pipe_expr(data_pipe))
)
)
Expand All @@ -96,7 +96,7 @@ template_logistic <- function(dataname,
data_list <- add_expr(
data_list,
substitute(
expr = ANL <- df %>% # nolint
expr = ANL <- df %>%
dplyr::mutate(Response = aval_var %in% responder_val) %>%
df_explicit_na(na_level = "_NA_"),
env = list(df = as.name("ANL"), aval_var = as.name(aval_var), responder_val = responder_val)
Expand All @@ -107,7 +107,7 @@ template_logistic <- function(dataname,

if (!is.null(arm_var)) {
y$relabel <- substitute(
expr = teal.data::col_labels(ANL[arm_var]) <- arm_var_lab, # nolint
expr = teal.data::col_labels(ANL[arm_var]) <- arm_var_lab,
env = list(arm_var = arm_var)
)
}
Expand Down Expand Up @@ -658,7 +658,7 @@ srv_t_logistic <- function(id,
all_q <- shiny::reactive({
validate_checks()

ANL <- merged$anl_q()[["ANL"]] # nolint
ANL <- merged$anl_q()[["ANL"]]

label_paramcd <- get_paramcd_label(ANL, paramcd)

Expand Down
2 changes: 1 addition & 1 deletion R/tm_t_mult_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ template_mult_events <- function(dataname,

lbl_lst <- add_expr(
lbl_lst,
substitute( # nolint
substitute(
expr = attr(dataname$hlt_new, which = "label"),
env = list(
dataname = as.name(dataname),
Expand Down
2 changes: 1 addition & 1 deletion R/tm_t_pp_basic_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ srv_t_basic_info <- function(id,
substitute(
expr = {
pt_id <- patient_id
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
2 changes: 1 addition & 1 deletion R/tm_t_pp_laboratory.R
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ srv_g_laboratory <- function(id,
substitute(
expr = {
pt_id <- patient_id
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
2 changes: 1 addition & 1 deletion R/tm_t_pp_medical_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ srv_t_medical_history <- function(id,
anl_q(),
substitute(
expr = {
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
2 changes: 1 addition & 1 deletion R/tm_t_pp_prior_medication.R
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ srv_t_prior_medication <- function(id,
teal.code::eval_code(
substitute(
expr = {
ANL <- ANL[ANL[[patient_col]] == patient_id, ] # nolint
ANL <- ANL[ANL[[patient_col]] == patient_id, ]
}, env = list(
patient_col = patient_col,
patient_id = patient_id()
Expand Down
Loading
Loading