Require usage of correctly-typed literals over literal coercions
Source:R/literal_coercion_linter.R
literal_coercion_linter.Rd
as.integer(1)
(or rlang::int(1)
) is the same as 1L
but the latter is
more concise and gets typed correctly at compilation.
Details
The same applies to missing sentinels like NA
-- typically, it is not
necessary to specify the storage type of NA
, but when it is, prefer
using the typed version (e.g. NA_real_
) instead of a coercion
(like as.numeric(NA)
).
See also
linters for a complete list of linters available in lintr.