Skip to content

Commit f2d64a4

Browse files
averissimom7pr
andauthored
Convert "# nolint" to specific rule exception (#178)
# Pull Request <!--- Replace `#nnn` with your issue link for reference. --> Part of #172 #### Changes description - Add new regex style to object_name_linter to account for ADaM variables. - See `.lintr` file - `regexes = c(ANL = "^ANL_?[0-9]*$", ADaM = "^r?ADSL|ADTTE|ADLB|ADRS|ADAE$"))` - Allows for variables named `ANL` with optional underscore and numbers after. - note: can't use groups (`(rule_within_parenthesis)`) due to [r-lib/lintr/issues/2188](r-lib/lintr#2188) not being released yet. - Convert other `# nolint` to specific `# nolint: <rule name>.` for specificity --------- Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Co-authored-by: m7pr <marcin.kosinski.mk1@roche.com>
1 parent 4a1d42c commit f2d64a4

27 files changed

+254
-242
lines changed

.lintr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
linters: linters_with_defaults(
22
line_length_linter = line_length_linter(120),
33
cyclocomp_linter = NULL,
4-
object_usage_linter = NULL
4+
object_usage_linter = NULL,
5+
object_name_linter = object_name_linter(styles = c("snake_case", "symbols"), regexes = c(ANL = "^ANL_?[0-9]*$", ADaM = "^r?AD[A-Z]{2,3}_?[0-9]*$"))
56
)

R/Queue.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#' @name Queue
1818
#' @keywords internal
1919
#'
20-
Queue <- R6::R6Class( # nolint
20+
Queue <- R6::R6Class( # nolint: object_name_linter.
2121
classname = "Queue",
2222
# public methods ----
2323
public = list(

R/choices_labeled.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ variable_choices.character <- function(data, subset = NULL, fill = FALSE, key =
191191

192192
#' @rdname variable_choices
193193
#' @export
194-
variable_choices.data.frame <- function(data, subset = NULL, fill = TRUE, key = NULL) { # nolint
195-
194+
variable_choices.data.frame <- function(data, subset = NULL, fill = TRUE, key = NULL) {
196195
checkmate::assert(
197196
checkmate::check_character(subset, null.ok = TRUE),
198197
checkmate::check_function(subset, null.ok = TRUE)
@@ -316,7 +315,7 @@ value_choices.character <- function(data,
316315

317316
#' @rdname value_choices
318317
#' @export
319-
value_choices.data.frame <- function(data, # nolint
318+
value_choices.data.frame <- function(data,
320319
var_choices,
321320
var_label = NULL,
322321
subset = NULL,

R/choices_selected.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ choices_selected <- function(choices,
191191
#'
192192
#' @export
193193
#'
194-
is.choices_selected <- function(x) { # nolint
194+
is.choices_selected <- function(x) { # nolint: object_name_linter.
195195
inherits(x, "choices_selected")
196196
}
197197

@@ -231,7 +231,7 @@ add_no_selected_choices <- function(x, multiple = FALSE) {
231231
#'
232232
#' @export
233233
#'
234-
no_selected_as_NULL <- function(x) { # nolint
234+
no_selected_as_NULL <- function(x) { # nolint: object_name_linter.
235235
if (is.null(x) || identical(x, no_select_keyword) || x == "") {
236236
NULL
237237
} else {

R/data_extract_module.R

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,16 @@ data_extract_srv.FilteredData <- function(id, datasets, data_extract_spec, ...)
457457
#' `select_validation_rule` but for the choose dataset part of the `data_extract_ui`
458458
#' @export
459459
#'
460-
data_extract_srv.list <- function(id, datasets, data_extract_spec, join_keys = NULL,
460+
data_extract_srv.list <- function(id,
461+
datasets,
462+
data_extract_spec,
463+
join_keys = NULL,
461464
select_validation_rule = NULL,
462465
filter_validation_rule = NULL,
463-
dataset_validation_rule = if (is.null(select_validation_rule) && is.null(filter_validation_rule)) { # nolint
466+
dataset_validation_rule = if (
467+
is.null(select_validation_rule) &&
468+
is.null(filter_validation_rule)
469+
) {
464470
NULL
465471
} else {
466472
shinyvalidate::sv_required("Please select a dataset")
@@ -738,14 +744,20 @@ data_extract_multiple_srv.FilteredData <- function(data_extract, datasets, ...)
738744
#'
739745
#' @export
740746
#'
741-
data_extract_multiple_srv.list <- function(data_extract, datasets, join_keys = NULL,
747+
data_extract_multiple_srv.list <- function(data_extract,
748+
datasets,
749+
join_keys = NULL,
742750
select_validation_rule = NULL,
743751
filter_validation_rule = NULL,
744-
dataset_validation_rule = if (is.null(select_validation_rule) && is.null(filter_validation_rule)) { # nolint
752+
dataset_validation_rule = if (
753+
is.null(select_validation_rule) &&
754+
is.null(filter_validation_rule)
755+
) {
745756
NULL
746757
} else {
747758
shinyvalidate::sv_required("Please select a dataset")
748-
}, ...) {
759+
},
760+
...) {
749761
checkmate::assert_list(datasets, types = c("reactive", "data.frame"), names = "named")
750762
checkmate::assert_class(join_keys, "join_keys", null.ok = TRUE)
751763
checkmate::assert(

R/filter_spec.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ filter_spec_internal <- function(vars_choices,
285285

286286
#' @rdname filter_spec_internal
287287
#' @export
288-
filter_spec_internal.delayed_data <- function(vars_choices, # nolint
288+
filter_spec_internal.delayed_data <- function(vars_choices,
289289
vars_selected = NULL,
290290
vars_label = NULL,
291291
vars_fixed = FALSE,

R/get_dplyr_call.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ get_dplyr_call_data <- function(selector_list, join_keys = teal.data::join_keys(
8282
all_cols
8383
)
8484

85-
pivot_longer_unite_cols_renamed <- if (rlang::is_empty(unite_vals)) { # nolint
85+
pivot_longer_unite_cols_renamed <- if (rlang::is_empty(unite_vals)) { # nolint: object_length_linter.
8686
pivot_longer_cols_renamed
8787
} else {
8888
Reduce(

R/get_merge_call.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ get_merge_call <- function(selector_list,
5757
anl_merge_call_i <- call(
5858
"<-",
5959
as.name(anl_name),
60-
{ # nolint
60+
{
6161
merge_key_i <- get_merge_key_i(idx = idx, dplyr_call_data = dplyr_call_data)
6262
is_merge_key_pair <- vapply(merge_key_i, function(x) length(names(x)) == 1, logical(1))
6363

R/select_spec.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ select_spec <- function(choices,
109109
#' @rdname select_spec
110110
#' @export
111111
#'
112-
select_spec.delayed_data <- function(choices, # nolint
112+
select_spec.delayed_data <- function(choices, # nolint: object_name_linter.
113113
selected = NULL,
114114
multiple = length(selected) > 1,
115115
fixed = FALSE,
@@ -144,7 +144,7 @@ select_spec.delayed_data <- function(choices, # nolint
144144
#' @rdname select_spec
145145
#' @export
146146
#'
147-
select_spec.default <- function(choices, # nolint
147+
select_spec.default <- function(choices, # nolint: object_name_linter.
148148
selected = choices[1],
149149
multiple = length(selected) > 1,
150150
fixed = FALSE,

R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.onLoad <- function(libname, pkgname) { # nolint
1+
.onLoad <- function(libname, pkgname) {
22
teal.logger::register_logger("teal.transform")
33
invisible()
44
}

0 commit comments

Comments
 (0)