Skip to content

Commit

Permalink
Also knock out '<<-' usage
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed May 5, 2024
1 parent 124664b commit bb2f3e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 2 additions & 5 deletions .ci/.lintr.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ linters = c(dt_linters, all_linters(
# par = NULL,
# setwd = NULL
# )),
undesirable_operator_linter(modify_defaults(
default_undesirable_operators,
`<<-` = NULL
)),
undesirable_operator_linter(),
# TODO(lintr#2441): Use upstream implementation.
assignment_linter = NULL,
absolute_path_linter = NULL, # too many false positives
Expand Down Expand Up @@ -57,7 +54,7 @@ linters = c(dt_linters, all_linters(
strings_as_factors_linter = NULL,
# TODO(lintr->3.2.0): Fix on a valid TODO style, enforce it, and re-activate.
todo_comment_linter = NULL,
# TODO(michaelchirico): Enforce these and re-activate them one-by-one. Also stop using '<<-'.
# TODO(michaelchirico): Enforce these and re-activate them one-by-one.
brace_linter = NULL,
condition_call_linter = NULL,
conjunct_test_linter = NULL,
Expand Down
1 change: 1 addition & 0 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ replace_dot_alias = function(e) {
else if (any(idx <- nm != jvnames))
warningf('Different branches of j expression produced different auto-named columns: %s; using the most "last" names. If this was intentional (e.g., you know only one branch will ever be used in a given query because the branch is controlled by a function argument), please (1) pull this branch out of the call; (2) explicitly provide missing defaults for each branch in all cases; or (3) use the same name for each branch and re-name it in a follow-up call.', brackify(sprintf('%s!=%s', nm[idx], jvnames[idx])))
}
# nolint next: undesirable_operator_linter. Workaround is clunkier, though a bigger refactor could be considered.
jvnames <<- nm # TODO: handle if() list(a, b) else list(b, a) better
setattr(q, "names", NULL) # drops the names from the list so it's faster to eval the j for each group; reinstated at the end on the result.
}
Expand Down
8 changes: 4 additions & 4 deletions R/test.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,18 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
xsub = substitute(x)
ysub = substitute(y)

actual = list("warning"=NULL, "error"=NULL, "message"=NULL)
actual = list2env(list(warning=NULL, error=NULL, message=NULL))
wHandler = function(w) {
# Thanks to: https://stackoverflow.com/a/4947528/403310
actual$warning <<- c(actual$warning, conditionMessage(w))
actual$warning <- c(actual$warning, conditionMessage(w))
invokeRestart("muffleWarning")
}
eHandler = function(e) {
actual$error <<- conditionMessage(e)
actual$error <- conditionMessage(e)
e
}
mHandler = function(m) {
actual$message <<- c(actual$message, conditionMessage(m))
actual$message <- c(actual$message, conditionMessage(m))
m
}
if (is.null(output) && is.null(notOutput)) {
Expand Down

0 comments on commit bb2f3e2

Please sign in to comment.