Skip to content

Commit 9165924

Browse files
consistently use "=" for assignment
1 parent 770e80b commit 9165924

File tree

17 files changed

+53
-52
lines changed

17 files changed

+53
-52
lines changed

.ci/.lintr.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ linters = c(dt_linters, all_linters(
2626
# setwd = NULL
2727
# )),
2828
undesirable_operator_linter(),
29-
# TODO(lintr#2441): Use upstream implementation.
30-
assignment_linter = NULL,
29+
# TODO(lintr#2765): Use upstream implementation.
30+
# assignment_linter(operator = "="),
3131
absolute_path_linter = NULL, # too many false positives
3232
# TODO(lintr#2442): Use this once x[ , j, by] is supported.
3333
commas_linter = NULL,
@@ -84,7 +84,8 @@ exclusions = c(local({
8484
infix_spaces_linter = Inf,
8585
undesirable_function_linter = Inf
8686
)),
87-
exclusion_for_dir(c("vignettes", "vignettes/fr"), list(
87+
exclusion_for_dir(c("vignettes", "vignettes/fr", "vignettes/ru"), list(
88+
# assignment_linter = Inf,
8889
implicit_integer_linter = Inf,
8990
quotes_linter = Inf,
9091
sample_int_linter = Inf

R/IDateTime.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@ rep.ITime = function(x, ...)
235235
y
236236
}
237237

238-
round.ITime <- function(x, digits = c("hours", "minutes"), ...)
238+
round.ITime = function(x, digits = c("hours", "minutes"), ...)
239239
{
240240
(setattr(switch(match.arg(digits),
241241
hours = as.integer(round(unclass(x)/3600.0)*3600.0),
242242
minutes = as.integer(round(unclass(x)/60.0)*60.0)),
243243
"class", "ITime"))
244244
}
245245

246-
trunc.ITime <- function(x, units = c("hours", "minutes"), ...)
246+
trunc.ITime = function(x, units = c("hours", "minutes"), ...)
247247
{
248248
(setattr(switch(match.arg(units),
249249
hours = as.integer(unclass(x)%/%3600.0*3600.0),

R/as.data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ as.data.table.matrix = function(x, keep.rownames=FALSE, key=NULL, ...) {
6363
for (i in ic) value[[i]] = x[, i] # <strike>for efficiency.</strike> For consistency - data.table likes and prefers "character"
6464
}
6565
else {
66-
for (i in ic) value[[i]] <- as.vector(x[, i]) # to drop any row.names that would otherwise be retained inside every column of the data.table
66+
for (i in ic) value[[i]] = as.vector(x[, i]) # to drop any row.names that would otherwise be retained inside every column of the data.table
6767
}
6868
col_labels = dimnames(x)[[2L]]
6969
setDT(value)

R/between.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ between = function(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE)
6060
y = eval.parent(ysub)
6161
}
6262
if ((l <- length(y)) != 2L) {
63-
suggestion <- if (ysub %iscall% 'c') gettextf("Perhaps you meant %s? ", capture.output(print(`[[<-`(ysub, 1L, quote(list))))) else ""
63+
suggestion = if (ysub %iscall% 'c') gettextf("Perhaps you meant %s? ", capture.output(print(`[[<-`(ysub, 1L, quote(list))))) else ""
6464
stopf("RHS has length() %d; expecting length 2. %sThe first element should be the lower bound(s); the second element should be the upper bound(s).", l, suggestion)
6565
}
6666
between(x, y[[1L]], y[[2L]], incbounds=TRUE)

R/cedta.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ cedta.pkgEvalsUserCode = c("gWidgetsWWW","statET","FastRWeb","slidify","rmarkdow
2828

2929
# nocov start: very hard to reach this within our test suite -- the call stack within a call generated by e.g. knitr
3030
# for loop, not any(vapply_1b(.)), to allow early exit
31-
.any_eval_calls_in_stack <- function() {
31+
.any_eval_calls_in_stack = function() {
3232
calls = sys.calls()
3333
# likelier to be close to the end of the call stack, right?
3434
for (ii in length(calls):1) { # nolint: seq_linter. rev(seq_len(length(calls)))? See https://bugs.r-project.org/show_bug.cgi?id=18406.
35-
the_call <- calls[[ii]][[1L]]
35+
the_call = calls[[ii]][[1L]]
3636
if (is.name(the_call) && (the_call %chin% c("eval", "evalq"))) return(TRUE)
3737
}
3838
FALSE

R/data.table.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ replace_dot_alias = function(e) {
108108
# eval(parse()) to avoid "no visible binding for global variable" note from R CMD check
109109
# names starting with _ don't parse, so no leading _ in the name
110110
)
111-
idx <- regexpr(missing_obj_fmt, err$message, perl=TRUE)
111+
idx = regexpr(missing_obj_fmt, err$message, perl=TRUE)
112112
if (idx > 0L) {
113113
start = attr(idx, "capture.start", exact=TRUE)[ , "obj_name"]
114114
used = substr(
@@ -703,7 +703,7 @@ replace_dot_alias = function(e) {
703703
names(..syms) = ..syms
704704
j = eval(jsub, lapply(substr(..syms, 3L, nchar(..syms)), get, pos=parent.frame()), parent.frame())
705705
}
706-
if (is.logical(j)) j <- which(j)
706+
if (is.logical(j)) j = which(j)
707707
if (!length(j) && !notj) return( null.data.table() )
708708
if (is.factor(j)) j = as.character(j) # fix for FR: #358
709709
if (is.character(j)) {
@@ -1138,7 +1138,7 @@ replace_dot_alias = function(e) {
11381138
if (!all(named_idx <- nzchar(lhs))) {
11391139
# friendly error for common case: trailing terminal comma
11401140
n_lhs = length(lhs)
1141-
this_call <- if (root == "let") "let" else "`:=`"
1141+
this_call = if (root == "let") "let" else "`:=`"
11421142
.check_nested_walrus(jsub, which(!named_idx)+1L, this_call)
11431143
if (!named_idx[n_lhs] && all(named_idx[-n_lhs])) {
11441144
stopf("In %s(col1=val1, col2=val2, ...) form, all arguments must be named, but the last argument has no name. Did you forget a trailing comma?", this_call)
@@ -1288,7 +1288,7 @@ replace_dot_alias = function(e) {
12881288
# warningf(sym," in j is looking for ",getName," in calling scope, but a column '", sym, "' exists. Column names should not start with ..")
12891289
}
12901290
getName = substr(sym, 3L, nchar(sym))
1291-
getNameVal <- get0(getName, parent.frame())
1291+
getNameVal = get0(getName, parent.frame())
12921292
if (is.null(getNameVal)) {
12931293
if (exists(sym, parent.frame())) next # user did 'manual' prefix; i.e. variable in calling scope has .. prefix
12941294
stopf("Variable '%s' is not found in calling scope. Looking in calling scope because this symbol was prefixed with .. in the j= parameter.", getName)
@@ -2166,8 +2166,8 @@ as.matrix.data.table = function(x, rownames=NULL, rownames.value=NULL, ...) {
21662166
internal_error("length(X)==%d but a dimension is zero", length(X)) # nocov
21672167
return(array(if (is.null(X)) NA else X, dim = dm, dimnames = list(rownames.value, cn)))
21682168
}
2169-
dim(X) <- c(n, length(X)/n)
2170-
dimnames(X) <- list(rownames.value, unlist(collabs, use.names = FALSE))
2169+
dim(X) = c(n, length(X)/n)
2170+
dimnames(X) = list(rownames.value, unlist(collabs, use.names = FALSE))
21712171
X
21722172
}
21732173

@@ -2454,7 +2454,7 @@ split.data.table = function(x, f, drop = FALSE, by, sorted = FALSE, keep.by = TR
24542454
# same as split.data.frame - handling all exceptions, factor orders etc, in a single stream of processing was a nightmare in factor and drop consistency
24552455
# evaluate formula mirroring split.data.frame #5392. Mimics base::.formula2varlist.
24562456
if (inherits(f, "formula"))
2457-
f <- eval(attr(terms(f), "variables"), x, environment(f))
2457+
f = eval(attr(terms(f), "variables"), x, environment(f))
24582458
# be sure to use x[ind, , drop = FALSE], not x[ind], in case downstream methods don't follow the same subsetting semantics (#5365)
24592459
return(lapply(split(x = seq_len(nrow(x)), f = f, drop = drop, ...), function(ind) x[ind, , drop = FALSE]))
24602460
}
@@ -2559,7 +2559,7 @@ copy = function(x) {
25592559
## get correct key if cols are present
25602560
cols = names(x)[cols]
25612561
keylength = which.first(!key(ans) %chin% cols) - 1L
2562-
if (is.na(keylength)) keylength <- length(key(ans))
2562+
if (is.na(keylength)) keylength = length(key(ans))
25632563
if (!keylength) {
25642564
setattr(ans, "sorted", NULL) ## no key remaining
25652565
} else {
@@ -3086,9 +3086,9 @@ gweighted.mean = function(x, w, ..., na.rm=FALSE) {
30863086
if (missing(w)) gmean(x, na.rm)
30873087
else {
30883088
if (na.rm) { # take those indices out of the equation by setting them to 0
3089-
ix <- is.na(x)
3090-
x[ix] <- 0.0
3091-
w[ix] <- 0.0
3089+
ix = is.na(x)
3090+
x[ix] = 0.0
3091+
w[ix] = 0.0
30923092
}
30933093
gsum((w!=0.0)*x*w, na.rm=FALSE)/gsum(w, na.rm=FALSE)
30943094
}
@@ -3157,7 +3157,7 @@ is_constantish = function(q, check_singleton=FALSE) {
31573157

31583158
# Check for na.rm= in expr in the expected slot; allows partial matching and
31593159
# is robust to unnamed expr. Note that NA names are not possible here.
3160-
.arg_is_narm <- function(expr, which=3L) !is.null(nm <- names(expr)[which]) && startsWith(nm, "na")
3160+
.arg_is_narm = function(expr, which=3L) !is.null(nm <- names(expr)[which]) && startsWith(nm, "na")
31613161

31623162
.gforce_ok = function(q, x) {
31633163
if (is.N(q)) return(TRUE) # For #334

R/fcast.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ guess = function(x) {
88
var
99
}
1010

11-
dcast <- function(
11+
dcast = function(
1212
data, formula, fun.aggregate = NULL, ..., margins = NULL,
1313
subset = NULL, fill = NULL, value.var = guess(data)
1414
) {
@@ -115,7 +115,7 @@ aggregate_funs = function(funs, vals, sep="_", ...) {
115115
if (is.null(nm) || !nzchar(nm)) {
116116
nm = all.names(funs[[i]], max.names=1L, functions=TRUE)
117117
}
118-
if (!length(nm)) nm <- paste0("fun", i)
118+
if (!length(nm)) nm = paste0("fun", i)
119119
construct_funs(funs[i], nm, vals[[i]])
120120
})
121121
as.call(c(quote(list), unlist(ans)))
@@ -185,7 +185,7 @@ dcast.data.table = function(data, formula, fun.aggregate = NULL, sep = "_", ...,
185185
fun.call = aggregate_funs(fun.call, lvals, sep, ...)
186186
maybe_err = function(list.of.columns) {
187187
if (!all(lengths(list.of.columns) == 1L)) {
188-
msg <- gettext("Aggregating functions should take a vector as input and return a single value (length=1), but they do not, so the result is undefined. Please fix by modifying your function so that a single value is always returned.")
188+
msg = gettext("Aggregating functions should take a vector as input and return a single value (length=1), but they do not, so the result is undefined. Please fix by modifying your function so that a single value is always returned.")
189189
if (is.null(fill)) { # TODO change to always stopf #6329
190190
stop(msg, domain=NA, call. = FALSE)
191191
} else {

R/fmelt.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ measurev = function(fun.list, sep="_", pattern, cols, multiple.keyword="value.na
7272
if (!is.character(cols)) {
7373
stopf("cols must be a character vector of column names")
7474
}
75-
prob.i <- if (is.null(names(fun.list))) {
75+
prob.i = if (is.null(names(fun.list))) {
7676
seq_along(fun.list)
7777
} else {
7878
which(!nzchar(names(fun.list)))
@@ -101,7 +101,7 @@ measurev = function(fun.list, sep="_", pattern, cols, multiple.keyword="value.na
101101
stopf("number of elements of fun.list (%d) must be the same as the number of capture groups in pattern (%d)", length(fun.list), ncol(start))
102102
}
103103
end = attr(match.vec, "capture.length")[measure.vec.i,]+start-1L
104-
measure.vec <- cols[measure.vec.i]
104+
measure.vec = cols[measure.vec.i]
105105
names.mat = matrix(measure.vec, nrow(start), ncol(start))
106106
substr(names.mat, start, end)
107107
} else { #pattern not specified, so split using sep.

R/fread.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ yaml=FALSE, autostart=NULL, tmpdir=tempdir(), tz="UTC")
317317
warning = fun <- function(c) {
318318
# NB: branch here for translation purposes (e.g. if error/warning have different grammatical gender)
319319
if (inherits(c, "warning")) {
320-
msg_fmt <- gettext("Column '%s' was requested to be '%s' but fread encountered the following warning:\n\t%s\nso the column has been left as type '%s'")
320+
msg_fmt = gettext("Column '%s' was requested to be '%s' but fread encountered the following warning:\n\t%s\nso the column has been left as type '%s'")
321321
} else {
322-
msg_fmt <- gettext("Column '%s' was requested to be '%s' but fread encountered the following error:\n\t%s\nso the column has been left as type '%s'")
322+
msg_fmt = gettext("Column '%s' was requested to be '%s' but fread encountered the following error:\n\t%s\nso the column has been left as type '%s'")
323323
}
324324
warningf(msg_fmt, names(ans)[j], new_class, conditionMessage(c), typeof(v), domain=NA)
325325
v

R/fwrite.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
8080
}
8181
if (NCOL(x)==0L && file!="") {
8282
if (file.exists(file)) {
83-
suggested <- if (append) "" else gettextf("\nIf you intended to overwrite the file at %s with an empty one, please use file.remove first.", file)
83+
suggested = if (append) "" else gettextf("\nIf you intended to overwrite the file at %s with an empty one, please use file.remove first.", file)
8484
warningf("Input has no columns; doing nothing.%s", suggested)
8585
return(invisible())
8686
} else {

0 commit comments

Comments
 (0)