You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Require drop = FALSE whenever [ is used with two or more args
Require na.rm argument for any function that has it (to force you to
think about missing values during development)
Don't use of require()/library() inside a function
Don't change global state: setwd(), options(), par() etc. Could
have next package robustr that contained alternatives (i.e. the with_*
functions from devtools)
Always turn partial matching warning options on (not really code
linting, but related)
Avoid functions that use NSE (with(), subset(), transform() etc)
Avoid functions that return different types of output (e.g. sapply())
TRUE and FALSE instead of T and F.
return() calls at the end of functions (result of last statement is always returned, so the explicit return() is redundant (and also slower as it requires an additional function call).
use of 1:length(x) in for loops (dangerous if length(x) can be 0) as 1:0 returns c(1, 0), should use seq_len(length(x)) instead.
Iterative appending to vectors within loops rather than pre-allocation the vectors and filling. (the former is quadratic in time complexity, as R has to keep re-sizing the vector on every assignment.
The following items have been implemented recently:
1:x usages are caught by seq_linter()
T_and_F_symbol_linter catches "T" and "F" instead of TRUE and FALSE.
setwd(), options(), par(), sapply are linted by undesirable_function_linter() using the functions listed by default_undesirable_functions(). Additional functions to lint can easily be added.
same thing for require, library, although all uses are detected, not just within a function
Suggestions from @hadley
think about missing values during development)
have next package robustr that contained alternatives (i.e. the with_*
functions from devtools)
linting, but related)
TRUE
andFALSE
instead ofT
andF
.return()
calls at the end of functions (result of last statement is always returned, so the explicitreturn()
is redundant (and also slower as it requires an additional function call).1:length(x)
in for loops (dangerous if length(x) can be 0) as1:0
returnsc(1, 0)
, should useseq_len(length(x))
instead.The text was updated successfully, but these errors were encountered: